Classification
BAD CODE™ — structural test debt exposed by review of #838.
Problem
test/unit/scripts/entity-capture-type-assertion-ratchet.test.ts currently protects the occurrence-authority boundary with a literal source-substring assertion:
expect(occurrence).not.toContain("issued.subject === occurrence.subject");
Whitespace, parentheses, or reversing the equality operands can restore the forbidden semantic coupling without tripping that ratchet. The same test already imports the TypeScript compiler API, so a syntax-dependent text check is below the established structural-testing standard.
Required correction
- Parse
src/domain/api/EntityOccurrence.ts through the TypeScript AST.
- Detect equality comparisons between
issued.subject and occurrence.subject regardless of operand order, whitespace, or parenthesization.
- Keep the existing prohibitions on hidden
WeakMap authority and private comparison callbacks.
- Remove the literal source-text assertion once the semantic check exists.
Acceptance
- A regression fixture fails for
issued.subject === occurrence.subject.
- A regression fixture fails for
occurrence.subject===issued.subject.
- The current occurrence-owned authority implementation passes.
- The focused ratchet test and
npm run test:fast pass.
Related: #838.
Classification
BAD CODE™ — structural test debt exposed by review of #838.
Problem
test/unit/scripts/entity-capture-type-assertion-ratchet.test.tscurrently protects the occurrence-authority boundary with a literal source-substring assertion:Whitespace, parentheses, or reversing the equality operands can restore the forbidden semantic coupling without tripping that ratchet. The same test already imports the TypeScript compiler API, so a syntax-dependent text check is below the established structural-testing standard.
Required correction
src/domain/api/EntityOccurrence.tsthrough the TypeScript AST.issued.subjectandoccurrence.subjectregardless of operand order, whitespace, or parenthesization.WeakMapauthority and private comparison callbacks.Acceptance
issued.subject === occurrence.subject.occurrence.subject===issued.subject.npm run test:fastpass.Related: #838.