Skip to content

fix(T12030): preserve semicolons inside note: atom payloads (#1126) - #1133

Open
kryptobaseddev wants to merge 2 commits into
mainfrom
task/T12030
Open

fix(T12030): preserve semicolons inside note: atom payloads (#1126)#1133
kryptobaseddev wants to merge 2 commits into
mainfrom
task/T12030

Conversation

@kryptobaseddev

@kryptobaseddev kryptobaseddev commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Problem

The evidence atom parser (parseEvidenceString) naively split on every ;, which truncated note: payloads containing semicolons. A note like note:AC1 verified via satisfy; AC2 tool:lint; AC3 documented would be incorrectly broken into multiple chunks, causing malformed-atom errors.

Closes #1126.

Fix (2 commits)

Commit 1: Boundary-aware split

  • Adds EVIDENCE_ATOM_KINDS — a typed readonly constant array covering every recognized atom kind (shared SSoT for the discriminated union, boundary regex, and error messages).
  • Builds KIND_BOUNDARY_REGEX — splits at ; only when followed by a known kind: prefix. Semicolons inside note: payloads are preserved.
  • Includes state in the parser-prefix list so pr:357;state:MERGED still splits correctly.
  • Unknown-kind-like text after a ; inside a note stays as note content — only standalone atoms with truly unknown kinds are rejected.

Commit 2: Compatibility — strip trailing separator semicolons

  • The boundary-aware split preserved semicolons in every payload, causing: commit:abc1234; → sha=abc1234; (regression), ;; between atoms leaked into structured payloads.
  • Fix is kind-aware: strip leading ; from every chunk (leftover from ;; separator artifacts), and strip trailing ; from non-note atom payloads (the old naive split consumed those as empty chunks). Note payloads preserve every character including trailing ; as real punctuation.

Changes (2 files)

File Change
packages/contracts/src/evidence-atom-schema.ts EVIDENCE_ATOM_KINDS, PARSER_PREFIXES, KIND_BOUNDARY_REGEX; kind-aware split + trailing-strip
packages/contracts/src/__tests__/evidence-atom-schema.test.ts 22 new regression tests (semicolons in notes, trailing ;/;; across non-note atoms, mixed atoms, mid-payload ; in urls)

Test Results

  • 129 contracts tests pass (81 evidence-atom-schema + 48 satisfies-atom)
  • 0 new failures
  • Biome: clean

The evidence atom parser naively split on every ';', which truncated
note: payloads that contain semicolons (e.g. multi-sentence waivers).
Replace with a boundary-aware regex that splits only at semicolons
preceding known atom-kind prefixes (commit:, files:, tool:, etc.).

- Add shared typed EVIDENCE_ATOM_KINDS constant (contracts) — one list
  for the discriminated union, the boundary regex, and error messages.
- Build KIND_BOUNDARY_REGEX from EVIDENCE_ATOM_KINDS + state modifier.
- Derive unknown-kind error text from the same constant.
- Add 9 focused regression tests: single note with semicolons,
  mixed note+hard-evidence, unknown-kind rejection, state:MERGED
  boundary, trailing semicolons, unknown-kind-like text absorption.
- 117 contracts tests pass; zero failures from this change.
…ayloads (#1126)

The boundary-aware split preserved semicolons in every atom payload,
causing regressions: commit:abc1234; produced sha=abc1234; instead of
abc1234, and ;; between atoms leaked into structured payloads.

Fix is kind-aware:
- Strip leading ; from every chunk (leftover from ;; separator artifacts)
- For non-note atoms, strip trailing ;+ from the payload (the old naive
  split consumed those as empty chunks)
- Note payloads preserve every character including trailing ; as real
  punctuation

Add 12 regression tests: trailing ; on commit/files/pr/tool/test-run/url/
decision, repeated ;; across non-note atoms, trailing ;; after multi-atom,
mid-payload ; in url, and mixed note/non-note with separators.
129 contracts tests pass (81 evidence-atom-schema + 48 satisfies-atom).
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.

[Bug]:Evidence atom parser breaks on semicolons inside note: payloads

1 participant