Skip to content

B5: figure-edge false refusal in capture availability (region slices dotted figures) #498

Done

Description

@abogartz

Related to #389. Follow-up from PR #493 review context; B5 label previously appeared only in fixture/source comments.

Problem

Known B5 false-refusal bug in src/capture/available.ts: figure rules disagree at figure edges. findClause/region bounds can admit a region ending at a non-word . while numericTokens treats . as figure continuation, slicing dotted figures. Examples: Requires Python 3 vs Requires Python 3.12, The cost is 11 vs The cost is 11.5.

Current vouch path: check() slices haystack.slice(region.start, region.end) and passes it to numericTokens(...) (around 949-970). Region bounds come from restatedContiguously/findClause; if a bound lands on a figure edge, the slice can tokenize a partial figure.

No existing regression test coverage found for 3.12/11.5 cases.

Proposed fix (separate step, not tests-as-is)

One invariant: regions never slice figures; only whole figures vouch.

  • Snap region bounds outward over [0-9.], or vouch whole tokens intersecting [start, end).
  • Should collapse/subsume figureRun + isTokenChar + hitCoversFigures + figuresWithin into one definition.
  • Verdicts change by design; land as own step: add B5 regression test first (red), then fix, keep other tests green.

Tests-as-is refactor opportunity (safe before/alongside)

  • Flatten check() (917-1026): hoist tree-path and gate-path checks into top-level helpers taking (haystack, slices, gates, ...). No verdict change.
  • Consolidate boundary/token/figure model: isBoundary, isTokenChar, figureRun, splitClaims, sentenceSpan, findClause, hitCoversFigures, gapIsPunctuation, figuresWithin/numericTokens. Name the invariant explicitly.
  • Compress design-history comments into one header design note + short invariant pointers; keep invariant-bearing comments.
  • Realistic outcome: ~750-800 lines (~25% down). Algorithmic complexity remains - six vetoes over positional matcher.

Key files

  • src/capture/available.ts
  • src/core/tokenize.ts (numericTokens)
  • tests: test/capture/capture-available.test.ts, test/capture/available-fail-open.test.ts, bench/fixtures/availability-cases.ts

Activity

  1. abogartz commented on Nov 23, 2026

    @abogartz
    OwnerAuthor

    Repro on main d5fa338e: the named examples are already pinned, two other shapes are live

    The two examples in the problem statement do not reproduce, and the reason is that PR #493 already shipped pins for them. test/capture/availability-case-bank.test.ts runs the bank in CI and asserts both:

    • figure-trunc-version-tail — tree Requires Python 3.12, candidate Requires Python 3, expectTag: false
    • figure-trunc-dotless-tail — tree The cost is 11.5., candidate The cost is 11, expectTag: false

    tokens() keeps dotted figures whole — "Requires Python 3.12" tokenizes as ["requires","python","3.12"] — so the claim matcher never matches 3 against 3.12, no region is produced, and the candidate is kept. The statement "no existing regression test coverage found for 3.12/11.5 cases" is not correct for current main.

    The invariant this ticket states is still right, and two shapes that violate it are live and unpinned.

    1. False refusal through the thousands comma — loses a fact.

    tokens("the limit is 1,024 rows.")  →  ["the","limit","is","1","024","rows."]
    

    Tracked The limit is 1,024 rows. against candidate The limit is 1 gives REFUSED in_tracked_file. The comma splits the grouped figure, so the region vouches for a bare 1 the tree never states. The control The limit is 1,024 rows refuses correctly, so the relation is not simply dead.

    2. Missed refusal where a sentence-final period glues onto the figure — costs a duplicate.

    tokens("the ratio is 1.5.")  →  ["the","ratio","is","1.5."]
    

    Tracked The ratio is 1.5. against candidate The ratio is 1.5 gives kept, although the tree states it. The same shape reproduces with The cost is 11.5. against The cost is 11.5. The control The ratio is 1.5. — candidate carrying the dot — refuses correctly. This direction is fail-open, so it spends a row rather than a fact.

    Both directions come from one root cause: tokens() treats . as figure continuation but , as a separator, and it does not strip a sentence-final . from a figure, so the figure edge the region logic sees is not the figure edge the tokenizer sees. The B6 work made dots inside a figure atomic; it did not cover the comma or the trailing period.

    Scope going forward. Fixing the two shapes above under this ticket, with bank rows for each plus the same-shape controls quoted here, so a green bank proves the relation moved rather than weakened. The 3.12 and 11.5 examples stay as they are: already pinned, nothing to fix.

  2. ocsi-architect commented on Nov 23, 2026

    @ocsi-architect

    Pre-architecture review — Appendix A, before any code

    Run against src/capture/available.ts and src/core/tokenize.ts as they stand on main at d5fa338e. Filesystem only: the PR thread, reviews and follow-up issues were not read, per the Appendix A contract. Deliverables are reproduced verbatim below; the tier call is at the end.


    Architecture review — src/capture/available.ts @ d5fa338e

    Measurements first (scratch run, temp git repo, README = The limit is 1,024 rows. The ratio is 1.5.):

    "The limit is 1"        -> REFUSE README.md     ← false refusal, tree says 1,024
    "The ratio is 1.5"      -> keep                 ← false keep, tree says 1.5.
    "The ratio is 1.5."     -> REFUSE README.md     ← verdict flips on candidate punctuation
    tokens("The limit is 1,024 rows.") = ["the","limit","is","1","024","rows."]
    tokens("The ratio is 1.5.")        = ["the","ratio","is","1.5."]
    

    Orchestrator's five floor claims: all confirmed. check() is 917–1026, vouch set built at available.ts:960, header claim at available.ts:247.

    Design space

    The problem: decide "does the tracked tree already state this candidate" where false-refusal loses a fact forever. Options:

    1. Normalized substring containment — trivial, but refuses on coincidental substrings inside larger claims; no markup robustness.
    2. Token-sequence containment, one shared tokenizer — whitespace/markup robust; boundary semantics defined once for free; still exact-word brittle.
    3. Bag-of-tokens subset — order-free, so cross-sentence collisions refuse; the B6 pairing defect (bench/fixtures/availability-cases.ts:261-266) kills it.
    4. Key-fact extraction (figures/ids) + presence check — cheap; figure boundary is exactly where presence checks lie. The comma bug here is an instance of this option's classic failure.
    5. Embedding similarity + threshold — paraphrase-robust, but verdicts irreproducible; an evidence line can't defend a cosine.
    6. LLM judge — best accuracy; cost, nondeterminism, offline death. Explicitly excluded by the module's own criterion 1 (available.ts:11-12).
    7. Structural per-unit matching — split both sides into assertion units, containment within one unit; prevents cross-sentence reassembly; requires a clause-boundary definition, which is where the whole fight lives.
    8. Hybrid: lexical locator + independent vetoes — locator finds a passage, vetoes (polarity, figures, contiguity) can only decline the refusal. Fail-safe by Saltzer-Schroeder construction.

    Figure-boundary sub-design (the defect site), independent of 1–8:

    • 8a. One shared tokenizer for locator and figure-vouch.
    • 8b. Span-carried vouch — vouch consumes the locator's own figure spans; no re-tokenization of a slice.
    • 8c. Canonical figure at tokenize time — 1,024→1024, trailing dot stripped; blast radius hits GATE-3 and the rejection sketch (tokenize.ts:1-7 says they share tokens() on purpose).
    • 8d. Edge abstention — any hit adjacent to figure-shaped punctuation abstains (keeps); can only remove refusals.

    Placement verdict

    The implementation is 7+8 hybrid with 8a claimed but not enforced. It protects against reassembly (B5/B6), polarity reversal (available.ts:690-693), warning-object matches (VETO 1b, available.ts:646-684), and operand reordering (available.ts:500-537). It does not protect the figure ontology itself. Three boundary vocabularies coexist: isBoundary treats . and , as clause edges (available.ts:169-178); isTokenChar treats . as a figure char and , as neither (available.ts:704-711); the human notion treats both as inside a number. The contract "Nothing else in this file may decide where a figure begins or ends" (available.ts:717-719) is enforced by a hand-copied char class that duplicates tokenize.ts:29's split regex — correct today by eye, not by code.

    The shared definition is itself wrong in both directions, measured above:

    • Comma: tokens("1,024") → ["1","024"], so 1 is a legal figure the tree "states"; the hit the limit is 1 ends at the comma, which figureRun doesn't see as figure territory, so hitCoversFigures (available.ts:745-751) admits it, and the region slice ends before 024 so the vouch set is {1} (available.ts:960). Refused. The comment at available.ts:247 — "cannot be assembled out of separate integers" — is measured false for comma grouping, and ADR 0009's "A figure is one token wherever the matcher reads it" is false for 1,024.
    • Trailing dot: tokens("1.5.") glues the sentence dot (tokenize.ts:29), so 1.5 ∉ {1.5.} and hitCoversFigures rejects the hit; the same fact refuses only if the candidate carries the period. Verdict depends on how the session phrased its prose.

    The bank pins six 1.5-family shapes (bench/fixtures/availability-cases.ts:162,191-215,228,261) and zero comma-grouped cases, zero trailing-period-flip cases. The escape-shape bank has the same blind spot as the matcher.

    Two alternatives

    A. Single-source figure extent + canonical comparison.
    (a) Export one figureExtent(text, pos) from tokenize.ts, built from the same grammar as tokens(), with figure grammar [0-9](?:[,.][0-9])* where a separator counts only between digits (so 1,024 and 1.4.3 are one figure; the . of 1.5. is not). numericTokens compares canonical values (commas stripped). isTokenChar/hitCoversFigures call it instead of duplicating.
    (b) Wins when comma-grouped and sentence-final figures are common in docs — they are in this repo's own prose, and the bank's silence is an artifact of authoring, not corpus.
    (c) Distinguishing test, three bank cases: (The limit is 1, tree 1,024 rows.) expect keep; (The ratio is 1.5, tree 1.5.) expect refuse; (The limit is 1,024, same tree) expect refuse. Current code: REFUSE / keep / REFUSE — fails two of three. A passes all three.

    B. Edge abstention (8d).
    (a) In findClause after hitCoversFigures: if the hit's edge token contains a digit and the adjacent haystack char is . or ,, return -1. One function, one file, structurally veto-only.
    (b) Wins when tokenize.ts is untouchable — and it is: GATE-3 floors and the tombstone sketch score on tokens() (tokenize.ts:1-7), so A's canonicalization is a cross-subsystem change with its own blast radius B doesn't have.
    (c) Distinguishing measurement: refusal rate over the bank corpus plus a real repo. Both fix the false refusal; A keeps the legitimate 1.5. refusal, B loses it. If the lost-refusal rate is material, A wins; if gates tests break, B ships first.

    Rot mechanism

    src/capture/available.ts:704-711, isTokenChar. A maintainer fixes the comma bug the obvious way — add , to isTokenChar so figureRun spans 1,024 — and does not touch tokens() at tokenize.ts:29 because that would change GATE-3 scoring and tombstone matching. Now hitCoversFigures refuses the 1-prefix hit, but numericTokens still emits 1 and 024 separately, and any other path where a 1-figure candidate reaches figuresWithin against a region containing 1,024 gets vouched again. The two definitions diverge; the comment at available.ts:717-719 becomes a lie; nothing fails. The bank pins verdicts on fixed strings, never the equivalence between the two definitions, so CI is green. Same rot on - (version ranges), same rot on any tokenizer "improvement".

    State-boundary map

    Once-computed state consumed per item:

    Site Shape Per-item or global Wrong-verdict construction
    available.ts:955 region → 960 re-tokenized slice first-match union, then re-derived boundaries. Region from earliest admissible chain; numericTokens re-decides figure edges on the slice — a second boundary decision hitCoversFigures never made global per check Measured: The limit is 1 vs The limit is 1,024 rows. → REFUSE. Slice ends at comma; vouch set {1}; tree figure was 1,024. False refusal.
    available.ts:990 first gateHit → 1006 introducesNewNumber(content, gate.label) first-match union: one gate vouches all figures in content, while operandsDeclared deliberately re-hits per span (523, with the bug confession at 524-529). The number veto was not given the same fix global where per-item intended Every construction I found fails open (extra figure → veto → keep), e.g. sync2 + deploy --replicas 2 against a deploy gate lacking 2 keeps via operand veto. Latent, not live — but it is the same shape as the documented-and-fixed operands bug, and the asymmetry invites the next dev to "clean up" the per-span re-hit back into the shared gate.
    available.ts:462-470 vouchLabels where-union union across gates sharing where, consumed per operand global per gate Guarded: script-kind where names one command (name+cmd pair); step-kind guarded by solo (361-364). No construction found.
    available.ts:885-908 haystack union + byte budget global scan, per-candidate consumption global Claim at 844 (truncation only lowers refusals) holds for the text path. Gate path reads gate files outside the budget (382-427) — consistent with "manifest declares existence", no false refusal constructed.
    available.ts:940 safeFirst first claim only, for the evidence line telemetry Hides the failure class: the comma false refusal prints where: README.md, matched: the limit is 1 — a truthful substring. An auditor reading the evidence line cannot see the tree said 1,024. The visibility surface hides exactly the bug that matters.
    available.ts:930 filler-empty fallback to whole global per candidate global All-filler candidates state nothing; refusal loses nothing. OK.
    available.ts:745-751 hitCoversFigures edge-only check per-hit per-item Logic sound for runs that cross edges; blind to runs the ontology splits (comma). Not an edge bug, a definition bug.

    Standard

    A finding BLOCKS when a maintainer can reintroduce the bug without noticing. Here: yes, three independent ways — edit either char class in isolation (rot mechanism above); author bank cases without comma/trailing-dot shapes (already happened); trust the 247/ADR-0009 comment as the spec (it asserts a property the tokenizer does not have).

    Verdict: BLOCKS. Not DRASTIC — the veto-only, fail-open, region-scoped, contiguity architecture is right and I would defend it in one line: every guard fails toward keeping, which is the only defensible asymmetry when a wrong refusal is unrecoverable. The defect is one wrong character class, duplicated by hand, asserted in comments, untested at its edges.

    Minimum change to pass: (1) figure grammar fix — separator between digits is figure-internal, sentence-final dot is not — with isTokenChar/figureRun and numericTokens derived from one exported definition, not copied; (2) the three distinguishing bank cases pinned; (3) if tokens() blast radius is not accepted this cycle, ship alternative B (edge abstention) as interim — it converts both measured wrong verdicts to keeps and cannot create a false refusal. Also correct available.ts:247 and the ADR 0009 atomicity sentence, which currently document 1,024 as handled when it is not.


    Tier call: tier:full

    Applied. The change touches a predicate that decides irreversibly what is stored, which is T3 by definition, and the arch finding widens it past a local patch: the minimum passing change derives isTokenChar, figureRun and numericTokens from one exported figure grammar, which reaches into src/core/tokenize.ts and therefore into GATE-3 scoring and tombstone matching. That is a cross-subsystem blast radius, not a behavior change inside an existing pattern, so tier:standard would understate it.

    Two notes for whoever picks this up. The escape-shape bank has the same blind spot as the matcher — six 1.5-family rows, zero comma-grouped, zero trailing-period-flip — so the bank rows are part of the fix, not a follow-up. And the evidence surface at available.ts:940 reports matched: the limit is 1 against a tree that says 1,024, which is a truthful substring that hides exactly this class; a fix that leaves the evidence line unchanged leaves the bug invisible to an auditor.

  3. added
    tier:full
    on Nov 23, 2026
  4. abogartz-opencode-self-improvement commented on Nov 23, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.34.2 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  5. added
    severity:high
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    releasedseverity:hightier:full

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions