T-1W6P-rebase-claims-line-scanners-on-markdown-contract
Status: closed/done · Impact: low · Complexity: medium
The two claim resolvers under plugin/lib/model/entities/task/claims/ each
re-derive document structure by hand: paths.ts runs its own frontmatter split
plus a body.split("\n") fence-tracking state machine, and quantifiers.ts
runs a body.split("\n") loop that hand-tracks the ## Acceptance criteria
heading and code fences. Both also rebase body line indices onto the raw file
with their own offset arithmetic. mc 0.2.0 (already vendored) parses the whole
document — frontmatter included — and reports absolute source line numbers, so
the offset math and the hand-rolled section/fence tracking can be deleted while
the resolvers keep emitting exact raw-file line positions.
| Location | Role today |
|---|---|
plugin/lib/model/entities/task/claims/paths.ts#splitFrontmatter | Local wrapper around the shared util/frontmatter split that also computes the frontmatter line count, so body line indices can be rebased onto the raw file |
plugin/lib/model/entities/task/claims/paths.ts#collectCitations | body.split("\n") + a hand-rolled fence-tracking state machine, then per-line inline-code path extraction; line = lineOffset + i + 1 |
plugin/lib/model/entities/task/claims/quantifiers.ts#collectAcLines | Re-derives the frontmatter offset inline, body.split("\n"), then hand-tracks the ## Acceptance criteria H2 and code fences; line = offset + i + 1 |
plugin/lib/model/entities/task/ops/parse-touchpoints.ts | Shipped precedent: reads the touchpoint table through mc parse / sectionsAt / rawTableRows / tableRowLines with line-aware positions |
plugin/lib/model/entities/task/claims/tests/paths.test.ts | Behavioural suite pinning paths findings and their line positions |
plugin/lib/model/entities/task/claims/tests/quantifiers.test.ts | Behavioural suite pinning quantifiers findings and their line positions |
Proposed
Section titled “Proposed”Both resolvers derive structure and line positions from a single mc parse of
the full document text. quantifiers locates the ## Acceptance criteria
section through mc navigation (findSection / sectionsAt) and reads its AC
checklist lines with mc’s absolute line numbers. paths skips fenced code via
mc’s codeBlockLines (the source lines occupied by fences) instead of its own
fence state machine. Because mc parses the whole doc including frontmatter, the
line numbers it reports are already raw-file-absolute — the local
splitFrontmatter offset wrapper in paths.ts and the inline offset math in
quantifiers.ts are deleted, not reimplemented. Every finding’s line is
byte-for-byte the same value as today.
Approach
Section titled “Approach”- In
quantifiers.ts, replacecollectAcLines’sbody.split("\n")+ H2/fence hand-tracking with a single mcparseof the full doc; locate the Acceptance-criteria section viafindSection(root, "Acceptance criteria", { depth: 2 })(orsectionsAt(root, 2)filtered by name), enumerate its AC checklist lines, and skip fenced code withcodeBlockLines. Use mc’s absolute line numbers directly; drop theoffset + i + 1rebasing. - In
paths.ts, replace thebody.split("\n")+ fence state machine incollectCitationswith mcparse+codeBlockLinesfor fence skipping, keeping the existing inline-code path-token extraction over the non-fenced lines. Delete the localsplitFrontmatterwrapper (the sharedutil/frontmattersplit stays available if a body-only view is still wanted, but the line numbers come from mc’s absolute positions). - Follow the
parse-touchpoints.tsidiom for the mc call shape and its line-aware helpers (rawTableRows/tableRowLines) as the reference for any row-level reading; the AC checklist and prose citations here are line-scanned rather than table-scanned, socodeBlockLines+ section navigation are the direct fit. - Confirm the
Finding.linevalues are unchanged (1-indexed into the raw file) for every fixture in both suites; adjust only if a fixture asserted a position the old offset math got wrong. - Run both claims suites.
Files to touch
Section titled “Files to touch”| Location | Kind | Change |
|---|---|---|
plugin/lib/model/entities/task/claims/paths.ts#collectCitations | modify | Skip fenced code via mc codeBlockLines; source line numbers from mc’s absolute positions; delete the local splitFrontmatter offset wrapper |
plugin/lib/model/entities/task/claims/quantifiers.ts#collectAcLines | modify | Locate ## Acceptance criteria via mc findSection / sectionsAt, skip fences via codeBlockLines, drop the inline frontmatter-offset math |
plugin/lib/model/entities/task/claims/tests/paths.test.ts | modify | Confirm findings and line positions unchanged; additions only |
plugin/lib/model/entities/task/claims/tests/quantifiers.test.ts | modify | Confirm findings and line positions unchanged; additions only |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1: Neither
paths.tsnorquantifiers.tscontains abody.split("\n")call or a hand-rolled fence / H2 tracking state machine; both derive structure from a single mcparse. - AC-2: The local
splitFrontmatteroffset wrapper inpaths.tsand the inlinetext.slice(...).split("\n").lengthoffset math inquantifiers.tscollectAcLinesare removed. - AC-3: Every
Finding.lineemitted by both resolvers is byte-identical to today’s value (1-indexed into the raw file) for the two claims suites’ fixtures — the CRITICAL invariant, since these positions drive claim placement. - AC-4:
plugin/lib/model/entities/task/claims/tests/paths.test.tsandplugin/lib/model/entities/task/claims/tests/quantifiers.test.tspass (additions only, no expectation weakened).
Out of scope
Section titled “Out of scope”- The claim-resolver
types.ts/index.tsregistry and thecheck-claimsop — the resolver interface and registration are unchanged. - Any change to WHAT the resolvers flag (path relocation heuristic, universal- quantifier heuristic) — this is a parsing-path rebase only.
parse-touchpoints.tsitself — it is the precedent, already on mc.
Dependencies
Section titled “Dependencies”- none — enabled by the already-vendored
markdown-contract0.2.0 (vendor/markdown-contract-0.2.0.tgz); no re-vendor needed. The precedentT-ZGO4rebased the touchpoint-table reader onto mc and is already shipped (closed/done); this task applies the same idiom to the two claim scanners.
Discovery context
Section titled “Discovery context”- Surfaced by a read-side audit of remaining bespoke
body.split("\n")scanners after the markdown-contract adoption (milestone M-0009).parse-touchpoints.tsreads the same corpus through mc; the claim resolvers were the residual hand-rolled readers.