* fix(#1196): wire discuss loop step for capability hooks discuss was contract-declared (gsd:loop-host marker, in POINT_ORDER and LOOP_HOST_CONTRACT) but structurally unwireable: discuss-phase.md had no `loop render-hooks` dispatch and was absent from the conformance gate's HOST_LOOP_FILES, so capabilities could never wire discuss:pre/discuss:post. - discuss-phase.md: add minimal discuss:pre (before analyze_phase) and discuss:post (after write_context) render-hooks dispatch steps that delegate consumption to a new shared reference (kept under the 32KB #2551 budget; no inline subagent dispatch token). - references/loop-hook-dispatch.md: new canonical, point-agnostic contract for consuming `loop render-hooks --raw` activeHooks (contribution/step/ gate) — single source for hook consumption across host loops. - gen-loop-host-contract.cjs: derive HOST_LOOP_FILES from STEP_WORKFLOWS and export scanWiredPoints()/getWiredLoopPoints() (throws on a missing host file) — one source of truth for the host-loop file + wired-point set. - phase6-capstone-conformance.test.cjs: consume the derived HOST_LOOP_FILES and shared scanWiredPoints (was a hand-maintained duplicate omitting discuss-phase.md + a duplicated regex). - gen-capability-registry.cjs: add validateHooksWired() gen-time guard that rejects a capability hook declared at a valid-but-unwired loop point, with a clear remediation message — failure now surfaces at gen --check/--write time instead of deep in the full conformance suite. - tests (capability-registry.test.cjs): regression + anti-pattern parity guards (every loop-host marker is in STEP_WORKFLOWS/HOST_LOOP_FILES; POINT_ORDER === flattened LOOP_HOST_CONTRACT) so no step can drift into the discuss-class gap again. - docs/INVENTORY*: register the new reference. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore(#1196): backfill changeset PR number (#1199) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -449,6 +449,58 @@ function main() {
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Derived single-source-of-truth exports ───────────────────────────────────
|
||||
|
||||
/**
|
||||
* Repo-relative paths to every host-loop workflow file, derived from STEP_WORKFLOWS.
|
||||
* This is the ONLY canonical enumeration of host-loop files — all consumers (tests,
|
||||
* registry generator, conformance gate) must derive from this rather than maintaining
|
||||
* a separate hardcoded list.
|
||||
*/
|
||||
const HOST_LOOP_FILES = STEP_WORKFLOWS.map((w) => 'gsd-core/workflows/' + w.file);
|
||||
|
||||
/**
|
||||
* Pure function: scan a text string for `loop render-hooks <point>` call sites.
|
||||
* Returns a Set of matched point strings.
|
||||
*
|
||||
* @param {string} text Content of a workflow file (or any text).
|
||||
* @returns {Set<string>}
|
||||
*/
|
||||
function scanWiredPoints(text) {
|
||||
const re = /loop render-hooks\s+([a-z:]+)/g;
|
||||
const result = new Set();
|
||||
let m;
|
||||
while ((m = re.exec(text)) !== null) {
|
||||
result.add(m[1]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read every host-loop workflow file and return the union of all wired loop points
|
||||
* (i.e. points that have a `loop render-hooks <point>` call site).
|
||||
*
|
||||
* @param {string} [repoRoot] Path to the repository root. Defaults to ROOT.
|
||||
* @returns {Set<string>}
|
||||
*/
|
||||
function getWiredLoopPoints(repoRoot) {
|
||||
const resolvedRoot = repoRoot !== undefined ? repoRoot : ROOT;
|
||||
const result = new Set();
|
||||
for (const relPath of HOST_LOOP_FILES) {
|
||||
const absPath = path.join(resolvedRoot, relPath);
|
||||
let content;
|
||||
try {
|
||||
content = fs.readFileSync(absPath, 'utf8');
|
||||
} catch (err) {
|
||||
throw new Error('getWiredLoopPoints: cannot read host-loop file ' + absPath + ': ' + err.message);
|
||||
}
|
||||
for (const point of scanWiredPoints(content)) {
|
||||
result.add(point);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ─── Exports (for tests) ─────────────────────────────────────────────────────
|
||||
|
||||
module.exports = {
|
||||
@@ -459,9 +511,12 @@ module.exports = {
|
||||
serializeContract,
|
||||
normalizeLineEndings,
|
||||
STEP_WORKFLOWS,
|
||||
HOST_LOOP_FILES,
|
||||
CANONICAL_POINTS,
|
||||
EXPECTED_POINTS_BY_STEP,
|
||||
ROLE_TO_AGENT,
|
||||
scanWiredPoints,
|
||||
getWiredLoopPoints,
|
||||
};
|
||||
|
||||
// ─── CLI entry point ──────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user