Repository navigation
fix(hooks): resolve open(var) paths in inline scripts; stop reporting read-only opens as edits - #177
Merged
Merged
Conversation
… read-only opens as edits (#176) Inline scripts that do `p='x.json'` then `open(p)` named no file, so the nudge and capture worklist never saw the read or the edit. 38% of inline file opens use a bare identifier; a preceding literal assignment exists for 1,838 of them across 752 local transcripts (+40% attributed commands). - inlineCalls: resolve `open(ident)` one hop to the last literal assignment before the call; tier each open call on its own instead of the whole command. - WRITE_API_RE: `open` is a write only when a mode string follows the path argument. The old `[^)]*['"][wax]` matched the first letter of the path, so open('assets/x.json') was reported as an edit. - Loops, argv, computed and `${}` paths stay unattributed. - cochange-nudge test that pinned "variable holding a literal claims nothing" now pins the new behaviour, plus controls for a truly computed target and a file that is only read. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #176
What changed
hooks/evidence.mjs:inlineCallsreplaces the singleAPI_ARG_REscan. For each file-open call in an inline script it resolves the path (a quoted literal, or a bare identifier resolved one hop to the last literal assignment before the call) and tiers that call on its own.WRITE_API_RE:opencounts as a write only when a mode string follows the first argument. The old pattern matched the first letter of the path, soopen('assets/x.json')was an "edit".for p in [...],sys.argv, string concatenation,${}templates, globs.Evidence
bashEditTargets -> []to['assets/i18n/en.json', 'app/pages/analytic/components/CardWidget/CardWidget.tsx'].tsc --noEmitclean.Deliberate test change
tests/cochange-nudge.test.tshad a test asserting thatconst f="src/b.ts"; writeFileSync(f, s)claims nothing. That is exactly the shape this PR resolves, so it now asserts the file IS an edit. I added two controls for what the old test was really protecting: a genuinely computed write target stays silent, and a file that is only read through a variable is never claimed as an edit.Not in this PR
prettier --write/eslint --fixas edits (listed as out of scope in #176). The notebook note forhooks/evidence.mjsstill describes the older behaviour; it needs akb writeand goes throughkb commit, not this feature branch.🤖 Generated with Claude Code