Skip to content

Fix: gate NDC compression on reply shape, not just IS_REJECTED (#597) - #598

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/597
Sep 6, 2026
Merged

fdaviddpt merged 1 commit into
mainfrom
fix/597

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #597.

The defect

On the release audit's destroys ranking: a non-English refusal from the NDC compression call passed the reject gate unfiltered. DEFAULT_REJECT_PATTERN (pipeline/haiku.py) is anchored to English refusal stems ("i cannot", "could you", "i'm sorry", ...), and #593 put the model's reply in the conversation's own language into now.md in ordinary use for the first time. IS_REJECTED was the NDC branch's only content gate -- the summarize path already had a second one (ENTRY_HEADER_ERE), the NDC branch did not. A missed refusal was appended to today-*.md as though it were a genuine day summary, and now.md was then truncated over the entries that were supposed to have been compressed: gone, with no copy anywhere, since keep_rejected_text was never called on that branch.

The fix

scripts/save-session.sh's NDC branch now also rejects any reply whose first line does not open with a "## " header, and handles it exactly like the existing IS_REJECTED branch (kept at tmp/rejected-*.md, now.md left intact so the next round retries).

Deliberately not ENTRY_HEADER_ERE itself -- the shape the issue suggested reusing. That pattern requires a single HH:MM time, and compress-ndc.prompt.txt explicitly instructs the model to merge same-subject entries into one time-blocked entry with a RANGE (e.g. ## 08:48-09:22 | branch), which ENTRY_HEADER_ERE rejects on sight. Confirmed against the existing NDC test suite's own shared stub default (`"## 2026-07-25

  • compressed summary
    "), which also fails ENTRY_HEADER_ERE(a date, no pipe) and would have broken under the naive fix. The plain"## "` check is the one invariant every legitimate NDC output shares (single entry, merged range, or whole-day header) that no refusal shares, in any language.

Reasoned vs observed

Observed: the missing gate, the shape mismatch between ENTRY_HEADER_ERE and the NDC prompt's own contract, and the fix closing both the negative case (Chinese/French refusal) and its positive control (genuine non-English summary still stages and still truncates now.md) in a real end-to-end shell test.

Reasoned, not observed (per the issue's own framing, unchanged by this fix): whether a real model handed non-English now.md content genuinely refuses in that language. This PR does not attempt to settle that half.

Testing

tests/test_ndc_non_english_reject_gate_597.py, new: red (4 failed / 2 passed) before the fix, green (6 passed) after. Full local run of all touched/adjacent NDC and reject-gate modules: 73 passed. .oss/assemble_changelog.py --check passed with the new fragment. Full repo pytest was deliberately NOT run locally (CI is the gate); see the report for the narrowed-suite rationale.

Review

The developer subagent's own session lacked an Agent/Task spawn capability (Bash/Skill only) and could not run the mandated two-reviewer self-review directly. The dispatching session, which does hold Agent/Task, ran it afterward against this same committed diff: Explore returned NO FINDINGS after tracing the gate logic, the ENTRY_HEADER_ERE rejection, the truncation gating, and reverting the script to pre-fix to confirm the new test module is genuinely red on old code. oss:auditor returned one finding (below). Both final messages were classified via scripts/review_return.py rather than read by eye, and the worktree was confirmed clean before/after via scripts/tree_snapshot.py.

report-for-filing: pre-existing log-injection shape, now at one more call site

oss:auditor flagged that the new gate's reject-log line writes the Haiku reply's first 80 bytes into the log with no newline-stripping. Haiku reply text is untrusted (arbitrary now.md content per #593) and could contain an embedded newline within its first 80 bytes, forging what looks like a second log entry to anyone or anything reading the log file. This is not new to this diff -- the identical shape already exists unchanged one branch above (the existing IS_REJECTED log line) and again at save-session.sh:788. A real fix means sanitizing log()'s message handling once for every call site, in scripts/log.sh, which is a wider change than this issue's own diff and a design decision (escape, strip, or reject embedded newlines) this PR does not make unbriefed. Filing this for a maintainer decision on scope and on whether it ranks forges or misreports per the manager skill's ranking table.

Below-bar note

While reading the NDC branch, the comment at (pre-fix) save-session.sh:893-898 was found to describe this exact failure and its own last clause -- "now.md is left intact so the next round retries" -- claimed a property that was true of the sibling IS_REJECTED arm and NOT of the elif arm it sits above. That stale comment is now folded into the new comment block this fix adds at the same location, so it is fixed in-diff rather than filed separately.

[AI-generated]

A non-English refusal from the NDC compression call passed the reject gate
unfiltered, since DEFAULT_REJECT_PATTERN is anchored to English refusal
stems and #593 put the reply in the conversation's own language into that
path for the first time. It was written into today-*.md as a day summary
and now.md was then truncated over the entries it was meant to compress --
gone, with no copy anywhere.

scripts/save-session.sh's NDC branch now also rejects any reply whose first
line does not open with a "## " header -- the one thing every genuine
compression shares (a single entry, a merged time-blocked range, or a
whole-day header) that no refusal produces in any language -- and handles
it exactly like the existing IS_REJECTED branch. Deliberately not
ENTRY_HEADER_ERE itself: that shape requires a single HH:MM time and would
reject the merged-range header compress-ndc.prompt.txt explicitly asks the
model to produce.

tests/test_ndc_non_english_reject_gate_597.py drives both the missed-gate
case (Chinese and French refusals, IS_REJECTED left false as the real gate
does today) and its required positive control (a genuine non-English
summary must still stage and still truncate now.md).

Co-Authored-By: Max <noreply>
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.

A non-English refusal passes the NDC reject gate, is written into today-*.md, and now.md is then truncated over it — the entries are gone with no copy

1 participant