Files
msd-core/examples/dynamic-context-management
0xdhx 664bab3b48 docs(#2665): the scrub-set and guard-target seams understated their own mechanism
Both predicates were written in round 3 and not updated when round 4 widened
what they describe, so the catalog that exists to stop a future omission had
two of its own.

CONFIG.LOCATION.SEAM.scrub-set said "four sources" and listed four. There are
five rungs: the two descriptor rungs each additionally walk skillsHome.env (the
maintainer's round-4 Minor 3), and the fifth is WRITE_ESCAPE_PERMISSION_ENV_KEYS,
which is a permission rather than a location and so is reachable by no other rung.

LIVE-CONFIG.GUARD.SEAM.non-root-targets said "the two live write surfaces" and
named a single config.toml via resolveKimiHooksTomlDir. Since #2755 landed
KIMI_CODE_HOOKS_TOML_DESCRIPTOR there are three, and the guard derives them by
iterating NON_REGISTRY_CONFIG_HOME_DESCRIPTORS rather than calling a named
resolver. Both bounds are stated rather than left open: skills bases are a
deliberate non-target (the config-root layout misfires beneath them), and a
further descriptor is only free if it owns the same NON_REGISTRY_OWNED_FILE —
the residual the guard already names at its own definition.

LIVE-CONFIG.GUARD.SEAM.scope's "gsd--prefixed" read as a two-hyphen prefix; the
selector is startsWith(GSD_ARTIFACT_PREFIX) where that constant is 'gsd-'.

CONFIG.LOCATION.SEAM.kimi-two-homes was checked and is NOT stale: #2755 made
Kimi Code a separate runtime, so Kimi CLI still declares exactly two.

Both CONTEXT-INDEX mirrors regenerated; predicate ids unchanged (425), only
their descriptions move.
2026-08-08 05:50:49 -05:00
..

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 package files[], 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 / --write drift-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.