Skip to content

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.

LocationRole today
plugin/lib/model/entities/task/claims/paths.ts#splitFrontmatterLocal 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#collectCitationsbody.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#collectAcLinesRe-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.tsShipped precedent: reads the touchpoint table through mc parse / sectionsAt / rawTableRows / tableRowLines with line-aware positions
plugin/lib/model/entities/task/claims/tests/paths.test.tsBehavioural suite pinning paths findings and their line positions
plugin/lib/model/entities/task/claims/tests/quantifiers.test.tsBehavioural suite pinning quantifiers findings and their line positions

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.

  1. In quantifiers.ts, replace collectAcLines’s body.split("\n") + H2/fence hand-tracking with a single mc parse of the full doc; locate the Acceptance-criteria section via findSection(root, "Acceptance criteria", { depth: 2 }) (or sectionsAt(root, 2) filtered by name), enumerate its AC checklist lines, and skip fenced code with codeBlockLines. Use mc’s absolute line numbers directly; drop the offset + i + 1 rebasing.
  2. In paths.ts, replace the body.split("\n") + fence state machine in collectCitations with mc parse + codeBlockLines for fence skipping, keeping the existing inline-code path-token extraction over the non-fenced lines. Delete the local splitFrontmatter wrapper (the shared util/frontmatter split stays available if a body-only view is still wanted, but the line numbers come from mc’s absolute positions).
  3. Follow the parse-touchpoints.ts idiom 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, so codeBlockLines + section navigation are the direct fit.
  4. Confirm the Finding.line values 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.
  5. Run both claims suites.
LocationKindChange
plugin/lib/model/entities/task/claims/paths.ts#collectCitationsmodifySkip 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#collectAcLinesmodifyLocate ## 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.tsmodifyConfirm findings and line positions unchanged; additions only
plugin/lib/model/entities/task/claims/tests/quantifiers.test.tsmodifyConfirm findings and line positions unchanged; additions only
  • AC-1: Neither paths.ts nor quantifiers.ts contains a body.split("\n") call or a hand-rolled fence / H2 tracking state machine; both derive structure from a single mc parse.
  • AC-2: The local splitFrontmatter offset wrapper in paths.ts and the inline text.slice(...).split("\n").length offset math in quantifiers.ts collectAcLines are removed.
  • AC-3: Every Finding.line emitted 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.ts and plugin/lib/model/entities/task/claims/tests/quantifiers.test.ts pass (additions only, no expectation weakened).
  • The claim-resolver types.ts / index.ts registry and the check-claims op — 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.ts itself — it is the precedent, already on mc.
  • none — enabled by the already-vendored markdown-contract 0.2.0 (vendor/markdown-contract-0.2.0.tgz); no re-vendor needed. The precedent T-ZGO4 rebased the touchpoint-table reader onto mc and is already shipped (closed/done); this task applies the same idiom to the two claim scanners.
  • Surfaced by a read-side audit of remaining bespoke body.split("\n") scanners after the markdown-contract adoption (milestone M-0009). parse-touchpoints.ts reads the same corpus through mc; the claim resolvers were the residual hand-rolled readers.

← Back to Tasks