* chore(#3875): sweep the spent ack fragments and automate the sweep
next has been red on every push since a84f75630 (#3823) — 24 consecutive pushes
over two days — on two fully-spent emitted-drift-ack fragments nobody swept.
#3823 introduced guard-no-ack-on-next together with a 45-fragment sweep, but
computed that sweep as a static set of deletions fixed at its branch point.
#3809's fragment merged to next while #3823 was in flight, so the guard reds on
its own merge commit. The condition is evaluated dynamically at merge time and
remediated statically at branch time; on a moving branch the second can never
reliably satisfy the first.
- delete tests/emitted-drift-acks/3809-* and 3866-* (3034-* and 3172-* stay --
the #3842 open-PR hold correctly defers them)
- runGuardNext returns `sweepable`, the set the guard actually reasoned about,
plus `legacyPresent` for the legacy document, which is a fixed path rather
than a fragment basename and would otherwise be invisible to any sweeper
- new --sweep-plan mode turns the guard into a work list: plan on stdout, prose
on stderr, exit 0 so a non-empty plan does not fail the step that asked for it
- main() is injectable in BOTH lanes; a half-injected seam lets a test that
passes cwd silently read the real repository instead of its fixture
- ack-fragment-sweep.yml derives its deletion list from that plan on a timer and
opens a reviewable PR, so the sweep can no longer go stale between branch
and merge
Hardening found in review, each verified against a live reproduction:
- git rm reads its arguments as PATHSPECS with wildmatch semantics, so a
fragment named a bare-star .json name -- legal, and admitted by
listFragmentFiles since it filters only on the suffix -- expanded to every
fragment in the directory, including ones the #3842 hold withheld. Confirmed
in a scratch repo: one such file deleted all three. Closed with a literal
allowlist and a :(literal) pathspec, two independent layers.
- an apostrophe inside a heredoc nested in a command substitution is an
unterminated quote and a hard syntax error at runtime, not just under bash -n.
- an empty plan no longer reports success unconditionally: the guard is re-run
without the hold to tell "next is clean" from "everything is held", the
commonest holder being the sweep PR from the previous run, which touches
exactly the fragments it proposed to delete.
- a branch pushed by a run that died before it could open the PR wedged every
later run on a non-fast-forward push; re-pointed under a lease instead.
- a guard crash in plan mode no longer reads as "nothing to sweep".
Refs #3875
* chore(#3875): regenerate CONTEXT-INDEX.json for the glossary entry
lint:generated-sync failed on CI: gen-context-index.cjs derives
docs/CONTEXT-INDEX.json from CONTEXT.md, and the RULESET.EMITTED_ATTRIBUTION
entry added in the previous commit left it stale.
Refs #3875
* chore(#3875): regenerate the example CONTEXT-INDEX for the glossary entry
CONTEXT.md feeds TWO committed indexes, not one: docs/CONTEXT-INDEX.json via
scripts/gen-context-index.cjs, and the examples/dynamic-context-management copy
that lint-example-parser-parity holds to a fresh parse. The previous commit
regenerated only the first, so the parity check stayed red.
Refs #3875
---------
Co-authored-by: sim <sim@local>
Dynamic context management — Option-E reference example
Reference example for ADR-1671, "Dynamic context management platform."
This is a non-shipping reference example. It lives outside the build (
src/→bin/lib/), the npm packagefiles[], the installer, and the CI test suite (tests/). Nothing here is compiled into or installed with GSD. The production implementation lands in a later phase of the Dynamic Context Management epic (#1671).
What it demonstrates
The predicate fact-store → JIT selector slice of the platform: parse the
repo-root CONTEXT.md CLASS.subkey=value predicates into structured records,
drift-guard a generated index, and select the relevant predicate subset for a
task — the building block for just-in-time agent-brief assembly instead of
hand-citing a 200 KB file.
Files
context-predicates.cjs— parser + selector + deterministic index builder (self-contained).gen-context-index.cjs—--check/--writedrift-guarded generator +--select.CONTEXT-INDEX.json— sample generated output (415 predicates, 20 classes).demo.cjs— runnable usage example.
Run (from the repo root)
node examples/dynamic-context-management/demo.cjs
node examples/dynamic-context-management/gen-context-index.cjs --select PRED.k320
node examples/dynamic-context-management/gen-context-index.cjs --check
Validation
During research this slice was validated with 42 behavioral tests — predicate
forms, fenced-code / prose skipping, duplicate-id detection, the selector, a
deterministic index, and a fast-check property test. The production
implementation has since landed, with tests/context-predicates.test.cjs and
tests/context-index-sync.test.cjs as its behavioral tests under tests/,
and scripts/lint-example-parser-parity.cjs (wired into npm run lint:ci)
asserting this example and production agree.
Research also surfaced 3 latent duplicate predicate IDs in CONTEXT.md
(RULESET.WORKFLOW_MARKDOWN.FENCES, RULESET.GEMINI.TOOLS.ask_user,
RULESET.GEMINI.TEST_SENTINEL) at the time; all three have since been
resolved and the current index carries 0 duplicate ids.