chore(core): strip history narration from comments - #9334
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS A gate-anticipated, shrink-only baseline remediation; spot-checked security-module rewrites preserve every invariant and rationale, and the token-stream proof makes the claim checkable. Suggestions
[DESIGN-REVIEWED] ae71aa5 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The "Manual verification" black reformat of Not justified as shipped
What this change shipsInventory (3 items) — 2 justifiedIntent: bring 113 top-level modules into compliance with the documented comment rule (code-style.md, enforced by
Verified mechanically: scanned every added and every removed diff line for code-shaped content ( [FIRST-PRINCIPLES-REVIEWED] ae71aa5 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsI've now independently verified the complete diff (all 7703 lines, end-to-end). Every change is prose inside The one comment a gate actually parses — the Step 1 has no candidates to falsify (the discovery pass reported none, which my own read confirms). Step 2 surfaced no new finding meeting the (a)/(b)/(c) bar. No findings. [OPUS-REVIEWED] ae71aa5 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
e8d2b32 to
977fe4a
Compare
977fe4a to
99dbf48
Compare
99dbf48 to
e0cb701
Compare
e0cb701 to
86f7e12
Compare
f8fa600 to
c7ed9e5
Compare
c7ed9e5 to
809a5a9
Compare
809a5a9 to
00e3431
Compare
00e3431 to
328a09b
Compare
|
comments change only. Better to merge, as it frequently cause the merge conflicts |
The code-style spec says a comment carries invariants, edge cases, units and the reason a surprising choice is correct -- not a task log. History lives in git. This applies that rule to the top-level modules of src/kiro_crew. Removed from comments and docstrings: PR, issue and ticket numbers, review-round and finding markers, and change-log sentences. Narration was rewritten into present-tense statements of what the code does now, so a reader can tell whether a comment describes the code in front of them. Comments that carried nothing but provenance were deleted outright. Every invariant, attack spelling, measured number and threat-model rationale was kept. Only the reference to how the code got there was dropped. comment-history-baseline.json is lowered to match: 56 entries pruned and 52 lowered, so the ratchet keeps shrinking rather than carrying counts this change already paid down. Comments and docstrings only. No executable code changed: the token stream of every file in this diff is identical to the base commit, with comments dropped and docstrings normalised.
Problem / Motivation
Comments in the top-level
src/kiro_crewmodules had turned into a task log. Theycarried PR and issue numbers, review-round markers, and sentences about what the
code used to do.
docs/system-specs/common/code-style.mdalready bans this in thesection "Comments explain the WHY": history lives in git, and a comment states
CURRENT behaviour in present tense.
Why it matters
A comment that narrates a change goes stale the moment the next change lands. A
reader cannot tell whether it describes the code in front of them or some earlier
version of it. That is worse than no comment, because it looks authoritative.
The numbers make it concrete. 858 comment and docstring lines in these files
matched history-narration patterns before this change. 10 match now, and each of
those 10 is a false positive the scanner cannot tell apart from real narration.
What changed (motivation → approach → change)
The rule was already written down but nothing applied it. So comments across 111
top-level modules still said things like "Perf short-circuit (#3603)" and "kiro-cli
historically denied that form". A reader had to guess which parts were still true.
The approach was to read every match in its surrounding code, then pick one of
three moves. Strip the reference and keep the sentence. Or rewrite the narration
as a present-tense statement of what the code does now. Or, if the comment said
nothing once the history was gone, delete it whole.
The change removes PR, issue and ticket numbers, review-round and finding markers,
and change-log sentences. Every invariant, attack spelling, measured number and
threat-model rationale was kept. Only the pointer to how the code got there went
away.
Two things were deliberately kept. A tracker id that points at another repository
and describes live future work, such as
# TODO: revert when kiro-cli PR #2034 merges, stays: the rule is about how THIS code got here, and removing that idmakes the TODO impossible to act on. And "previously" or "no longer" describing
runtime DATA state, such as a pid that no longer exists or a file previously read,
stays: those are statements about data, not about code history.
Tests
Comments and docstrings only, so no test outcome should move.
origin/main,with comments dropped and docstrings normalised to a placeholder. Verified
mechanically per file.
The same 156 test ids fail identically on a clean
origin/mainworktree, sothey are pre-existing local environment artifacts, not this diff.
Gates run locally, all passing: black (baselined), subprocess-encoding, isort,
flake8, brand name, feature-map, changelog-history, loop-bound-locks,
sync-io-in-async, agent-sdk-boundary, builtin-skill-scope, docs-lint.
mypyreports 108 errors here, identically on cleanorigin/main— the localinterpreter is 3.9 and the project floor is 3.12, so every one is a PEP 604 /
ParamSpec syntax artifact. CI runs it on a supported interpreter.
Manual verification
One file,
src/kiro_crew/mcp_cron.py, also picks up a whitespace-only blackreformat that joins a wrapped call onto one line. That file is unformatted on
origin/mainand is not in.github/black-baseline.txt, so it passes the gatetoday only because nothing brings it into scope. This PR is the first change to
touch it, which puts it in scope and exposes the pre-existing violation. The
repo's own rule is to format what you touch, so it is formatted. No tokens
changed, only line breaks.
Screenshots / video
Not applicable — no user-visible change.
Related Issues
None.
Pattern harvest
The check that made this safe was mechanical rather than careful reading: tokenise
each file before and after, drop comments, normalise docstrings to a placeholder,
and compare the remaining token stream. It caught three files where an agent had
reflowed real code, and it caught them for a reason worth recording — running
blackon a file listed in.github/black-baseline.txtreformats pre-existingcode, so "format what you touched" and "change no code" conflict in exactly those
files. The baselined ones have to be left unformatted.
It is also what makes the "no code change" claim in this PR checkable instead of
merely asserted. Any comment-only sweep should carry the same proof.
Checklist
docs/system-specs/common/code-style.mdappend-only and has no draft section to add to)
Contribution License Agreement
By submitting this pull request I confirm that my contribution is made under the
terms of the project's license.