Repository navigation
fix(#803): stop the message-field skip masking a bookkeeping entrypoint sniff - #814
Merged
Merged
Conversation
`_transcript_is_pluginless_sdk()` (#745) skipped every line carrying a top-level "message" key on the theory that such a line is always real dialogue. A bookkeeping record's own "message" field can be a plain string (an error/status value on e.g. a queue-operation record) rather than the nested {role, content} object real dialogue always uses -- and when that same line also carries "entrypoint", the substring-only skip discarded it unseen, silently defeating the pluginless-SDK exclusion #745 exists to provide. Discriminates on the field's own JSON shape instead: _stdin_json_string only succeeds on a quoted-string value, so it now distinguishes the object shape (skip, real dialogue) from the string shape (fall through to the entrypoint check, like any other bookkeeping line) with no new JSON-parsing machinery. Closes edge 3 of trap.d/745.entrypoint-sniff-has-two-unfixed-edges.md; edges 1 and 2 remain open, unchanged, per that fragment's own note that they need a curation decision rather than a fix mid this issue's own context. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…date stale prose Two spawned reviewers (Explore + oss:auditor) against the #803 commit found: 1. (Explore) A real regression: the dialogue-skip branch used `continue`, which jumps past the `_ENTRYPOINT_SNIFF_CAP` check on every dialogue line -- since ordinary transcripts are overwhelmingly dialogue, this silently defeated the scan cap for the common case. Fixed by replacing `continue` with an `is_dialogue` flag checked by the entrypoint case below, so the cap check always runs every iteration. Pinned by two new paired tests (cap still enforced past a wall of dialogue lines; entrypoint within the cap past the same wall is still found). 2. (Explore) Stale prose: the function's own header comment and trap.d/745's item 2 still asserted the pre-#803 "any message field is skipped outright" behavior. Both updated to describe the shape discrimination. 3. (oss:auditor) A residual masking edge: `_stdin_json_string` fails identically on an object-shaped value and a genuinely EMPTY string value (its own `[ -n "$value" ]` guard), so `"message":""` on a bookkeeping line collapsed into the same skip as real dialogue, reproducing the #803 bug for that one shape. Fixed with a direct check for the empty- string form; pinned by a new test. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…e the shape check A second, lightweight review round over the round-1 fix commit (2a88be1) -- triggered by scripts/fix_commit_scope.py's own needs-second-pass verdict for touching 3 files -- found two more issues, independently, from both spawns: 1. trap.d/745.entrypoint-sniff-has-two-unfixed-edges.md's own item 3 body was left unedited by the first self-review pass even though the file's header (edited in that same pass) already claims "Edge 3... was fixed by #803" -- item 3's body still described the edge as open and untested, directly contradicting both the header and the new tests. Rewritten to say CLOSED and to name the two tests that pin it. 2. The empty-string discriminator added in the first self-review pass (`*'"message":""'*|*'"message": ""'*`) only covered zero or one space after the colon -- a literal match on a fixed set of widths, not a real shape check. Two spaces, a tab, or any other width fell through to the object-shaped (dialogue) branch and re-masked the entrypoint, on code that did not exist before the previous commit. Replaced with a direct shape check (does only colon/whitespace separate the "message" key from its value's opening quote, the same test _stdin_json_string's own prefix check already relies on) that is width-independent by construction and makes the empty-string special case, and the earlier _stdin_json_string round-trip, both unnecessary. Pinned by a new two-space regression test. Co-Authored-By: Claude Sonnet 5 <[email protected]>
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 #803
What
_transcript_is_pluginless_sdk()(added by #745) skips any line carrying a top-level"message"key on the theory that such a line is always real dialogue, never a bookkeeping record. That theory is wrong: an Agent SDK bookkeeping record (e.g. an error/status value on a queue-operation record) can carry"message"as a plain STRING, not the{role,content}OBJECT real dialogue always uses. The old substring-only skip (case "$line" in *'"message"'*) ;;) discarded such a line unseen, silently defeating the whole entrypoint exclusion when that same line also carried"entrypoint"-- exactly the false-negative edge #803 (edge 3 of #745's three logged edges) named.Fix
Discriminate the
"message"field's own JSON shape inline, without an external parser:If
"message"is followed (after any whitespace) by an opening quote, it is a string value (bookkeeping, any length including empty) and falls through to the entrypoint check like any other line; anything else (most plainly{) is the object shape real dialogue always uses and is skipped. The scan cap (_ENTRYPOINT_SNIFF_CAP) now runs unconditionally every loop iteration, fixing a cap-bypass regression introduced and caught during this lane's own self-review (see below).trap.d/745.entrypoint-sniff-has-two-unfixed-edges.mdis updated: edge 3 is now CLOSED (mechanism + tests named); edges 1 (no evidence check) and 2 (substring scan, not a JSON parse) remain open, unchanged, by design -- both were explicitly deferred as curation decisions needing broader context than one issue's lane carries.Self-review (3 rounds, each triggered by fix_commit_scope.py's needs-second-pass verdict)
continue, jumping past the cap check on every dialogue line), stale prose in the function header and trap.d, and an empty-string masking edge ("message":"").7 new tests in
tests/test_entrypoint_sniff_bookkeeping_message_803.py, extracting the real shipped function bodies (same_function_body()techniquetests/test_previous_transcript_no_sort_691.pyalready uses). Red:test_bookkeeping_string_message_does_not_mask_entrypointfailed pre-fix (bookkeeping entrypoint masked, exactly the issue). Green: 11 passed (7 new + 4 pre-existing sibling tests, no regression toprevious_transcript()/_second_newest_jsonl()).Known branch-base anomaly -- please read before choosing a base/head or squash strategy
This branch (
fix/803) was already cut before this lane started, and its base is NOT an ancestor oforigin/main.git merge-base --is-ancestor fix/803 origin/mainreturns false. The branch carries two raw, unsquashed commits for a DIFFERENT, already-separately-merged issue (#805:0b0c76eandffcb8e4) that predateorigin/main's squashed merge of that same work (de83ad3, already onmain). Confirmed independently:git-diff:branch:mainfrom this worktree shows 8 files changed, 4 of which belong to #805 (tests/test_rotated_slices_guard_805.py,changelog.d/805.security.md,scripts/lib-memory-context.sh,docs/windows-skip-triage.md) and are net content-identical to whatmainalready has, alongside this pull request's own 4 genuine#803files (scripts/session-start-hook.sh,tests/test_entrypoint_sniff_bookkeeping_message_803.py,trap.d/745.entrypoint-sniff-has-two-unfixed-edges.md,changelog.d/803.fixed.md).Opening this pull request as-is against
mainwill show a confusing, duplicate-looking diff and 5-commit history. This was not rebased or altered by the lane or by this report, per the developer brief's instruction against a pre-push rebase-and-rerun -- it pre-existed this lane's own work. Recommend either rebasingfix/803onto currentorigin/mainbefore merge, or cherry-picking just the three #803 commits (a6d5d85,2a88be1,61f518c) onto a fresh branch offorigin/main.🤖 Generated with Claude Code
[AI-generated]