Skip to content

fix(#803): stop the message-field skip masking a bookkeeping entrypoint sniff - #814

Merged
fdaviddpt merged 3 commits into
mainfrom
fix/803-clean
Sep 27, 2026
Merged

fdaviddpt merged 3 commits into
mainfrom
fix/803-clean

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

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:

rest=${line#*\"message\"}
prefix=${rest%%\"*}
case "$prefix" in
    *[!:[:space:]]*) is_dialogue=1 ;;
esac

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.md is 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)

  • Round 1 (Explore + oss:auditor): found and fixed a cap-bypass regression (the dialogue-skip branch used 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":"").
  • Round 2 (Explore + oss:auditor): both independently caught that round 1's prose fix left trap.d item 3's own body stale/self-contradictory; Explore separately caught that round 1's empty-string fix was a fixed-width literal match (0 or 1 space only), not a real width-independent shape check. Both fixed.
  • Round 3 (Explore only, narrower delta): NO FINDINGS, with one explicitly-non-reportable completeness note.

7 new tests in tests/test_entrypoint_sniff_bookkeeping_message_803.py, extracting the real shipped function bodies (same _function_body() technique tests/test_previous_transcript_no_sort_691.py already uses). Red: test_bookkeeping_string_message_does_not_mask_entrypoint failed pre-fix (bookkeeping entrypoint masked, exactly the issue). Green: 11 passed (7 new + 4 pre-existing sibling tests, no regression to previous_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 of origin/main. git merge-base --is-ancestor fix/803 origin/main returns false. The branch carries two raw, unsquashed commits for a DIFFERENT, already-separately-merged issue (#805: 0b0c76e and ffcb8e4) that predate origin/main's squashed merge of that same work (de83ad3, already on main). Confirmed independently: git-diff:branch:main from 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 what main already has, alongside this pull request's own 4 genuine #803 files (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 main will 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 rebasing fix/803 onto current origin/main before merge, or cherry-picking just the three #803 commits (a6d5d85, 2a88be1, 61f518c) onto a fresh branch off origin/main.

🤖 Generated with Claude Code

[AI-generated]

fdaviddpt and others added 3 commits September 27, 2026 01:45
`_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]>
@fdaviddpt
fdaviddpt merged commit b729cf6 into main Sep 27, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix/803-clean branch September 27, 2026 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session-start-hook.sh's entrypoint sniff (#745) has three unresolved false-negative/false-positive edges

1 participant