Imported from eshu-hq/eshu (
go/internal/replay/parserfixture/AGENTS.md). Install upstream withnpx skills add eshu-hq/eshu --skill parserfixture. Copyright stays with the author.
replay/parserfixture — agent scope
Owned surface
go/internal/replay/parserfixture/— the parser-fact record/replay flavor.
Key invariants
- Record at the REAL seam. The emitter MUST build envelopes via
collector.ParserFileFactEnvelope(the exported entry over the Git collector'sfileFactEnvelope), running the realparser.Engine. NEVER re-implement envelope construction or provenance population here — a re-implementation would let production drift from the fixture undetected. - Provenance is first-class.
SourceURIis a REQUIRED fixture fact field;LoadFile/ParseAndValidateMUST reject a fixture that drops it. A record→replay round-trip MUST reproduceSourceRef.SourceURI,SourceRef.SourceRecordID, andSourceRef.SourceSystemexactly. The provenance-regression test MUST stay failing-capable: prove it by breaking the production assertion path (e.g. blankingSourceURIinsource.go) and seeing the test go red, then revert. Do not weaken the assertion to make a red test pass. - Canonical determinism.
RecordMUST be byte-identical on re-record of the same tree. It usesreplay.Canonicalizewith the parser payload subtree marked opaque so parser output is preserved verbatim while object keys sort and generation_id derives. The emitter stampsreplay.DerivedGenerationID(scopeID)so the live generation_id already equals its canonical form (live == replayed). SourceMUST implementreplay.Source(which embedscollector.Source) and emit oneCollectedGeneration, then returnok=falseto signal exhaustion.- Portable identities only in any COMMITTED fixture. The
filepayload embeds the parser output, which carries an absolutepath, andsource_uriis absolute. A committed fixture MUST be recorded withRecordOptions.RepoRootso the repo root is tokenized to{{REPO_ROOT}}(portable.go), and replayed withNewSourceRehydrated/LoadFileRehydrated.TestCommittedParserFixturesAreCurrentasserts no committed fixture leaks an absolute checkout path; do not weaken it. A temp-dir round-trip recording (noRepoRoot) keeps absolute paths and is not committed. - Ledger lockstep. Every parser in
specs/parser-backing-ledger.v1.yamlMUST have a committed fixture undertestdata/fixtures/and a case incommitted_fixtures_test.go;TestLedgerCasesMatchSpecenforces this so C-1 parser coverage cannot silently drop below 100%. Regenerate fixtures with-update-fixturesand review the diff — never hand-edit a fixture. - Language-scoreboard fixtures. A C-12 fixture may map an exact
parser:<language>row fromspecs/language-feature-parity-ledger.v1.yamlwithout adding that parser tospecs/parser-backing-ledger.v1.yaml. Keep those cases inlanguageFixtureCases; they satisfy the visibility-only language scoreboard and MUST NOT expand the blocking parser-backing-ledger denominator. - Fixture format version is
"1". Increment with a migration note for breaking changes; do not silently change the shape.
Skill routing
golang-engineeringfor any Go change to this package.eshu-golden-corpus-rigorif a committed parser-fixture corpus is added or a gate begins asserting against it.eshu-diagnostic-rigorif you add telemetry or measure replay throughput.
Do not
- Add network calls or SDK imports to this package.
- Re-implement envelope/provenance construction instead of calling the collector seam.
- Allow
LoadFileto succeed whensource_urior other required fields are missing. - Couple this package to the R-5 offline tier before R-5 is on
main; expose theSource/NewSource/NewSourceRehydratedseam and let R-5 adapt to it.