fix(rpi): skip batch-consumed entries in next-work materialize (ag-mjlg #batch-consumed-skip)#652
Merged
Merged
Conversation
…lg #batch-consumed-skip) ag-9jle.3's `ao next-work materialize` checked only the per-item NextWorkItem.Consumed flag, but the real next-work.jsonl records consumption at the BATCH level (NextWorkEntry.Consumed / consumed_by, set after the items[] array). Every historically-consumed entry therefore looked fresh: a dry-run against the live queue planned 44 beads when only 16 items are genuinely available — ~28 stale duplicates for work done months ago (soc-9xn0 AOP-CLAIM audit, practice-backfill passes 2-12, ...). Gate enumerateMaterializeCandidates on entry-level consumption via a new isEntryConsumed() helper that mirrors the entry half of rpi.IsFullyConsumed. Add TestNextWorkMaterialize_SkipsBatchConsumedEntry exercising the real queue shape (entry.Consumed=true, item-level flag unset) — it fails without the gate (creates 1 stale bead) and passes with it. Verified: real-queue dry-run drops 44 -> 16; full materialize suite green. Closes-scenario: ag-mjlg#batch-consumed-skip Bounded-context: BC5-Runtime Evidence: cli/cmd/ao/next_work_materialize_test.go
…ze-batch-consumed
…ze-batch-consumed
boshu2
added a commit
that referenced
this pull request
Jun 6, 2026
…pe (ag-jwtx #test-standard-names-real-shape-requirement) (#776) ## What Encodes a test standard from **ag-jwtx**: skip/dedup/consumed/idempotency/regression **guard tests must build fixtures from the real persisted data shape** — round-trip a real sample (production writer → reader) or assert against a checked-in real example — never a hand-built in-memory constructor that sets a marker at a granularity the on-disk format never emits. ## Why `ag-mjlg` (PR #652) shipped a next-work materialize over-creation bug (44 vs 16) green because `TestNextWorkMaterialize_SkipsConsumed` set `consumed` at the **per-item** level while real `next-work.jsonl` marks it at the **batch** level. The guard exercised a shape production never produces → false green. This converts that one-off into a durable standard + a pre-mortem flag (catch→encode→never-repeat). ## Changes (docs/standards only) - `skills/standards/references/test-pyramid.md` — new **Fixture Fidelity** section (the standard + how-to-comply + the pre-mortem flag). - `skills/standards/references/go.md` + `.claude/rules/go.md` — Test-Conventions bullet (kept in parity). - `skills/pre-mortem/references/mandatory-checks.md` — two flags added to the **Test Pyramid Coverage Check (Mandatory)** table. ## Verification - `markdownlint --config .markdownlint.json` on all four files: clean. - `scripts/generate-registry.sh --check`: registry up to date (no new reference files; existing files edited). - Docs-only; no code paths touched. ## Scenario > Given the AI-native test-shape standard doc, when an agent writes a skip/dedup/consumed guard test, then the standard requires the fixture to come from a round-tripped real persisted sample, and a pre-mortem/checklist item flags item-level-only fixtures for batch-level state. Closes-scenario: ag-jwtx#test-standard-names-real-shape-requirement Bounded-context: BC1-Corpus Evidence: skills/standards/references/test-pyramid.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ag-9jle.3shippedao next-work materializewith an idempotency gap.isMaterializable()checked only the per-itemNextWorkItem.Consumedflag, but the real.agents/rpi/next-work.jsonlrecords consumption at the batch level (NextWorkEntry.Consumed/consumed_by, set after theitems[]array). Every historically-consumed entry therefore looked fresh.Impact: a dry-run against the live queue planned 44 beads when only 16 items are genuinely available — ~28 stale duplicates for work done months ago (the
soc-9xn0AOP-CLAIM audit, practice-backfill passes 2–12, etc.). Runningao next-work materializeas-is would have flooded the tracker.Fix
enumerateMaterializeCandidateson entry-level consumption via a newisEntryConsumed()helper that mirrors the entry half of the existingrpi.IsFullyConsumed.isMaterializablechecks remain as a second gate.Why the original test missed it
TestNextWorkMaterialize_SkipsConsumedAndHeldsetconsumedat the item level — a shape the real queue never uses. Classic test-shape mismatch giving false confidence.First failing test (regression contract)
TestNextWorkMaterialize_SkipsBatchConsumedEntry— fails without the gate (creates 1 stale bead), passes with it. Proven by reverting the gate and re-running.Evidence
go build ./...,go vet ./cmd/ao/, full materialize suite (6 tests) all green.Closes-scenario: ag-mjlg#batch-consumed-skip
Bounded-context: BC5-Runtime
Evidence: cli/cmd/ao/next_work_materialize_test.go