* chore(#2992): widen the when= grammar and key the section manifest per workflow Epic #1671 Phase 6.1. Two blockers stopped the fragment model reaching any file beyond execute-phase.md: the when= vocabulary was frozen at 4 atoms (3 execute-phase-specific), and the section manifest was single-workflow by construction with 'execute-phase' hardcoded into buildSectionManifestField. - widen WHEN_VOCABULARY 4 -> 14 via a coordinated ADR-1671 amendment; the grammar stays CLOSED (one atom, no operators, negation or nesting) and WHEN_PREDICATES stays a hand-written literal map, never deriving a predicate from its atom string - InvocationFacts gains flags: ReadonlySet<string> plus three computed state booleans; add the missing reverse vocabulary/predicate parity guard - key the manifest artifact per workflow; a stale flat {sections:[...]} artifact now fails shape validation instead of being misattributed - wire the field into six init entry points and parse the flags each needs An atom ships only with both a real consuming section and a fact the init seam actually computes. Six surveyed atoms are withheld because their workflows have no dedicated init entry point; an atom without a computed fact evaluates false forever and silently disables its own section. Fixes a defect found while wiring: parseNamedArgs always materializes a boolean flag key, so folding its false into the absent sentinel is required or every flag reads as present and gating is silently always-on. Also resolves ADR-1671:194 by measurement: --mvp stays unmarkable, because its interleaved sites are always-run flag resolution and a ~340 byte block that already delegates lazily. Refs #2992 * fix(#2992): treat any falsy option value as an absent flag and reject unsafe manifest read paths Findings from two orthogonal reviews (Claude /code-review + an isolated adversarial pass); both independently reproduced the first one. - MAJOR: the flags-builder treated only `undefined` as absent, but parseNamedArgs yields `null` for an absent value-flag and `false` for an absent boolean-flag, so `--granularity` read as present on every plan-phase invocation. Fixed at the root: a flag is present iff its option value is truthy. The six per-handler `|| undefined` folds are now redundant and removed, which also closes the duplicate-translation and missed-onboard-handler findings. - MAJOR: state:needs-codebase-map had zero coverage. Added unit, property and real-CLI integration tests. - MINOR: reject absolute, UNC/drive and `..`-traversing `read` paths in the manifest, degrading the whole load to null like every other shape violation. Verified: `/etc/passwd` previously reached section_manifest.read. - MINOR: corrected a stale "4 to 20" doc comment; the vocabulary is 14. Refs #2992 * test(#2992): update the generator suite for the per-workflow manifest shape The remote matrix went red with 5 unique failures, identical on linux-node22 and linux-node24, all in tests/gen-section-manifest.test.cjs. Re-keying the artifact to {workflows:{...}} left this suite asserting the old flat {sections:[...]} shape; nothing else in the tree still does. - three tests read manifest.sections.length, now undefined; retargeted at workflows.<name> with their original intent preserved (a fenced or loop-host marker still asserts NO section is produced, not merely a changed count) - the stale-manifest test wrote its fixture in the OLD shape, so it tripped shape validation and stopped exercising staleness at all. Its fixture is now valid-but-mismatched so FAIL_STALE is genuinely reached again. - added the coverage that exposed: a pre-6.1 flat artifact must report FAIL_MANIFEST_MALFORMED_SHAPE. That is the real upgrade path for an installed tree and nothing covered it. Refs #2992 * chore(#2992): backfill changeset pr number to 3013 --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -381,23 +381,33 @@ grammar, the frozen `when=` vocabulary, and fail-closed authoring rules, and
|
||||
[ADR-1671](adr/1671-dynamic-context-management-platform.md) (open questions 1 and 2) for why
|
||||
in-file markers were chosen over separate fragment files or a sidecar manifest.
|
||||
|
||||
### Section Manifest (`src/section-manifest.cts`, ADR-1671 Phase 5)
|
||||
### Section Manifest (`src/section-manifest.cts`, ADR-1671 Phases 5 and 6.1)
|
||||
|
||||
Two seams turn a workflow's `gsd:section` markers into per-invocation applicability data.
|
||||
`scripts/gen-section-manifest.cjs --write` (wired into `build` after `build:lib`, and into
|
||||
`lint:generated-sync`) scans `gsd-core/workflows/*.md` and writes the committed
|
||||
`gsd-core/workflows/section-manifest.json`: a `{id, when, read}` triple per marked section,
|
||||
where `read` is the path of the step file the section's body was extracted to. It reuses
|
||||
`gsd-core/workflows/section-manifest.json`, keyed **per workflow** —
|
||||
`{workflows: {"<name>": [{id, when, read}]}}` — where `read` is the path of the step file the
|
||||
section's body was extracted to. A workflow with no marked sections contributes **no key at
|
||||
all**: an absent key means degraded/unknown (the caller reads every section, the safe superset),
|
||||
while a key present with an empty array means "computed, nothing applies". The generator reuses
|
||||
`parseWorkflowSections` unchanged rather than re-implementing marker parsing, and fails closed
|
||||
(`--check`) on a marker naming a step file that does not exist or a step file no marker
|
||||
references.
|
||||
(`--check`) on a marker naming a step file that does not exist, a step file no marker
|
||||
references, or a committed artifact still carrying the pre-6.1 flat `{sections: [...]}` shape.
|
||||
|
||||
A separate pure evaluator, `src/section-manifest.cts` (compiled to
|
||||
`gsd-core/bin/lib/section-manifest.cjs` per ADR-457), maps one invocation's facts —
|
||||
`{waveFlag, phaseNumber, hasPriorPhases}` — to an included/excluded partition of section ids
|
||||
via `selectSections`. Per Greenspun's Tenth Rule, this is a total lookup over the frozen
|
||||
`when=` vocabulary, never a parser: it never tokenizes or interprets `when=` structure, and an
|
||||
unrecognized value fails closed rather than being silently excluded.
|
||||
`{flags, phaseNumber, hasPriorPhases}` plus the optional `needsCodebaseMap`, `phaseMvpMode` and
|
||||
`worktreesEnabled` booleans — to an included/excluded partition of section ids via
|
||||
`selectSections`. `flags` is a `ReadonlySet<string>` of flag tokens; because `parseNamedArgs`
|
||||
always materializes a boolean flag key (`false` when the token was absent, never `undefined`),
|
||||
presence is **truthiness**, and the init router folds a boolean flag's own `false` into the
|
||||
absent sentinel before the facts are built. Per Greenspun's Tenth Rule, the evaluator is a total
|
||||
lookup over the frozen 14-atom `when=` vocabulary, never a parser: `WHEN_PREDICATES` is a
|
||||
hand-written literal map that never derives a predicate from its atom string, and an
|
||||
unrecognized value fails closed rather than being silently excluded. An atom is admitted only
|
||||
when it has both a real consuming section and a fact the init seam actually computes — an atom
|
||||
without the latter would evaluate `false` forever and silently disable its own section.
|
||||
|
||||
`execute-phase.md`'s `partial-wave` and `gap-closure-artifacts` sections — previously inlined
|
||||
directly per #2930's pilot — now delegate to dedicated step files under
|
||||
|
||||
@@ -67,6 +67,54 @@ Pure Agent Skills (A alone) and pure MCP (D alone) were rejected as the foundati
|
||||
|
||||
**Amended by #2929 (Phase 2).** This ADR originally specified the contract as "priority + binary-search cutoff to a per-runtime budget". Implementing Phase 2 established that a cutoff alone **cannot express the function this platform generalizes**: `prompt-budget.applyBudget` is not a cutoff but a fixed five-step ladder in which each section carries its own shrink strategy, and only three of its eight sections are ever droppable — `PROJECT.md` is head-shrunk to N lines and plans are proportionally tail-truncated with a per-plan floor, while instructions and roadmap are never trimmed at all. A cutoff composer sorts by priority and discards the tail; it has no way to say "shrink this one", "truncate that one but never below its floor", or "these three are the only droppables, in this order". Building to the literal wording and routing `prompt-budget` through it would have silently changed review-prompt output. Shrink strategies are therefore the core abstraction, and **binary-search cutoff becomes one strategy among them** — the right one for per-runtime emission in Phases 3-4, not for this ladder. Ordering is declaration order rather than a numeric priority field. This is an elaboration of the decision's intent, not a reversal of it.
|
||||
- **Applicability grammar (added by #2930, Phase 3).** The fragment unit's `when=` attribute is deliberately a CLOSED grammar: exactly one atom from a frozen vocabulary — `always`, `flag:--wave`, `state:gap-closure-phase`, `state:has-prior-phases` — with no boolean operators, negation, or nesting, and an unknown `when=` value throws rather than being ignored. This is a Greenspun's-Tenth-Rule guard: left open-ended, `when=` acquires `&&`/`!`/precedence/runtime-capability predicates and becomes an ad-hoc, informally-specified predicate language grown one condition at a time. Widening the vocabulary requires a coordinated ADR amendment, not an organic edit. `when=` is parsed and validated in Phase 3 but not yet acted on; applicability selection is Phase 5.
|
||||
|
||||
**Amended by #2992 (Phase 6.1) — the vocabulary widens 4 → 14, and the guard is restated.**
|
||||
This is the coordinated amendment this bullet requires; it is not an organic edit. Rolling the
|
||||
fragment model past `execute-phase.md` was impossible without it: three of the original four
|
||||
atoms are execute-phase-specific, so every other LARGE/XL workflow branches on conditions the
|
||||
vocabulary could not express.
|
||||
|
||||
*The guard is composition, not cardinality.* This bullet's own rationale names the hazard
|
||||
precisely — `when=` acquiring `&&`/`!`/precedence and becoming an ad-hoc predicate language. A
|
||||
14-entry list with no operators is not a language; a 4-entry list **with** `&&` would be. Adding
|
||||
atoms therefore does not weaken the guard, and the following invariants are unchanged and
|
||||
binding: exactly one atom per marker, no boolean operators, no negation, no nesting, and an
|
||||
unrecognized `when=` still throws rather than being silently excluded. `WHEN_PREDICATES` remains
|
||||
a **hand-written literal map** — deriving a predicate from its atom string (`atom.slice(5)`) is
|
||||
tokenization, and a parser relocated into a build loop is still a parser. The redundancy between
|
||||
an atom's name and its literal token is deliberate; a behavioral test derived from the vocabulary
|
||||
catches a desync, because a desync silently excludes a section rather than failing loudly.
|
||||
|
||||
*Two independent gates govern admission.* An atom ships only when it has **both** (1) a named
|
||||
consuming section of at least 400 bytes, established by survey, and (2) a fact the init seam
|
||||
demonstrably computes at a real entry point. Gate (2) was learned during implementation and is
|
||||
the more important of the two: an atom whose fact is never computed evaluates `false` forever, so
|
||||
a section marked with it is silently never included — strictly worse than not shipping the atom,
|
||||
because the marker looks like working gating. The same failure mode appeared twice more during
|
||||
this phase and is recorded so it is not rediscovered: `parseNamedArgs` always materializes a
|
||||
boolean flag key (`false` when absent, never `undefined`), so "present in the options record" is
|
||||
**not** token presence; and four workflow handlers passed no options at all. Both were fixed by
|
||||
wiring, not by relaxing the gate.
|
||||
|
||||
**Shipped (14).** `always`, `flag:--wave`, `state:gap-closure-phase`, `state:has-prior-phases`
|
||||
(pre-existing), plus `flag:--auto`, `flag:--discuss`, `flag:--forensic`, `flag:--full`,
|
||||
`flag:--research`, `flag:--reset-phase-numbers`, `flag:--validate`, `state:needs-codebase-map`,
|
||||
`state:phase-mvp-mode`, `state:worktrees-enabled`.
|
||||
|
||||
**Withheld (6), surveyed and justified but not yet computable.** `flag:--verify-only` and
|
||||
`state:is-monorepo` (docs-update), `flag:--converge` (autonomous), `flag:--fix` and
|
||||
`state:fallow-enabled` (code-review), `state:git-create-tag` (complete-milestone). Each fails
|
||||
gate (2): `docs-update` initializes through `cmdDocsInit` in `docs.cts`, and the other three run
|
||||
through the shared generic `init.phase-op` / `init.milestone-op` / `init.manager` entry points,
|
||||
each invoked by 20+ workflows — binding a workflow name into those would misattribute one
|
||||
workflow's sections to every other caller. They land with the entry-point work in the LARGE/XL
|
||||
rollout phase. The survey is recorded so it is not repeated.
|
||||
|
||||
**Permanently ineligible condition classes** (found by survey, not admissible as atoms at any
|
||||
future point without a different mechanism): runtime tool/capability availability (Task tool,
|
||||
Playwright-MCP session), live git repository state, Capability-Registry/hook-resolved conditions,
|
||||
interactive answers given mid-run, and UAT/verification runtime results. None is knowable from
|
||||
parsed CLI arguments or `.planning/` state at init time.
|
||||
- **Budget unit:** bytes for emission caps (matches `lfByteCount`, deterministic, offline-safe); a token estimate for run-time selection.
|
||||
|
||||
**Corrected by #2931 (Phase 4) — the Windsurf cap was never load-bearing.** The Context
|
||||
@@ -193,6 +241,8 @@ Prototype scope notes: the parser is intentionally self-contained for the exampl
|
||||
|
||||
**Resolved by #2930 (Phase 3) — fragment unit: in-file `<!-- gsd:section id= when= -->` markers.** Question 1 asked separate files vs in-file section markers. Confirmed with the maintainer: separate files are eliminated by this phase's own acceptance criterion — "emitted output byte-identical-or-smaller" — because splitting a workflow into files changes the emitted tree's *shape*, which is neither identical nor smaller, it is different; it also multiplies INVENTORY rows and `@`-ref contract surface for no Phase-3 benefit. A sidecar fragment manifest keyed on heading anchors was also rejected: zero source growth, but it creates a second surface that drifts from the workflow — the exact multi-surface edit pain the epic exists to remove (`DEFECT.GENERATIVE-FIX`), and directly against the epic's "one fragment, not 4 surfaces" thesis. The shipped answer is in-file markers, stripped at emit so the installed artifact carries no build metadata and shrinks; markers are self-anchoring (no line-number keying — Open question 4 already rejected that for the predicate index, and the same reasoning applies here), and the existing `<!-- gsd:loop-host … -->` block at `plan-phase.md:1` is in-repo precedent for the form. Production landed under `src/workflow-fragments.cts` → `gsd-core/bin/lib/workflow-fragments.cjs` (ADR-457 build-at-publish), piloted on `execute-phase.md`. **The pilot was retargeted from `plan-phase.md` mid-phase, and the reason is itself the most important finding here.** The branches the epic names as motivating (`--prd`, `--ingest`, `--mvp`, `--reviews`) all live in `plan-phase.md` — but `plan-phase.md` sits only 36 B under an independent, pre-existing size gate (`tests/phase6-capstone-conformance.test.cjs`'s `PRE_PHASE6`, an ADR-857 Phase-6 completion property that this ADR's own Blast-radius analysis did not enumerate against, catching only the XL cap). It cannot absorb even the smallest marker overhead, so **it could not be fragmentized at all under this phase's grammar**, independent of any shape limitation. The pilot instead proves the mechanism on state- and flag-gated `<step>` blocks in `execute-phase.md` (`partial-wave`/`flag:--wave`, `gap-closure-artifacts`/`state:gap-closure-phase`, `regression-gate`/`state:has-prior-phases`), which has 728 B of real headroom under its own `PRE_PHASE6` gate. This is direct evidence for the epic's premise that fragmentization pays off, but it also means **Phase 4 (moving size caps from source bytes to emitted bytes) may need to land before `plan-phase.md` itself can be fragmentized.** Separately, and independent of the size-gate finding: the marker grammar addresses SECTION-shaped branches only — a whole-line, non-nesting comment pair around a contiguous block — and `--mvp`'s content in `plan-phase.md` is INTERLEAVED rather than sectioned (`MVP_MODE` resolution shares a bash block with `--tdd`/`--no-tracer`/`--no-reversibility-gates` at `plan-phase.md:125-158`, and is inline `${MVP_MODE === 'true' ? ... }` template interpolation at `:794-803`), so `--mvp` would remain unmarkable by this grammar even if the size gate allowed it. Phase 6 must either accept that gap or introduce a finer-grained (sub-line) mechanism for interleaved branches.
|
||||
|
||||
**Resolved by #2992 (Phase 6.1) — the gap is ACCEPTED, and it is closed by measurement rather than by mechanism.** Phase 6 initially chose to build the sub-line mechanism. Measuring the two sites first falsified the premise that choice rested on. `plan-phase.md:125-158` is not optional content at all: it is `MVP_MODE` **resolution** (alongside `--tdd` / `--no-tracer` / `--no-reversibility-gates`), which must execute on every invocation in order to resolve the flags — gating it would break the workflow rather than trim it. `plan-phase.md:794-803` is genuinely conditional, but it is roughly **340 bytes** and is *already* a lazy pointer: its body instructs the planner to read `references/planner-mvp-mode.md`, so the heavy content is deferred by the existing `@`-reference model, not carried inline. A sub-line grammar would therefore buy about 340 bytes at one site while the other site must never be gated at all — and it would reintroduce exactly the Greenspun's-Tenth-Rule hazard the applicability-grammar bullet above exists to prevent, in exchange for that. The gap this ADR identified is real as a *shape* observation and inconsequential as a *value* one. `--mvp` remains unmarkable by the section grammar, deliberately and permanently; the section-shaped branches of `plan-phase.md` are still fragmentized normally. Should an interleaved branch later carry genuinely large, genuinely skippable content, that measurement — not this precedent — is what should reopen the question.
|
||||
|
||||
**Resolved by #2930 (Phase 3) — build-time emission is the primary surface; per-workflow cutover, no double-write.** Question 2 asked build-time emission vs run-time assembly as the primary surface during migration, and whether that requires a double-write period. Because markers are stripped at emit, an unmarked workflow parses to exactly one implicit fragment and composes back byte-identical by construction — that structural guarantee is what makes a per-workflow cutover safe file-by-file, with no double-write period and no flag day: a workflow can gain markers on its own schedule without touching any other workflow's emission path. Phase 5's run-time selection is planned to consume a build-derived manifest, not markers read at run time, keeping the run-time surface decoupled from the authoring surface.
|
||||
|
||||
## Related
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
> questions 1 and 2).
|
||||
|
||||
Workflow authors can mark one or more sections of a `gsd-core/workflows/*.md` file
|
||||
so that `bin/install.js`'s emission path can compose them per runtime. Today this
|
||||
is an authoring model with no run-time effect yet — see
|
||||
[Not acted on yet](#not-acted-on-yet) below.
|
||||
so that `bin/install.js`'s emission path can compose them per runtime, and so that
|
||||
a separate init-time seam can select which sections apply to one concrete
|
||||
invocation — see [The manifest artifact and per-workflow
|
||||
keying](#the-manifest-artifact-and-per-workflow-keying) below.
|
||||
|
||||
## Marker syntax
|
||||
|
||||
@@ -45,7 +46,8 @@ gap fragment and composes back byte-identical to its source.
|
||||
|
||||
## The frozen `when=` vocabulary
|
||||
|
||||
`when=` takes exactly one of:
|
||||
`when=` takes exactly one of 14 atoms (widened from 4 via the ADR-1671
|
||||
amendment for #2992, epic #1671 Phase 6.1):
|
||||
|
||||
| Value | Meaning |
|
||||
|---|---|
|
||||
@@ -53,12 +55,49 @@ gap fragment and composes back byte-identical to its source.
|
||||
| `flag:--wave` | Applicable when the workflow runs with `--wave`. |
|
||||
| `state:gap-closure-phase` | Applicable when the phase number is a gap-closure phase (has a decimal, e.g. `4.1`). |
|
||||
| `state:has-prior-phases` | Applicable when prior phases (and their `VERIFICATION.md` files) exist. |
|
||||
| `flag:--auto` | Applicable when the workflow runs with `--auto`. |
|
||||
| `flag:--discuss` | Applicable when the workflow runs with `--discuss`. |
|
||||
| `flag:--forensic` | Applicable when the workflow runs with `--forensic`. |
|
||||
| `flag:--full` | Applicable when the workflow runs with `--full`. |
|
||||
| `flag:--research` | Applicable when the workflow runs with `--research`. |
|
||||
| `flag:--reset-phase-numbers` | Applicable when the workflow runs with `--reset-phase-numbers`. |
|
||||
| `flag:--validate` | Applicable when the workflow runs with `--validate`. |
|
||||
| `state:needs-codebase-map` | Applicable when a codebase map is needed (init-computed). |
|
||||
| `state:phase-mvp-mode` | Applicable when the current phase's `ROADMAP.md` entry declares `**Mode:** mvp`. |
|
||||
| `state:worktrees-enabled` | Applicable when `.planning/config.json`'s `workflow.use_worktrees` is enabled. |
|
||||
|
||||
This list is **closed by design** (Greenspun's Tenth Rule): left open-ended,
|
||||
`when=` would acquire boolean operators, negation, precedence, and
|
||||
runtime/capability predicates one edit at a time, becoming an ad-hoc,
|
||||
informally-specified applicability language. Widening the vocabulary is a
|
||||
coordinated ADR amendment to ADR-1671, never an organic edit to the parser.
|
||||
coordinated ADR amendment to ADR-1671, never an organic edit to the parser —
|
||||
`when=` remains exactly one atom per marker: no operators, no negation, no
|
||||
nesting, regardless of how many atoms the frozen list holds. An unknown value
|
||||
still throws (see [Fails closed](#fails-closed)).
|
||||
|
||||
An atom only ships once it clears **two independent admission gates**, both
|
||||
required:
|
||||
|
||||
1. **A named consuming section.** Some workflow's marked section actually
|
||||
needs the condition — an atom with no section that uses it is dead
|
||||
vocabulary, and dead vocabulary is how a closed list rots into an open
|
||||
one.
|
||||
2. **A fact the init seam can actually compute.** Only a workflow with a
|
||||
dedicated `cmdInit*` entry point (see [The manifest
|
||||
artifact](#the-manifest-artifact-and-per-workflow-keying) below) can carry
|
||||
a manifest, and only a condition that entry point can resolve at init time
|
||||
— from parsed CLI options or from `.planning/` state — may become an atom.
|
||||
An atom without a computable fact would always evaluate `false`, so a
|
||||
section marked with it would silently never include: the exact
|
||||
silent-wrong-answer class this gate exists to prevent.
|
||||
|
||||
Six further atoms (`flag:--converge`, `flag:--fix`, `flag:--verify-only`,
|
||||
`state:fallow-enabled`, `state:git-create-tag`, `state:is-monorepo`) satisfy
|
||||
gate 1 but not yet gate 2 — their workflows (`autonomous`, `code-review`,
|
||||
`complete-milestone`, `docs-update`) route through shared generic init entry
|
||||
points invoked by 20+ other workflows, so a dedicated `cmdInit*` seam does
|
||||
not yet exist to compute their facts. They are withheld pending that seam,
|
||||
not rejected.
|
||||
|
||||
## Fails closed
|
||||
|
||||
@@ -119,13 +158,61 @@ The pre-existing `<!-- gsd:loop-host ... -->` marker family (consumed by
|
||||
`scripts/gen-loop-host-contract.cjs`) is a different, already-established
|
||||
marker and is never treated as a `gsd:section` marker.
|
||||
|
||||
## Not acted on yet
|
||||
## The manifest artifact and per-workflow keying
|
||||
|
||||
`when=` is parsed and validated today, but applicability selection — actually
|
||||
choosing which sections apply to a given invocation — is not implemented in
|
||||
this phase. Every fragment composes into the output regardless of its `when=`
|
||||
value; only the marker lines are stripped. Run-time selection is planned for
|
||||
a later phase of ADR-1671's epic.
|
||||
`bin/install.js`'s emission path always composes every fragment into the
|
||||
output regardless of its `when=` value — marker lines are stripped, nothing
|
||||
else changes there. Applicability selection is a separate, later seam:
|
||||
`scripts/gen-section-manifest.cjs --write` scans `gsd-core/workflows/*.md` for
|
||||
`gsd:section` markers and generates a committed artifact,
|
||||
`gsd-core/workflows/section-manifest.json`, shaped as
|
||||
`{"workflows": {"<workflow-name>": [{"id", "when", "read"}, ...], ...}}`,
|
||||
where `<workflow-name>` is a source `.md` file's basename without extension
|
||||
and `read` is the POSIX-normalized, repo-root-relative path of the step file
|
||||
the section body was extracted to. This is a per-workflow superset of the
|
||||
pre-#2992 shape, which was a single flat `{"sections": [...]}` array with no
|
||||
workflow key — that shape is now rejected outright rather than mis-parsed, so
|
||||
a stale committed artifact can never be silently attributed to whichever
|
||||
workflow asks first.
|
||||
|
||||
A workflow key's **presence vs. absence is meaningful, not cosmetic**:
|
||||
|
||||
- The key is **absent** when the workflow has zero marked sections. A caller
|
||||
for that workflow must treat this as degraded/unknown (`null`) — safe
|
||||
superset, read everything.
|
||||
- The key is **present with an empty array** when the workflow's sections
|
||||
were evaluated and none applied to this invocation — genuinely nothing to
|
||||
read, not "unknown."
|
||||
|
||||
Collapsing these two states inverts behavior on the degraded path: `null`
|
||||
means "I don't know, so include everything"; `[]` means "I computed this,
|
||||
and the answer is nothing."
|
||||
|
||||
At init time, a separate pure evaluator, `src/section-manifest.cts`
|
||||
(`selectSections`), partitions a workflow's manifest sections into
|
||||
`included`/`excluded` id lists against one invocation's
|
||||
`InvocationFacts` — `{flags, phaseNumber, hasPriorPhases, needsCodebaseMap?,
|
||||
phaseMvpMode?, worktreesEnabled?}`. Only a workflow with a **dedicated
|
||||
`cmdInit*` entry point** in `src/init.cts` can have this evaluation run for
|
||||
it, because only that entry point can assemble `InvocationFacts` from its own
|
||||
parsed CLI options and `.planning/` state reads — this is admission gate 2
|
||||
from [The frozen `when=` vocabulary](#the-frozen-when-vocabulary) above,
|
||||
applied per-workflow rather than per-atom. Six entry points are wired today:
|
||||
`execute-phase`, `plan-phase`, `new-project`, `new-milestone`, `quick`, and
|
||||
`progress`.
|
||||
|
||||
`InvocationFacts.flags` is a `ReadonlySet<string>` of the literal `--<name>`
|
||||
tokens seen on the invocation, and **membership is token-presence, not
|
||||
value-truthiness**. This matters because `parseNamedArgs`'s `booleanFlags`
|
||||
always materializes the key in its result object — `true` when the token was
|
||||
seen, `false` otherwise, never `undefined`. A caller that passed a
|
||||
boolean-flag's own `false` straight through as an "option value" would add it
|
||||
to `flags` anyway (any non-`undefined` value counts as present for a
|
||||
*value* flag), making that `flag:` atom permanently true regardless of the
|
||||
actual command line — the fix is that every boolean-flag call site folds its
|
||||
own `false` into `undefined` (`namedArgs['wave'] || undefined`) before
|
||||
handing options to the facts builder, so `flags` only ever contains tokens
|
||||
that were actually seen.
|
||||
|
||||
## Piloted on one workflow so far
|
||||
|
||||
@@ -173,3 +260,9 @@ for how both limits get addressed.
|
||||
- `src/workflow-fragments.cts` — the compiled parser/composer source.
|
||||
- `src/context-composer.cts` — the shared budget-composition seam consumed by
|
||||
`composeWorkflow`.
|
||||
- `src/section-manifest.cts` — the pure `when=` evaluator (`selectSections`,
|
||||
`InvocationFacts`) consumed by the init seam.
|
||||
- `scripts/gen-section-manifest.cjs` — generates the committed
|
||||
`gsd-core/workflows/section-manifest.json` artifact from markers.
|
||||
- `src/init.cts` — `buildSectionManifestField` and the six wired
|
||||
`cmdInit*` entry points.
|
||||
|
||||
Reference in New Issue
Block a user