Skip to content

feat(constraints): a comment narrates as well as instructs - #21

Merged
ojassug merged 3 commits into
mainfrom
feat-narrative-directive-scope
Aug 12, 2026
Merged

feat(constraints): a comment narrates as well as instructs#21
ojassug merged 3 commits into
mainfrom
feat-narrative-directive-scope

Conversation

@ojassug

@ojassug ojassug commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

§51 (merged in #20) measured where the fallbacks actually are: 29 of 29 code-bucket fallbacks on the frozen corpus are CONSTRAINT_DIRECTIVE_LOST. Not drift, not AST — this gate, every time. This is the first pass at it.

§42 scoped the gate by region: an instruction lives in a comment, never in an expression, which stopped it firing on logger.critical(exc). This scopes it by mood within that region, because a comment is also where a codebase narrates its own history.

What it was refusing

Inspecting the matched text behind those 29 fallbacks, roughly twelve read like this:

"The MCP branch of runCli has always read these two"
"It never did: this branch bypassed pruning entirely"
"HTTP_PROXY and HTTPS_PROXY … could never have worked"
"a saving that never reached the wire (audit C4)"

Losing one of those costs a reader some history. Losing "never hash items matching preserveKinds" costs a caller a rule. The keyword is identical, and the gate refused the whole file for either.

Narrowed in the safe direction, three ways

This gate protects content — unlike §48 and §50, where a wrong call costs output size, a wrong call here silently deletes an instruction.

  1. Only never and always, the two keywords equally comfortable describing and instructing. must, must not, do not, required, critical, only if, except when, make sure to are untouched — "must have been called before" is a requirement about a past state, and a perfect-tense test applied to must would drop it.
  2. Only provable perfect/past constructions — a preceding have/has/had, or a following past-tense verb. "is always deterministic" and "do not support" are descriptive too and are left firing on purpose: there the line between describing a constraint and stating one is genuinely blurry.
  3. Unanimity before dropping. A segment goes only if every keyword in it is narrative-capable, so "this has always been true, so you must call it first" still fires.

The negative control is the load-bearing test

test/unit/narrative-directive-scope.test.ts asserts the eight narrative sentences stop firing — and that sixteen real instructions still do, several verbatim from this repository. A rule that drops one of those is not a better rule at any reduction figure, and the test says so directly rather than leaving it to a reduction number two layers away.

Measured — per-row, 576 rows, both routes, target 0.3, against v1.4.0

result
rows byte-identical 572 of 576
fallbacks fixed / new 4 / 0
rows newly reducing / stopped 4 / 0
rows already reducing that changed at all 0

TypeScript file route: 39 reduced / 16 fallbacks → 43 / 12, aggregate 18.52% → 24.58%. The four are adapters/mcp/tools.ts, cli/main.ts, gateway/exec.ts and gateway/proxy.tsexec.ts being the file that literally contains "could never have worked".

The caveat matters more than the headline

Python gained nothing — 0 of the 4. Every recovered file is this repository's own source, and this repository is unusually narrative: M11 measured 32.8% of src/ as comment prose, written in a what-used-to-be-true style. pip's comments describe behaviour in the present tense and were never caught.

So the 6pp on the TypeScript bucket is not a portable estimate. It is the corpus-bias trap CLAUDE.md warns about, showing up as a favourable number instead of an unfavourable one — the harder direction to notice. What is portable is the shape: zero regressions, and four files that produced nothing now produce something.

Still open on this axis, deliberately

Descriptive present-tense uses still raise directives. §50's other open item is the same gate: it is why the better sub-region coverage setting costs two working files.

657 tests, typecheck, lint and build green.

🤖 Generated with Claude Code

ojassug and others added 3 commits August 12, 2026 22:14
§51 measured where the fallbacks are: 29 of 29 code-bucket fallbacks on the frozen corpus
are CONSTRAINT_DIRECTIVE_LOST. Not drift, not AST -- this gate, every time.

§42 scoped it by region (an instruction lives in a comment, not an expression). This
scopes it by mood within that region, because a comment is also where a codebase explains
its own history. Roughly twelve of the 29 were sentences like "the MCP branch of runCli
has always read these two", "It never did: this branch bypassed pruning", "could never
have worked", "a saving that never reached the wire". Losing one of those costs a reader
some history; losing "never hash items matching preserveKinds" costs a caller a rule, and
the gate refused the whole file for either.

This gate protects content, so unlike §48 and §50 a wrong call deletes an instruction
rather than costing output size. Narrowed three ways, all in the safe direction:

  - only `never` and `always`, the two keywords equally comfortable describing and
    instructing. `must have been called before` is a requirement about a past state, and
    a perfect-tense test applied to `must` would drop it.
  - only provable perfect/past constructions. "is always deterministic" and "do not
    support" are descriptive too and are left firing on purpose -- there the line is
    genuinely blurry, and under-narrowing costs reduction while over-narrowing costs
    content.
  - unanimity: a segment is dropped only if every keyword in it is narrative-capable, so
    "this has always been true, so you must call it first" still fires.

The negative control is the load-bearing test: sixteen real instructions, several verbatim
from this repo, asserted to keep firing. A rule that drops one of those is not a better
rule at any reduction figure.

Per-row over 576 rows, both routes, target 0.3, against v1.4.0: 572 byte-identical, 4
fallbacks fixed, 0 new, 4 newly reducing, 0 stopped, and no change to any row that was
already reducing. The four are adapters/mcp/tools.ts, cli/main.ts, gateway/exec.ts and
gateway/proxy.ts -- exec.ts being the file containing "could never have worked".

The gain is NOT portable and that caveat is in §52: all four are this repository's own
source, which M11 measured as 32.8% comment prose written in a what-used-to-be-true style.
Python gained zero. The 6pp on the TypeScript bucket is the corpus-bias trap CLAUDE.md
warns about, showing up as a favourable number, which is the harder direction to notice.

657 tests, typecheck, lint and build green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
§7 item 5 is done as a first pass (§52) with its caveat carried forward: the 6pp is
this repository's own narrative comment style, not a portable figure, and Python gained
zero. Names what is deliberately still open on that axis -- descriptive present-tense
uses -- and why over-narrowing a content-protecting gate is the expensive direction.

Suite count 628 -> 657.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ojassug
ojassug merged commit 36dcdeb into main Aug 12, 2026
3 checks passed
@ojassug
ojassug deleted the feat-narrative-directive-scope branch August 15, 2026 12:59
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.

1 participant