@webpieces/agent-workflow-rules 0.4.1027 → 0.4.1029

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../../packages/tooling/agent-workflow-rules/src/core/runner.ts"],"names":[],"mappings":";;AAgEA,4CAEC;AAKD,4CAEC;AAkBD,kBAOC;AAqFD,0BAEC;AAmBD,0BA2CC;;AAvPD,0DAAiG;AACjG,mDAA6B;AAE7B,0DAYiC;AAEjC,0DAA0E;AAC1E,0DAA4D;AAC5D,iDAAkD;AAClD,0DAA+E;AAC/E,0DAA2E;AAC3E,0DAAkF;AAClF,iEAAgE;AAChE,mDAAqD;AACrD,6CAAoD;AACpD,+DAA0D;AAC1D,2DAA4D;AAC5D,2DAAmF;AACnF,iDAAsJ;AACtJ,iEAA6D;AAC7D,0DAAmF;AACnF,iEAAgE;AAChE,sCAA0D;AAC1D,0DAAyD;AAEzD,0DAA8G;AAC9G,0DAA2F;AAC3F,2CAAsE;AACtE,uCAAkF;AAClF,mDAA4D;AAC5D,0DAAoK;AAEpK,8DAA0D;AAE1D,mGAAmG;AACnG,oGAAoG;AACpG,oGAAoG;AACpG,2BAA2B;AAC3B,oGAAoG;AACpG,2FAA2F;AAC3F,gGAAgG;AAChG,yFAAyF;AACzF,mKAAmK;AACnK,SAAS,YAAY,CAAC,KAAsB,EAAE,IAAc,EAAE,QAA0B;IACpF,IAAI,IAAI,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAO,EAAW,EAAE,CAAC,IAAA,0BAAW,EAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IACrG,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAO,EAAW,EAAE,CAAC,CAAC,IAAA,0BAAW,EAAC,CA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, runFileRules, runBashRules } from '@webpieces/hook-runtime';\nimport * as path from 'path';\n\nimport {\n loadAndValidate,\n LoadedConfig,\n ConfigRepairAccess,\n RulePackRegistry,\n WebpiecesRulesConfig,\n isHookGuard,\n HomeConfigService,\n RepoRootFinder,\n seedEntryForRule,\n CONFIG_FILENAME,\n renderRuleFailForAi,\n} from '@webpieces/rules-config';\n\nimport { buildContexts, buildBashContext } from '@webpieces/hook-runtime';\nimport { DeleteScopedRules } from '@webpieces/hook-runtime';\nimport { VersionSyncGuard } from './version-sync';\nimport { EffectiveTree, EffectiveTreeResolver } from '@webpieces/hook-runtime';\nimport { GovernedPath, TargetTreeResolver } from '@webpieces/hook-runtime';\nimport { bashGovernedPath, filterByExcludedPaths } from '@webpieces/hook-runtime';\nimport { ExcludedPathEscapeHint } from './excluded-path-escape';\nimport { gitFromSubdirBlock } from './force-to-root';\nimport { loadKeylessBashRules } from './load-rules';\nimport { WorkflowHookRules } from './workflow-hook-rules';\nimport { missingDirectoryBlock } from './missing-directory';\nimport { branchStateHangTimeout, maybeRefreshMainSync } from './main-sync-timeout';\nimport { logGuardDecision, logL1Decision, GuardDecision, branchForLog, MatrixRef, Verdict, MATRIX_L0_ALLOW, MATRIX_L2_UNROWED } from './decision-log';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { formatReport, READ_SUBJECT, BASH_SUBJECT } from '@webpieces/hook-runtime';\nimport { ReadOnlyInspectionScan } from './read-only-inspection';\nimport { L0_CURE_ALLOW_JS, isAllowed } from '../bin/shim';\nimport { isRootManifest } from '@webpieces/hook-runtime';\nimport { AiType } from '@webpieces/hook-runtime';\nimport { L0_FAULT_CONFIG_MISSING, L0_FAULT_CONFIG_OUT_OF_SYNC, L0_FAULT_NONE } from '@webpieces/rules-config';\nimport { CONFIG_MISSING_REPORT, CONFIG_OUT_OF_SYNC_HEADER } from '@webpieces/rules-config';\nimport { writeGuardMatrixDoc, guardMatrixPointer } from './l0-matrix';\nimport { L1Classification, firstMatchingL1Row, L1_PRESTAGE_ROW } from './l1-rows';\nimport { withLocationMatrixPointer } from './l1-matrix-doc';\nimport { ToolKind, NormalizedToolInput, BlockedResult, HookMode, Rule, Violation, RuleGroup, EditContext, FileContext, BashContext } from '@webpieces/hook-runtime';\nimport { RuleFailError } from '@webpieces/rules-config';\nimport { InformAiError } from '@webpieces/tooling-common';\n\n// Restrict loaded rules to the category this hook invocation runs. The two split hooks each pass a\n// disjoint category ('rules' = code-style, 'guards' = the hookGuards section); 'all' runs both (the\n// openclaw plugin adapter, a single before_tool_call hook). isHookGuard is the shared classifier in\n// @webpieces/rules-config.\n// isHookGuard is asked about the rule's CONFIG KEY, never its name. Since the collapse those differ\n// for every class behind a policy key — `feature-branch-guard` is a rule NAME whose key is\n// `branch-state-guard` — and asking about the name would classify all eight collapsed guards as\n// code-style rules, i.e. run them in the wrong hook and never in the guards hook at all.\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nfunction filterByMode(rules: readonly Rule[], mode: HookMode, registry: RulePackRegistry): readonly Rule[] {\n if (mode === 'all') return rules;\n if (mode === 'guards') return rules.filter((r: Rule): boolean => isHookGuard(r.configKey, registry));\n return rules.filter((r: Rule): boolean => !isHookGuard(r.configKey, registry));\n}\n\n// The cwd a command actually runs from, after its own leading `cd`/`pushd` run. Thin delegate kept\n// for the callers (and specs) that only need the directory; the full tree classification — primary\n// clone vs linked worktree vs nested clone vs outside any repo — is EffectiveTreeResolver.resolve().\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nexport function effectiveBashCwd(command: string, cwd: string): string {\n return new EffectiveTreeResolver().effectiveCwd(command, cwd);\n}\n\n// A git or gh invocation anywhere in the command (start, or after a ;/&&/|| separator or pipe).\nconst GIT_OR_GH_RE = /(?:^|[;&|]\\s*)(?:git|gh)\\b/;\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nexport function isGitOrGhCommand(command: string): boolean {\n return GIT_OR_GH_RE.test(command);\n}\n\n// Fault C (webpieces.config.json missing) — the deny text lives in ./l0-matrix beside the rest of the\n// L0 fault table, so the message and the allowlist can never prescribe different cures. `cwd` is used\n// only to drop the matrix doc where the AI can read it (the config root does not exist yet here).\n//\n// THE ALLOWLIST ESCAPE IS THE CALLER'S (moved out 2026-09-01): behind an optional `command` it could\n// not see the harness, so the gated half of the list was unreachable under C while\n// CONFIG_MISSING_REPORT promised it. See l0FaultAllows. This has one job now: build the block.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction configMissingBlock(cwd: string): BlockedResult {\n const root = new RepoRootFinder().resolveRepoRoot(cwd);\n // Stamped with its L0 letter so the block is greppable as fault C wherever it is recorded — the\n // adapter carries it to the audit line rather than re-deriving it from the report text.\n return new BlockedResult(CONFIG_MISSING_REPORT + guardMatrixPointer(writeGuardMatrixDoc(root)), L0_FAULT_CONFIG_MISSING);\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nexport function run(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n cwd: string,\n mode: HookMode = 'all',\n): BlockedResult | null {\n return runInternal(toolKind, input, cwd, mode);\n}\n\n// The pre-config pass: an edit whose every path — BOTH sides of a Move — is a repair file, a root\n// manifest or the home config. Checking the source is what stops a rename of ordinary code ONTO a\n// recovery file from deleting that code with nothing judging it (#1448).\n// webpieces-disable no-function-outside-class -- sibling of runInternal in this module-scope runner\nfunction isPreConfigRecoveryEdit(toolKind: ToolKind, input: NormalizedToolInput, cwd: string): boolean {\n if (toolKind === 'Delete') return false;\n const root = new RepoRootFinder().resolveRepoRoot(cwd);\n return [input.filePath, input.sourcePath].every(\n (target: string): boolean =>\n new ConfigRepairAccess().isRepairFile(root, target) ||\n isRootManifest(target) ||\n new HomeConfigService().isHomeConfigPath(target),\n );\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nfunction runInternal(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n cwd: string,\n mode: HookMode,\n): BlockedResult | null {\n if (isPreConfigRecoveryEdit(toolKind, input, cwd)) return null;\n const loaded = loadAndValidate(cwd);\n if (loaded.configPath === null) return configMissingBlock(cwd);\n\n const workspaceRoot = path.dirname(loaded.configPath);\n\n // Always allow edits to webpieces.config.json — it's the fix target when out of sync — and the same\n // PASS for the machine-local `~/.webpieces/config.json` (a bad key there fails a `wp-*` command with\n // an instruction to edit it, so blocking the edit would wedge the agent inside the failure) and for\n // the two ROOT MANIFESTS a pin lives in — L1 row 8 PROMISED that edit and its cure IS it.\n // isRootManifest, never a basename: this returns EARLY, so basename would unrule every package.json\n // in the repo. It admits any tree's root (the config sits beside it), which is what a worktree's own\n // cure needs. IN PLACE ONLY: a Move onto one of these still deletes its source, which is judged (#1448).\n if (\n input.sourcePath === input.filePath &&\n (path.resolve(input.filePath) === path.resolve(loaded.configPath) ||\n isRootManifest(input.filePath) ||\n new HomeConfigService().isHomeConfigPath(input.filePath))\n )\n return null;\n\n // Built-in/custom rules PLUS the client-authored match-rules (content guards). Match-rules run only\n // in the file-edit path (they are code-style, so filterByMode keeps them out of the bash/guards path).\n const allRules = [...new WorkflowHookRules().load(loaded).rules];\n const modeRules = filterByMode(allRules, mode, loaded.ruleRegistry);\n if (modeRules.length === 0) return null;\n\n // Suppress enforcement for files under this category's excludePaths (e.g. vendored repos under\n // repositories/**). Exclusion is all-or-nothing per category, so an excluded file drops the whole\n // rule set and is fully hands-off — no violations AND no config-sync nag on those files.\n const governed = new TargetTreeResolver().governedPath(input.filePath, workspaceRoot);\n const relativePath = governed.relativePath;\n const rules = new DeleteScopedRules().narrow(\n toolKind,\n filterByExcludedPaths(modeRules, governed, loaded.excludePaths),\n );\n if (rules.length === 0) return null;\n\n const contexts = buildContexts(toolKind, input, workspaceRoot, governed);\n\n const editGroups = runEditRules(rules, contexts.editContexts);\n const fileGroups = runFileRules(rules, contexts.fileContext);\n const allGroups = [...editGroups, ...fileGroups];\n\n if (allGroups.length === 0) return null;\n\n const report = formatReport(relativePath, allGroups);\n return new BlockedResult(report);\n}\n\n// SINGLETON, deliberately: WebpiecesVersions memoizes per root, and the same two roots are asked for on\n// every Bash call. A fresh instance per call would spawn `git worktree list` and re-read two manifests\n// on the hook's blocking path each time.\nconst VERSION_SYNC = new VersionSyncGuard();\n\n// There is deliberately NO agent parameter. It existed only for CoordinatorWorktreeGuard, which asked\n// WHO was calling; that guard is gone and its replacement asks WHICH TREE the command acts on. Agent\n// identity was measured untrustworthy for that question anyway — a worktree-isolated agent auto-reaped\n// at a turn boundary silently resumes with its cwd on the primary clone — so a guard must never infer\n// a tree from who is asking.\n// webpieces-disable no-function-outside-class -- sibling of run()/runRead() in this module; the whole runner is module-scope functions and a lone class for this one entry point would break the file's shape\nexport function runBash(command: string, cwd: string, mode: HookMode, aiType: AiType): BlockedResult | null {\n return runBashInternal(command, cwd, mode, aiType);\n}\n\n// The name of the ONLY rule permitted to block a Read. Reads are the highest-blast-radius tool\n// there is, so this path is an explicit single-rule allowlist rather than the general rule loop.\nconst READ_SCOPED_GUARDS: ReadonlySet<string> = new Set(['read-stale-guard']);\n\n/**\n * The Read path. Deliberately NOT `run()`:\n *\n * - NO config-sync check. A rule present in code but missing from webpieces.config.json blocks\n * every Write/Edit/Bash by design — but applying that to Read would mean an upgrade that adds\n * any new rule instantly blocks the agent from reading the very config file it must edit to fix\n * it. Reads must never carry that failure mode.\n * - NO general rule loop. Only READ_SCOPED_GUARDS run, so no code-style rule can ever see a Read.\n * - Fails OPEN everywhere, including on a thrown rule (the caller catches and allows).\n *\n * Returns null (allow) unless the one guard fires.\n */\n// webpieces-disable no-function-outside-class -- sibling of run()/runBash() in this module; the whole runner is module-scope functions and a lone class for this one entry point would break the file's shape\nexport function runRead(\n filePath: string,\n cwd: string,\n mode: HookMode = 'all',\n): BlockedResult | null {\n // Code-style mode has nothing to say about a read.\n if (mode === 'rules') return null;\n\n let loaded: LoadedConfig;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- broken configuration must remain readable without enabling any mutating policy\n try {\n loaded = loadAndValidate(cwd);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError) return null;\n throw error;\n }\n // No config → nothing to enforce. Unlike the edit path we do NOT block: an unconfigured repo\n // must still be readable.\n if (loaded.configPath === null) return null;\n\n const workspaceRoot = path.dirname(loaded.configPath);\n\n // Same git-repo-boundary governance as bash, through the SAME resolver: a read inside a different\n // clone is out of scope. (No command to parse here, so the shell cwd IS the effective cwd.)\n if (new EffectiveTreeResolver().resolve('', cwd, workspaceRoot).kind === 'foreign') return null;\n\n const governed = new TargetTreeResolver().governedPath(filePath, workspaceRoot);\n const relativePath = governed.relativePath;\n const all = new WorkflowHookRules().load(loaded).rules;\n const rules = filterByExcludedPaths(\n all.filter((r: Rule): boolean => READ_SCOPED_GUARDS.has(r.name)),\n governed,\n loaded.excludePaths,\n );\n if (rules.length === 0) return null;\n\n const ctx = new FileContext('Read', filePath, relativePath, workspaceRoot, null, 0, 0, 0, 0);\n const groups = runFileRules(rules, ctx);\n if (groups.length === 0) return null;\n\n return new BlockedResult(formatReport(relativePath, groups, READ_SUBJECT));\n}\n\n// L0 cure bypass — every command on THE L0 allowlist passes here, ahead of any config load. A\n// webpieces.config.json that is ahead of the installed validator (new rule tokens the published\n// binary doesn't know yet) makes loadAndValidate() throw and would deny `pnpm install` — the very\n// command that updates the validator (deadlock).\n//\n// This used to test INSTALLER_ALLOW_JS alone, which made the config faults (C = config missing,\n// Y = config out of sync) accept a bare `pnpm install` while denying `rm -rf node_modules && pnpm\n// install` — the one cure that works when node_modules is CORRUPT rather than merely stale. Same\n// intent, opposite verdict, for no reason anyone recorded. Each alternative is still anchored at both\n// ends, so `pnpm install && rm -rf /` still falls to the guards.\n//\n// It tests the CURE subset (L0_CURE_ALLOW_JS), not the whole list, and the distinction matters here\n// and nowhere else: this call site runs BEFORE any fault has been established, so whatever it accepts\n// is waved past the L1 guards on a perfectly healthy repo too. A repair command has to be waved past —\n// it runs before the config can be loaded at all. Read-only ORIENTATION does not: it fixes nothing, and\n// letting `git status` through here would delete force-to-root as a side effect of adding `pwd`. Under\n// an actual fault, l0FaultAllows() below consults the WHOLE list.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction isL0CureCommand(command: string): boolean {\n return L0_CURE_ALLOW_JS.test(command.trim());\n}\n\n// The FULL L0 list, asked only where this file has actually detected an L0 fault (C = config missing,\n// Y = config out of sync). D/X/U/K are decided in the shim, which greps the same union.\n// IT ASKS `isAllowed()`, not a regex: that is the ONE question both halves of L0 ask, and the only\n// place harness-gated entries are consulted. Testing `L0_ALLOW_JS` directly (which is what this did)\n// dropped the Codex read under C and Y while D/X/U/K honoured it — a per-fault carve-out again.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction l0FaultAllows(command: string, aiType: AiType): boolean {\n return isAllowed('Bash', command.trim(), '', aiType) !== null;\n}\n\n// The L0 cure bypass's audit line. Anchored at the repo root that owns `.webpieces` — RepoRootFinder\n// (config-walk-up first, then git toplevel) is the authority for that, and it is correct in a linked\n// worktree because each worktree checks out its own webpieces.config.json. This runs BEFORE\n// loadAndValidate, which is why it resolves the root itself rather than using workspaceRoot.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction logL0CureBypass(command: string, cwd: string): void {\n const root = new RepoRootFinder().resolveRepoRoot(cwd);\n logGuardDecision(root, new GuardDecision('-', 'Bash', command, branchForLog(root), 'ALLOW', 'L0 cure bypass (always allowed)', '-', L0_FAULT_NONE, MATRIX_L0_ALLOW));\n}\n\n/**\n * Load the config for the bash path — but do NOT let an unloadable config trap the tools needed to\n * repair it.\n *\n * loadAndValidate throws an InformAiError when webpieces.config.json is unparseable (a real syntax\n * error, or leftover `<<<<<<< HEAD` markers mid-merge) or fails validation. That throw propagates to\n * the hook adapter, which fails CLOSED and denies the command — correct for work, since a config that\n * did not load means no guards ran. But it denied `cat`/`grep`/`sed -n` on webpieces.config.json too,\n * i.e. it blocked the only way to see the problem it was reporting. Observed live, twice.\n *\n * So: on a load failure, a provably-inert INSPECTION command is allowed through (returns null, \"no\n * block\"), matching the escape hatch every other layer already grants this file. Everything else —\n * every write, every git/gh command, every build — still hits the same hard failure as before. The\n * bypass cannot be widened by accident; see ReadOnlyInspectionScan for how narrow \"inert\" is.\n *\n * Returns the loaded config, or null meaning \"allow this command without guards\".\n */\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction loadConfigOrAllowInspection(command: string, cwd: string): LoadedConfig | null {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- rethrown unchanged unless the command is provably inert\n try {\n return loadAndValidate(cwd);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError && new ReadOnlyInspectionScan().isReadOnlyInspection(command)) {\n return null;\n }\n throw error;\n }\n}\n\n// Version skew: this worktree pins a different @webpieces than the MAIN tree that governs it. The guard\n// hooks are absolute, so the main tree's binary judges every tree — which is fine until the two trees\n// disagree about which release that should be. L1 row 8; guards/L1-location.md carries the table.\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction versionSkewBlock(command: string, tree: EffectiveTree, aiType: AiType): BlockedResult | null {\n const report = VERSION_SYNC.block(command, tree, aiType);\n return report === null ? null : new BlockedResult(report);\n}\n\n// Where the command lands in L1's five dimensions (K/A/R/G/P). The ONE place the runner's view of the\n// world is translated into the matrix's vocabulary — see L1Classification.forEnforcement for why\n// TreeKind 'outside' currently classifies as `p`.\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction l1Classify(command: string, tree: EffectiveTree): L1Classification {\n return L1Classification.forEnforcement(\n tree.kind,\n VERSION_SYNC.skewed(tree),\n new ReadOnlyInspectionScan().isReadOnlyInspection(command),\n isGitOrGhCommand(command),\n path.resolve(tree.effectiveCwd) === path.resolve(tree.root),\n );\n}\n\n// The structural L1 blocks, in order: the misplaced-`cd` PRE-STAGE, then version skew (row 8), then\n// force-to-root (row 5). None is a configurable rule — they are decided from the command text, the\n// resolved tree and the caller, so they run as one step here rather than as three near-identical\n// stanzas in runBashInternal.\n//\n// For the two TREE-BASED blocks the ORDER and the CHOICE are not written here: they come from L1_ROWS\n// (l1-rows.ts), the same array guards/L1-location.md is rendered from. Classify, take the first\n// matching row, dispatch on its blockId — so a row deleted from the array is a block that stops firing,\n// and the doc cannot describe a table the guard does not consult. The two report builders below still\n// own their own predicates and their deny strings; l1-matrix.spec.ts asserts the row lookup and those\n// predicates agree.\n//\n// misplacedCdBlock is deliberately OUTSIDE that lookup, and runs ahead of it, for the reason its own\n// docblock gives: it decides from command TEXT, before a tree has been resolved, and the other two\n// reason FROM the resolved tree. Classifying it would mean asking L1_ROWS a question whose answer the\n// classification itself depends on. It is the same shape as L2's `bareCheckoutOfMain` pre-stage. It is\n// therefore ROW 0 — \"pre-stage, decided from command text\" — rather than a row among 1-6, which keeps\n// it IN the table (the drift this table exists to prevent) without pretending it is classified over the\n// same five dimensions. `L1_PRESTAGE_ROW` is the number the doc prints and `row=` logs, so the two join.\n//\n// THIS FUNCTION IS THE ONE PLACE L1 REPORTS. It is the only scope holding the classification, the\n// matched row, the resolved tree and the agent at once — so logging here, BEFORE the early return,\n// is what finally records the outcomes that were previously invisible: the exempt row and the three\n// hand-downs wrote nothing at all, which is why \"L1 had no objection\" could not be observed and\n// \"show me every L1 decision\" had no answer. The three block helpers no longer log for themselves —\n// and, for the same reason, none of them knows about the matrix POINTER either: every deny is stamped\n// with it HERE, from the same scope and the same row number, so deny and log line cannot disagree.\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction l1LocationBlock(command: string, tree: EffectiveTree, aiType: AiType): BlockedResult | null {\n const misplacedCd = misplacedCdBlock(command, tree);\n if (misplacedCd !== null) {\n logL1(tree, command, 'BLOCK_AI_CURE', L1_PRESTAGE_ROW, 'cd-must-be-first', 'cd not leading/literal');\n return withLocationMatrixPointer(misplacedCd, tree.root, L1_PRESTAGE_ROW);\n }\n\n const row = firstMatchingL1Row(l1Classify(command, tree));\n const rowNum = String(row.num);\n if (row.blockId === null) {\n // ALLOW_EXEMPT stops here; ALLOW means \"no objection, handed down to L2\". Recording the\n // difference is the point — see Verdict. Neither claims the call RAN: the other parallel hook\n // may still have denied it.\n logL1(tree, command, row.action.kind === 'exempt' ? 'ALLOW_EXEMPT' : 'ALLOW', rowNum, '-', row.why);\n return null;\n }\n logL1(tree, command, 'BLOCK_AI_CURE', rowNum, row.blockId, row.why);\n if (row.blockId === 'missing-directory') return withLocationMatrixPointer(missingDirectoryBlock(command, tree), tree.root, rowNum);\n if (row.blockId === 'trinary-version-skew') return withLocationMatrixPointer(versionSkewBlock(command, tree, aiType), tree.root, rowNum);\n return withLocationMatrixPointer(gitFromSubdirBlock(command, tree, isGitOrGhCommand(command)), tree.root, rowNum);\n}\n\n// One L1 line, into L1's OWN stream. `row` is the number the generated doc prints, so a reader who sees\n// `row=5` can open the L1 matrix at row 5 — the deny for that same call names it by absolute path.\n// eslint-disable-next-line @typescript-eslint/max-params -- the six fields of one log line, and a class here would break this file's shape\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions\nfunction logL1(tree: EffectiveTree, command: string, verdict: Verdict, row: string, rule: string, why: string): void {\n logL1Decision(tree.root, new GuardDecision(\n rule, 'Bash', command, branchForLog(tree.root), verdict, why, '-', L0_FAULT_NONE, new MatrixRef('L1', row),\n ));\n}\n\n/**\n * ONE legal shape for relocating a command: `cd <literal path> && <work>`. Anything else — a `cd` after\n * another command or after a `VAR=…` assignment, or a `cd \"$DIR\"` the guard cannot expand — is refused\n * here instead of being silently judged from the shell cwd.\n *\n * This changes no verdict: every command it refuses was ALREADY judged from the shell cwd, so nothing\n * it blocks was previously being allowed on the strength of its `cd`. What changes is that the agent\n * finds out. Two PRs of increasingly precise near-miss wording (#596, #597) still left the fact in a\n * paragraph appended to an unrelated block; the rule is simpler stated as a rule.\n *\n * FIRST in the L1 chain deliberately. version skew and force-to-root both reason from the\n * resolved tree, and if the `cd` did not resolve, that tree is not the one the agent thinks they are\n * in — so their remedies would be steering from a location the command does not actually run in.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole runner is module-scope functions\nfunction misplacedCdBlock(command: string, tree: EffectiveTree): BlockedResult | null {\n const reason = new EffectiveTreeResolver().misplacedCd(command);\n if (reason === null) return null;\n const report =\n `❌ A \\`cd\\` must come FIRST in the command, with a LITERAL path.\\n` +\n ` Why this one was rejected: ${reason}.\\n` +\n ` \\`cd <literal path> && <work>\\` is the ONE shape that moves where webpieces judges a command.\\n` +\n ` Any other \\`cd\\` cannot be resolved, so the command would be judged against ${tree.root}\\n` +\n ` — not where you think it runs. That used to happen silently; this block is that silence, spoken.\\n` +\n ` Fix Option 1: put the \\`cd\\` first, literal path, SAME command: cd /abs/path && <the rest>\\n` +\n ` Fix Option 2: drop the \\`cd\\` — ${tree.root} is where the command is judged anyway.\\n` +\n ` Fix Option 3: if the SECOND \\`cd\\` was there to point a tool at a directory, use that tool's own\\n` +\n ` directory flag instead — \\`git -C <dir>\\`, \\`tar -C <dir>\\`, \\`npm --prefix <dir>\\`,\\n` +\n ` \\`npm pack --pack-destination <dir>\\`, \\`pnpm --dir <dir>\\`. One \\`cd\\`, same result.\\n` +\n ` ONLY for a dir INSIDE this tree. \\`git -C <another tree>\\` is REFUSED to a subagent,\\n` +\n ` and is never the cure for a version skew — for that, tell the MAIN agent.\\n` +\n ` Fix Option 4: split it — run the work in one call, the \\`cd\\` in another (a \\`cd\\` alone still\\n` +\n ` moves nothing the guards judge; see EffectiveTree on why cwd cannot be assumed).`;\n return new BlockedResult(report);\n}\n\n/**\n * The KEYLESS bash guards, deliberately kept OUT of the config-driven rule set. They have no\n * webpieces.config.json entry at all, so passing them through checkConfigSync would make every\n * consumer's next Bash call a fault-Y block (\"this rule has no entry\") for a feature nobody opted into\n * — which is exactly what whole-repo-build-guard did on its first release. Each one decides for itself\n * whether it acts: whole-repo-build-guard reads ~/.webpieces/config.json for a machine-local OPT-IN\n * (absent means OFF); commit-message-substitution-guard and build-output-pipe-guard act unconditionally.\n * They still honour excludePaths, and they do not run in `rules` mode (code-style-only hook).\n */\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction keylessBashRules(loaded: LoadedConfig, mode: HookMode, governed: GovernedPath): readonly Rule[] {\n if (mode === 'rules') return [];\n return filterByExcludedPaths(\n loadKeylessBashRules(loaded.prGate.buildCommand), governed, loaded.excludePaths,\n );\n}\n\n// webpieces-disable no-function-outside-class -- sibling of run()/runBash() in this module; the whole runner is module-scope functions and a lone class for this one entry point would break the file's shape\nfunction runBashInternal(\n command: string,\n cwd: string,\n mode: HookMode,\n aiType: AiType,\n): BlockedResult | null {\n if (isL0CureCommand(command)) {\n logL0CureBypass(command, cwd);\n return null;\n }\n\n const loaded = loadConfigOrAllowInspection(command, cwd);\n // null = the config would not load AND this command only inspects → allow, see the helper.\n if (loaded === null) return null;\n if (loaded.configPath === null)\n return l0FaultAllows(command, aiType) ? null : configMissingBlock(cwd);\n\n const workspaceRoot = path.dirname(loaded.configPath);\n\n // WHICH TREE does this command act on? Not the shell's cwd: a `cd` OUT of the workspace is reset\n // by the harness and one INSIDE it persists, so neither can be assumed (see EffectiveTree).\n // ONE resolver answers this for the guards AND for force-to-root below, so the two can never\n // disagree about which tree you are in.\n const tree = new EffectiveTreeResolver().resolve(command, cwd, workspaceRoot);\n\n if (allowForeignTree(command, tree, workspaceRoot)) return null;\n\n // Honour excludePaths on the bash path too (not just Read/Edit): a command whose effective\n // cwd sits under an excluded tree (e.g. repositories/**) drops the whole guard set — matching how\n // runInternal/runRead treat file paths. The relative path is '' when there is no `cd` (root), which\n // matches no exclusion glob, so a plain command at the repo root is unaffected.\n const governedCwd = bashGovernedPath(tree, workspaceRoot);\n const rules = filterByExcludedPaths(\n filterByMode(new WorkflowHookRules().load(loaded).rules, mode, loaded.ruleRegistry),\n governedCwd,\n loaded.excludePaths,\n );\n const keyless = keylessBashRules(loaded, mode, governedCwd);\n if (rules.length === 0 && keyless.length === 0) return null;\n\n const locationBlock = l1LocationBlock(command, tree, aiType);\n if (locationBlock) return locationBlock;\n\n // Keep the feature-branch-guard cache warm on EVERY command (not just Write/Edit): the AI runs\n // far more bash than edits, so refreshing here means the guard's next file-edit check reads a\n // fresh status. Detached + fire-and-forget — never blocks the command. Only when the guard is\n // loaded (guards/all mode) and enabled, so a project that opted out never triggers git fetches.\n // Keyed on the JUDGED tree, so a worktree's cache is refreshed rather than the primary clone's.\n maybeRefreshMainSync(rules, tree.root, branchStateHangTimeout(loaded.rulesConfig));\n\n const groups = runBashRules([...rules, ...keyless], buildBashContext(command, tree));\n return bashPolicyResult(command, tree, loaded, groups);\n}\n\n// The bash report's subject line. It used to be the literal string `<bash>`, which told the agent\n// nothing; the command itself is what was blocked, so name it — truncated, because a heredoc-bearing\n// command can run to thousands of characters and the violation lines already carry the detail.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction commandLabel(command: string): string {\n const oneLine = command.replace(/\\s+/g, ' ').trim();\n const MAX = 100;\n return oneLine.length <= MAX ? oneLine : oneLine.slice(0, MAX) + '…';\n}\n\n// When a push/PR block fires AND the config exempts vendored/nested trees, surface the escape hatch the\n// AI cannot otherwise discover: git/gh run UNGUARDED inside those trees if it cd's there first (each is\n// governed by its own repo, not this one). Scoped to pr-creation-or-push-guard — for the other guards\n// \"cd into an exempt tree\" is not the remedy — and emitted only when such trees are actually configured,\n// so a repo without exemptions never sees the noise.\n//\n// The hint MUST state the precondition, not just the remedy. \"cd into it first\" is true only for a\n// LITERAL cd at the FRONT of the same command; `D=…; cd \"$D\"; git push` lands in the identical\n// directory and does NOT relocate the verdict. That used to be silent, then a near-miss paragraph\n// appended here; it is now misplacedCdBlock, which refuses the command outright — so by the time this\n// footer is reached, any `cd` in the command is already known to be leading and literal. The wording\n// still states the shape, because this is where an agent LEARNS it, before writing the next command.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction exemptTreesHint(groups: readonly RuleGroup[], exemptGuards: readonly string[]): string {\n if (exemptGuards.length === 0) return '';\n if (!groups.some((g: RuleGroup): boolean => g.ruleName === 'pr-creation-or-push-guard'))\n return '';\n\n return (\n `\\n\\nℹ️ Working in a nested repo under one of these exempt trees (${exemptGuards.join(', ')})? ` +\n `Put a LITERAL \\`cd\\` at the FRONT of the SAME command — \\`cd /abs/path/to/repo && git push\\` — and git/gh ` +\n `run normally there: the webpieces guards do NOT govern them (each is its own repo).` +\n `\\n \\`cd <literal path> && <work>\\` is the ONE shape that moves where a command is judged. A \\`cd\\` ` +\n `anywhere else in the line, or a non-literal target like \\`cd \"$DIR\"\\`, is refused outright rather than ` +\n `judged from somewhere you did not intend.`\n );\n}\n\n// webpieces-disable no-function-outside-class -- runner result assembly is a pure orchestration helper\nfunction bashPolicyResult(command: string, tree: EffectiveTree, loaded: LoadedConfig, groups: readonly RuleGroup[]): BlockedResult | null {\n const workspaceRoot = path.dirname(loaded.configPath!);\n if (groups.length === 0) {\n // Record the ALLOW only for git/gh commands — the operations the bash guards actually reason\n // about (branch create, commit, push, merge, PR). Skipping ls/cat/grep keeps the audit log\n // focused (the whole point of the log is \"why did/didn't a guard fire?\"). Blocks are always\n // logged below.\n if (/\\b(?:git|gh)\\b/.test(command)) {\n logGuardDecision(\n tree.root,\n new GuardDecision(\n '-',\n 'Bash',\n command,\n branchForLog(tree.root),\n 'ALLOW',\n 'no bash-guard block',\n '-',\n L0_FAULT_NONE,\n MATRIX_L2_UNROWED,\n ),\n );\n }\n return null;\n }\n\n const ruleNames = groups.map((g: RuleGroup): string => g.ruleName).join(',');\n logGuardDecision(\n tree.root,\n new GuardDecision(\n ruleNames,\n 'Bash',\n command,\n branchForLog(tree.root),\n 'BLOCK_AI_CURE',\n 'bash-guard block',\n '-',\n L0_FAULT_NONE,\n MATRIX_L2_UNROWED,\n ),\n );\n const report =\n new ExcludedPathEscapeHint(workspaceRoot, tree.effectiveCwd).render(\n command,\n loaded.excludePaths,\n ) +\n formatReport(commandLabel(command), groups, BASH_SUBJECT) +\n exemptTreesHint(groups, loaded.excludePaths.paths);\n return new BlockedResult(report);\n}\n\n// webpieces-disable no-function-outside-class -- orchestration helper for the explicit foreign-repository exemption\nfunction allowForeignTree(command: string, tree: EffectiveTree, workspaceRoot: string): boolean {\n if (tree.kind === 'foreign') {\n logGuardDecision(\n workspaceRoot,\n new GuardDecision(\n '-',\n 'Bash',\n command,\n branchForLog(workspaceRoot),\n 'ALLOW_EXEMPT',\n 'foreign git repo (out of scope)',\n '-',\n L0_FAULT_NONE,\n new MatrixRef('L1', '1'),\n ),\n );\n return true;\n }\n\n return false;\n}\n"]}
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../../packages/tooling/agent-workflow-rules/src/core/runner.ts"],"names":[],"mappings":";;AAgEA,4CAEC;AAKD,4CAEC;AAkBD,kBAOC;AAqFD,0BAEC;AAmBD,0BA2CC;;AAvPD,0DAAiG;AACjG,mDAA6B;AAE7B,0DAYiC;AAEjC,0DAA0E;AAC1E,0DAA4D;AAC5D,iDAAkD;AAClD,0DAA+E;AAC/E,0DAA2E;AAC3E,0DAAkF;AAClF,iEAAgE;AAChE,mDAAqD;AACrD,6CAAoD;AACpD,+DAA0D;AAC1D,2DAA4D;AAC5D,2DAAmF;AACnF,iDAAsJ;AACtJ,iEAA6D;AA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AA,2BAAY,EAAC,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,2BAAY,CAAC;QACzD,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACvD,OAAO,IAAI,4BAAa,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC;AAED,oHAAoH;AACpH,SAAS,gBAAgB,CAAC,OAAe,EAAE,IAAmB,EAAE,aAAqB;IACjF,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,IAAA,+BAAgB,EACZ,aAAa,EACb,IAAI,4BAAa,CACb,GAAG,EACH,MAAM,EACN,OAAO,EACP,IAAA,2BAAY,EAAC,aAAa,CAAC,EAC3B,cAAc,EACd,iCAAiC,EACjC,GAAG,EACH,4BAAa,EACb,IAAI,wBAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAC3B,CACJ,CAAC;QACF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import { runRuleCheck, runEditRules, runFileRules, runBashRules } from '@webpieces/hook-runtime';\nimport * as path from 'path';\n\nimport {\n loadAndValidate,\n LoadedConfig,\n ConfigRepairAccess,\n RulePackRegistry,\n WebpiecesRulesConfig,\n isHookGuard,\n HomeConfigService,\n RepoRootFinder,\n seedEntryForRule,\n CONFIG_FILENAME,\n renderRuleFailForAi,\n} from '@webpieces/rules-config';\n\nimport { buildContexts, buildBashContext } from '@webpieces/hook-runtime';\nimport { DeleteScopedRules } from '@webpieces/hook-runtime';\nimport { VersionSyncGuard } from './version-sync';\nimport { EffectiveTree, EffectiveTreeResolver } from '@webpieces/hook-runtime';\nimport { GovernedPath, TargetTreeResolver } from '@webpieces/hook-runtime';\nimport { bashGovernedPath, filterByExcludedPaths } from '@webpieces/hook-runtime';\nimport { ExcludedPathEscapeHint } from './excluded-path-escape';\nimport { gitFromSubdirBlock } from './force-to-root';\nimport { loadKeylessBashRules } from './load-rules';\nimport { WorkflowHookRules } from './workflow-hook-rules';\nimport { missingDirectoryBlock } from './missing-directory';\nimport { branchStateHangTimeout, maybeRefreshMainSync } from './main-sync-timeout';\nimport { logGuardDecision, logL1Decision, GuardDecision, branchForLog, MatrixRef, Verdict, MATRIX_L0_ALLOW, MATRIX_L2_UNROWED } from './decision-log';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { formatReport, READ_SUBJECT, BASH_SUBJECT } from '@webpieces/hook-runtime';\nimport { ReadOnlyInspectionScan } from './read-only-inspection';\nimport { L0_CURE_ALLOW_JS, isAllowed } from '../bin/shim';\nimport { isRootManifest } from '@webpieces/hook-runtime';\nimport { AiType } from '@webpieces/hook-runtime';\nimport { L0_FAULT_CONFIG_MISSING, L0_FAULT_CONFIG_OUT_OF_SYNC, L0_FAULT_NONE } from '@webpieces/rules-config';\nimport { CONFIG_MISSING_REPORT, CONFIG_OUT_OF_SYNC_HEADER } from '@webpieces/rules-config';\nimport { writeGuardMatrixDoc, guardMatrixPointer } from './l0-matrix';\nimport { L1Classification, firstMatchingL1Row, L1_PRESTAGE_ROW } from './l1-rows';\nimport { withLocationMatrixPointer } from './l1-matrix-doc';\nimport { ToolKind, NormalizedToolInput, BlockedResult, HookMode, Rule, Violation, RuleGroup, EditContext, FileContext, BashContext } from '@webpieces/hook-runtime';\nimport { RuleFailError } from '@webpieces/rules-config';\nimport { InformAiError } from '@webpieces/tooling-common';\n\n// Restrict loaded rules to the category this hook invocation runs. The two split hooks each pass a\n// disjoint category ('rules' = code-style, 'guards' = the hookGuards section); 'all' runs both (the\n// openclaw plugin adapter, a single before_tool_call hook). isHookGuard is the shared classifier in\n// @webpieces/rules-config.\n// isHookGuard is asked about the rule's CONFIG KEY, never its name. Since the collapse those differ\n// for every class behind a policy key — `feature-branch-guard` is a rule NAME whose key is\n// `branch-state-guard` — and asking about the name would classify all eight collapsed guards as\n// code-style rules, i.e. run them in the wrong hook and never in the guards hook at all.\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nfunction filterByMode(rules: readonly Rule[], mode: HookMode, registry: RulePackRegistry): readonly Rule[] {\n if (mode === 'all') return rules;\n if (mode === 'guards') return rules.filter((r: Rule): boolean => isHookGuard(r.configKey, registry));\n return rules.filter((r: Rule): boolean => !isHookGuard(r.configKey, registry));\n}\n\n// The cwd a command actually runs from, after its own leading `cd`/`pushd` run. Thin delegate kept\n// for the callers (and specs) that only need the directory; the full tree classification — primary\n// clone vs linked worktree vs nested clone vs outside any repo — is EffectiveTreeResolver.resolve().\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nexport function effectiveBashCwd(command: string, cwd: string): string {\n return new EffectiveTreeResolver().effectiveCwd(command, cwd);\n}\n\n// A git or gh invocation anywhere in the command (start, or after a ;/&&/|| separator or pipe).\nconst GIT_OR_GH_RE = /(?:^|[;&|]\\s*)(?:git|gh)\\b/;\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nexport function isGitOrGhCommand(command: string): boolean {\n return GIT_OR_GH_RE.test(command);\n}\n\n// Fault C (webpieces.config.json missing) — the deny text lives in ./l0-matrix beside the rest of the\n// L0 fault table, so the message and the allowlist can never prescribe different cures. `cwd` is used\n// only to drop the matrix doc where the AI can read it (the config root does not exist yet here).\n//\n// THE ALLOWLIST ESCAPE IS THE CALLER'S (moved out 2026-09-01): behind an optional `command` it could\n// not see the harness, so the gated half of the list was unreachable under C while\n// CONFIG_MISSING_REPORT promised it. See l0FaultAllows. This has one job now: build the block.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction configMissingBlock(cwd: string): BlockedResult {\n const root = new RepoRootFinder().resolveRepoRoot(cwd);\n // Stamped with its L0 letter so the block is greppable as fault C wherever it is recorded — the\n // adapter carries it to the audit line rather than re-deriving it from the report text.\n return new BlockedResult(CONFIG_MISSING_REPORT + guardMatrixPointer(writeGuardMatrixDoc(root)), L0_FAULT_CONFIG_MISSING);\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nexport function run(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n cwd: string,\n mode: HookMode = 'all',\n): BlockedResult | null {\n return runInternal(toolKind, input, cwd, mode);\n}\n\n// The pre-config pass: an edit whose every path — BOTH sides of a Move — is a repair file, a root\n// manifest or the home config. Checking the source is what stops a rename of ordinary code ONTO a\n// recovery file from deleting that code with nothing judging it (#1448).\n// webpieces-disable no-function-outside-class -- sibling of runInternal in this module-scope runner\nfunction isPreConfigRecoveryEdit(toolKind: ToolKind, input: NormalizedToolInput, cwd: string): boolean {\n if (toolKind === 'Delete') return false;\n const root = new RepoRootFinder().resolveRepoRoot(cwd);\n return [input.filePath, input.sourcePath].every(\n (target: string): boolean =>\n new ConfigRepairAccess().isRepairFile(root, target) ||\n isRootManifest(target) ||\n new HomeConfigService().isHomeConfigPath(target),\n );\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nfunction runInternal(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n cwd: string,\n mode: HookMode,\n): BlockedResult | null {\n if (isPreConfigRecoveryEdit(toolKind, input, cwd)) return null;\n const loaded = loadAndValidate(cwd);\n if (loaded.configPath === null) return configMissingBlock(cwd);\n\n const workspaceRoot = path.dirname(loaded.configPath);\n\n // Always allow edits to webpieces.config.json — it's the fix target when out of sync — and the same\n // PASS for the machine-local `~/.webpieces/config.json` (a bad key there fails a `wp-*` command with\n // an instruction to edit it, so blocking the edit would wedge the agent inside the failure) and for\n // the two ROOT MANIFESTS a pin lives in — L1 row 8 PROMISED that edit and its cure IS it.\n // isRootManifest, never a basename: this returns EARLY, so basename would unrule every package.json\n // in the repo. It admits any tree's root (the config sits beside it), which is what a worktree's own\n // cure needs. IN PLACE ONLY: a Move onto one of these still deletes its source, which is judged (#1448).\n if (\n input.sourcePath === input.filePath &&\n (path.resolve(input.filePath) === path.resolve(loaded.configPath) ||\n isRootManifest(input.filePath) ||\n new HomeConfigService().isHomeConfigPath(input.filePath))\n )\n return null;\n\n // Built-in/custom rules PLUS the client-authored match-rules (content guards). Match-rules run only\n // in the file-edit path (they are code-style, so filterByMode keeps them out of the bash/guards path).\n const allRules = [...new WorkflowHookRules().load(loaded).rules];\n const modeRules = filterByMode(allRules, mode, loaded.ruleRegistry);\n if (modeRules.length === 0) return null;\n\n // Suppress enforcement for files under this category's excludePaths (e.g. vendored repos under\n // repositories/**). Exclusion is all-or-nothing per category, so an excluded file drops the whole\n // rule set and is fully hands-off — no violations AND no config-sync nag on those files.\n const governed = new TargetTreeResolver().governedPath(input.filePath, workspaceRoot);\n const relativePath = governed.relativePath;\n const rules = new DeleteScopedRules().narrow(\n toolKind,\n filterByExcludedPaths(modeRules, governed, loaded.excludePaths),\n );\n if (rules.length === 0) return null;\n\n const contexts = buildContexts(toolKind, input, workspaceRoot, governed);\n\n const editGroups = runEditRules(rules, contexts.editContexts);\n const fileGroups = runFileRules(rules, contexts.fileContext);\n const allGroups = [...editGroups, ...fileGroups];\n\n if (allGroups.length === 0) return null;\n\n const report = formatReport(relativePath, allGroups);\n return new BlockedResult(report);\n}\n\n// SINGLETON, deliberately: WebpiecesVersions memoizes per root, and the same two roots are asked for on\n// every Bash call. A fresh instance per call would spawn `git worktree list` and re-read two manifests\n// on the hook's blocking path each time.\nconst VERSION_SYNC = new VersionSyncGuard();\n\n// There is deliberately NO agent parameter. It existed only for CoordinatorWorktreeGuard, which asked\n// WHO was calling; that guard is gone and its replacement asks WHICH TREE the command acts on. Agent\n// identity was measured untrustworthy for that question anyway — a worktree-isolated agent auto-reaped\n// at a turn boundary silently resumes with its cwd on the primary clone — so a guard must never infer\n// a tree from who is asking.\n// webpieces-disable no-function-outside-class -- sibling of run()/runRead() in this module; the whole runner is module-scope functions and a lone class for this one entry point would break the file's shape\nexport function runBash(command: string, cwd: string, mode: HookMode, aiType: AiType): BlockedResult | null {\n return runBashInternal(command, cwd, mode, aiType);\n}\n\n// The name of the ONLY rule permitted to block a Read. Reads are the highest-blast-radius tool\n// there is, so this path is an explicit single-rule allowlist rather than the general rule loop.\nconst READ_SCOPED_GUARDS: ReadonlySet<string> = new Set(['read-stale-guard']);\n\n/**\n * The Read path. Deliberately NOT `run()`:\n *\n * - NO config-sync check. A rule present in code but missing from webpieces.config.json blocks\n * every Write/Edit/Bash by design — but applying that to Read would mean an upgrade that adds\n * any new rule instantly blocks the agent from reading the very config file it must edit to fix\n * it. Reads must never carry that failure mode.\n * - NO general rule loop. Only READ_SCOPED_GUARDS run, so no code-style rule can ever see a Read.\n * - Fails OPEN everywhere, including on a thrown rule (the caller catches and allows).\n *\n * Returns null (allow) unless the one guard fires.\n */\n// webpieces-disable no-function-outside-class -- sibling of run()/runBash() in this module; the whole runner is module-scope functions and a lone class for this one entry point would break the file's shape\nexport function runRead(\n filePath: string,\n cwd: string,\n mode: HookMode = 'all',\n): BlockedResult | null {\n // Code-style mode has nothing to say about a read.\n if (mode === 'rules') return null;\n\n let loaded: LoadedConfig;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- broken configuration must remain readable without enabling any mutating policy\n try {\n loaded = loadAndValidate(cwd);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError) return null;\n throw error;\n }\n // No config → nothing to enforce. Unlike the edit path we do NOT block: an unconfigured repo\n // must still be readable.\n if (loaded.configPath === null) return null;\n\n const workspaceRoot = path.dirname(loaded.configPath);\n\n // Same git-repo-boundary governance as bash, through the SAME resolver: a read inside a different\n // clone is out of scope. (No command to parse here, so the shell cwd IS the effective cwd.)\n if (new EffectiveTreeResolver().resolve('', cwd, workspaceRoot).kind === 'foreign') return null;\n\n const governed = new TargetTreeResolver().governedPath(filePath, workspaceRoot);\n const relativePath = governed.relativePath;\n const all = new WorkflowHookRules().load(loaded).rules;\n const rules = filterByExcludedPaths(\n all.filter((r: Rule): boolean => READ_SCOPED_GUARDS.has(r.name)),\n governed,\n loaded.excludePaths,\n );\n if (rules.length === 0) return null;\n\n const ctx = new FileContext('Read', filePath, relativePath, workspaceRoot, null, 0, 0, 0, 0);\n const groups = runFileRules(rules, ctx);\n if (groups.length === 0) return null;\n\n return new BlockedResult(formatReport(relativePath, groups, READ_SUBJECT));\n}\n\n// L0 cure bypass — every command on THE L0 allowlist passes here, ahead of any config load. A\n// webpieces.config.json that is ahead of the installed validator (new rule tokens the published\n// binary doesn't know yet) makes loadAndValidate() throw and would deny `pnpm install` — the very\n// command that updates the validator (deadlock).\n//\n// This used to test INSTALLER_ALLOW_JS alone, which made the config faults (C = config missing,\n// Y = config out of sync) accept a bare `pnpm install` while denying `rm -rf node_modules && pnpm\n// install` — the one cure that works when node_modules is CORRUPT rather than merely stale. Same\n// intent, opposite verdict, for no reason anyone recorded. Each alternative is still anchored at both\n// ends, so `pnpm install && rm -rf /` still falls to the guards.\n//\n// It tests the CURE subset (L0_CURE_ALLOW_JS), not the whole list, and the distinction matters here\n// and nowhere else: this call site runs BEFORE any fault has been established, so whatever it accepts\n// is waved past the L1 guards on a perfectly healthy repo too. A repair command has to be waved past —\n// it runs before the config can be loaded at all. Read-only ORIENTATION does not: it fixes nothing, and\n// letting `git status` through here would delete force-to-root as a side effect of adding `pwd`. Under\n// an actual fault, l0FaultAllows() below consults the WHOLE list.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction isL0CureCommand(command: string): boolean {\n return L0_CURE_ALLOW_JS.test(command.trim());\n}\n\n// The FULL L0 list, asked only where this file has actually detected an L0 fault (C = config missing,\n// Y = config out of sync). D/X/U/K are decided in the shim, which greps the same union.\n// IT ASKS `isAllowed()`, not a regex: that is the ONE question both halves of L0 ask, and the only\n// place harness-gated entries are consulted. Testing `L0_ALLOW_JS` directly (which is what this did)\n// dropped the Codex read under C and Y while D/X/U/K honoured it — a per-fault carve-out again.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction l0FaultAllows(command: string, aiType: AiType): boolean {\n return isAllowed('Bash', command.trim(), '', aiType) !== null;\n}\n\n// The L0 cure bypass's audit line. Anchored at the repo root that owns `.webpieces` — RepoRootFinder\n// (config-walk-up first, then git toplevel) is the authority for that, and it is correct in a linked\n// worktree because each worktree checks out its own webpieces.config.json. This runs BEFORE\n// loadAndValidate, which is why it resolves the root itself rather than using workspaceRoot.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction logL0CureBypass(command: string, cwd: string): void {\n const root = new RepoRootFinder().resolveRepoRoot(cwd);\n logGuardDecision(root, new GuardDecision('-', 'Bash', command, branchForLog(root), 'ALLOW', 'L0 cure bypass (always allowed)', '-', L0_FAULT_NONE, MATRIX_L0_ALLOW));\n}\n\n/**\n * Load the config for the bash path — but do NOT let an unloadable config trap the tools needed to\n * repair it.\n *\n * loadAndValidate throws an InformAiError when webpieces.config.json is unparseable (a real syntax\n * error, or leftover `<<<<<<< HEAD` markers mid-merge) or fails validation. That throw propagates to\n * the hook adapter, which fails CLOSED and denies the command — correct for work, since a config that\n * did not load means no guards ran. But it denied `cat`/`grep`/`sed -n` on webpieces.config.json too,\n * i.e. it blocked the only way to see the problem it was reporting. Observed live, twice.\n *\n * So: on a load failure, a provably-inert INSPECTION command is allowed through (returns null, \"no\n * block\"), matching the escape hatch every other layer already grants this file. Everything else —\n * every write, every git/gh command, every build — still hits the same hard failure as before. The\n * bypass cannot be widened by accident; see ReadOnlyInspectionScan for how narrow \"inert\" is.\n *\n * Returns the loaded config, or null meaning \"allow this command without guards\".\n */\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction loadConfigOrAllowInspection(command: string, cwd: string): LoadedConfig | null {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- rethrown unchanged unless the command is provably inert\n try {\n return loadAndValidate(cwd);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError && new ReadOnlyInspectionScan().isReadOnlyInspection(command)) {\n return null;\n }\n throw error;\n }\n}\n\n// Version skew: this worktree pins a different @webpieces than the MAIN tree that governs it. The guard\n// hooks are absolute, so the main tree's binary judges every tree — which is fine until the two trees\n// disagree about which release that should be. L1 row 8; guards/L1-location.md carries the table.\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction versionSkewBlock(command: string, tree: EffectiveTree, aiType: AiType): BlockedResult | null {\n const report = VERSION_SYNC.block(command, tree, aiType);\n return report === null ? null : new BlockedResult(report);\n}\n\n// Where the command lands in L1's five dimensions (K/A/R/G/P). The ONE place the runner's view of the\n// world is translated into the matrix's vocabulary — see L1Classification.forEnforcement for why\n// TreeKind 'outside' currently classifies as `p`.\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction l1Classify(command: string, tree: EffectiveTree): L1Classification {\n return L1Classification.forEnforcement(\n tree.kind,\n VERSION_SYNC.skewed(tree),\n new ReadOnlyInspectionScan().isReadOnlyInspection(command),\n isGitOrGhCommand(command),\n path.resolve(tree.effectiveCwd) === path.resolve(tree.root),\n );\n}\n\n// The structural L1 blocks, in order: the misplaced-`cd` PRE-STAGE, then version skew (row 8), then\n// force-to-root (row 5). None is a configurable rule — they are decided from the command text, the\n// resolved tree and the caller, so they run as one step here rather than as three near-identical\n// stanzas in runBashInternal.\n//\n// For the two TREE-BASED blocks the ORDER and the CHOICE are not written here: they come from L1_ROWS\n// (l1-rows.ts), the same array guards/L1-location.md is rendered from. Classify, take the first\n// matching row, dispatch on its blockId — so a row deleted from the array is a block that stops firing,\n// and the doc cannot describe a table the guard does not consult. The two report builders below still\n// own their own predicates and their deny strings; l1-matrix.spec.ts asserts the row lookup and those\n// predicates agree.\n//\n// misplacedCdBlock is deliberately OUTSIDE that lookup, and runs ahead of it, for the reason its own\n// docblock gives: it decides from command TEXT, before a tree has been resolved, and the other two\n// reason FROM the resolved tree. Classifying it would mean asking L1_ROWS a question whose answer the\n// classification itself depends on. It is the same shape as L2's `bareCheckoutOfMain` pre-stage. It is\n// therefore ROW 0 — \"pre-stage, decided from command text\" — rather than a row among 1-6, which keeps\n// it IN the table (the drift this table exists to prevent) without pretending it is classified over the\n// same five dimensions. `L1_PRESTAGE_ROW` is the number the doc prints and `row=` logs, so the two join.\n//\n// THIS FUNCTION IS THE ONE PLACE L1 REPORTS. It is the only scope holding the classification, the\n// matched row, the resolved tree and the agent at once — so logging here, BEFORE the early return,\n// is what finally records the outcomes that were previously invisible: the exempt row and the three\n// hand-downs wrote nothing at all, which is why \"L1 had no objection\" could not be observed and\n// \"show me every L1 decision\" had no answer. The three block helpers no longer log for themselves —\n// and, for the same reason, none of them knows about the matrix POINTER either: every deny is stamped\n// with it HERE, from the same scope and the same row number, so deny and log line cannot disagree.\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction l1LocationBlock(command: string, tree: EffectiveTree, aiType: AiType): BlockedResult | null {\n const misplacedCd = misplacedCdBlock(command, tree);\n if (misplacedCd !== null) {\n logL1(tree, command, 'BLOCK_AI_CURE', L1_PRESTAGE_ROW, 'cd-must-be-first', 'cd not leading/literal');\n return withLocationMatrixPointer(misplacedCd, tree.root, L1_PRESTAGE_ROW);\n }\n\n const row = firstMatchingL1Row(l1Classify(command, tree));\n const rowNum = String(row.num);\n if (row.blockId === null) {\n // ALLOW_EXEMPT stops here; ALLOW means \"no objection, handed down to L2\". Recording the\n // difference is the point — see Verdict. Neither claims the call RAN: the other parallel hook\n // may still have denied it.\n logL1(tree, command, row.action.kind === 'exempt' ? 'ALLOW_EXEMPT' : 'ALLOW', rowNum, '-', row.why);\n return null;\n }\n logL1(tree, command, 'BLOCK_AI_CURE', rowNum, row.blockId, row.why);\n if (row.blockId === 'missing-directory') return withLocationMatrixPointer(missingDirectoryBlock(command, tree), tree.root, rowNum);\n if (row.blockId === 'trinary-version-skew') return withLocationMatrixPointer(versionSkewBlock(command, tree, aiType), tree.root, rowNum);\n return withLocationMatrixPointer(gitFromSubdirBlock(command, tree, isGitOrGhCommand(command)), tree.root, rowNum);\n}\n\n// One L1 line, into L1's OWN stream. `row` is the number the generated doc prints, so a reader who sees\n// `row=5` can open the L1 matrix at row 5 — the deny for that same call names it by absolute path.\n// eslint-disable-next-line @typescript-eslint/max-params -- the six fields of one log line, and a class here would break this file's shape\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions\nfunction logL1(tree: EffectiveTree, command: string, verdict: Verdict, row: string, rule: string, why: string): void {\n logL1Decision(tree.root, new GuardDecision(\n rule, 'Bash', command, branchForLog(tree.root), verdict, why, '-', L0_FAULT_NONE, new MatrixRef('L1', row),\n ));\n}\n\n/**\n * ONE legal shape for relocating a command: `cd <literal path> && <work>`. Anything else — a `cd` after\n * another command or after a `VAR=…` assignment, or a `cd \"$DIR\"` the guard cannot expand — is refused\n * here instead of being silently judged from the shell cwd.\n *\n * This changes no verdict: every command it refuses was ALREADY judged from the shell cwd, so nothing\n * it blocks was previously being allowed on the strength of its `cd`. What changes is that the agent\n * finds out. Two PRs of increasingly precise near-miss wording (#596, #597) still left the fact in a\n * paragraph appended to an unrelated block; the rule is simpler stated as a rule.\n *\n * FIRST in the L1 chain deliberately. version skew and force-to-root both reason from the\n * resolved tree, and if the `cd` did not resolve, that tree is not the one the agent thinks they are\n * in — so their remedies would be steering from a location the command does not actually run in.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other module-scope runner helpers; the whole runner is module-scope functions\nfunction misplacedCdBlock(command: string, tree: EffectiveTree): BlockedResult | null {\n const reason = new EffectiveTreeResolver().misplacedCd(command);\n if (reason === null) return null;\n const report =\n `❌ A \\`cd\\` must come FIRST in the command, with a LITERAL path.\\n` +\n ` Why this one was rejected: ${reason}.\\n` +\n ` \\`cd <literal path> && <work>\\` is the ONE shape that moves where webpieces judges a command.\\n` +\n ` Any other \\`cd\\` cannot be resolved, so the command would be judged against ${tree.root}\\n` +\n ` — not where you think it runs. That used to happen silently; this block is that silence, spoken.\\n` +\n ` Fix Option 1: put the \\`cd\\` first, literal path, SAME command: cd /abs/path && <the rest>\\n` +\n ` Fix Option 2: drop the \\`cd\\` — ${tree.root} is where the command is judged anyway.\\n` +\n ` Fix Option 3: if the SECOND \\`cd\\` was there to point a tool at a directory, use that tool's own\\n` +\n ` directory flag instead — \\`git -C <dir>\\`, \\`tar -C <dir>\\`, \\`npm --prefix <dir>\\`,\\n` +\n ` \\`npm pack --pack-destination <dir>\\`, \\`pnpm --dir <dir>\\`. One \\`cd\\`, same result.\\n` +\n ` ONLY for a dir INSIDE this tree. \\`git -C <another tree>\\` is REFUSED to a subagent,\\n` +\n ` and is never the cure for a version skew — for that, tell the MAIN agent.\\n` +\n ` Fix Option 4: split it — run the work in one call, the \\`cd\\` in another (a \\`cd\\` alone still\\n` +\n ` moves nothing the guards judge; see EffectiveTree on why cwd cannot be assumed).`;\n return new BlockedResult(report);\n}\n\n/**\n * The KEYLESS bash guards, deliberately kept OUT of the config-driven rule set. They have no\n * webpieces.config.json entry at all, so passing them through checkConfigSync would make every\n * consumer's next Bash call a fault-Y block (\"this rule has no entry\") for a feature nobody opted into\n * — which is exactly what whole-repo-build-guard did on its first release. All of them act\n * unconditionally (whole-repo-build-guard's machine-local opt-in was ended by a human on issue #1494).\n * They still honour excludePaths, and they do not run in `rules` mode (code-style-only hook).\n */\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction keylessBashRules(loaded: LoadedConfig, mode: HookMode, governed: GovernedPath): readonly Rule[] {\n if (mode === 'rules') return [];\n return filterByExcludedPaths(\n loadKeylessBashRules(loaded.prGate.buildCommand), governed, loaded.excludePaths,\n );\n}\n\n// webpieces-disable no-function-outside-class -- sibling of run()/runBash() in this module; the whole runner is module-scope functions and a lone class for this one entry point would break the file's shape\nfunction runBashInternal(\n command: string,\n cwd: string,\n mode: HookMode,\n aiType: AiType,\n): BlockedResult | null {\n if (isL0CureCommand(command)) {\n logL0CureBypass(command, cwd);\n return null;\n }\n\n const loaded = loadConfigOrAllowInspection(command, cwd);\n // null = the config would not load AND this command only inspects → allow, see the helper.\n if (loaded === null) return null;\n if (loaded.configPath === null)\n return l0FaultAllows(command, aiType) ? null : configMissingBlock(cwd);\n\n const workspaceRoot = path.dirname(loaded.configPath);\n\n // WHICH TREE does this command act on? Not the shell's cwd: a `cd` OUT of the workspace is reset\n // by the harness and one INSIDE it persists, so neither can be assumed (see EffectiveTree).\n // ONE resolver answers this for the guards AND for force-to-root below, so the two can never\n // disagree about which tree you are in.\n const tree = new EffectiveTreeResolver().resolve(command, cwd, workspaceRoot);\n\n if (allowForeignTree(command, tree, workspaceRoot)) return null;\n\n // Honour excludePaths on the bash path too (not just Read/Edit): a command whose effective\n // cwd sits under an excluded tree (e.g. repositories/**) drops the whole guard set — matching how\n // runInternal/runRead treat file paths. The relative path is '' when there is no `cd` (root), which\n // matches no exclusion glob, so a plain command at the repo root is unaffected.\n const governedCwd = bashGovernedPath(tree, workspaceRoot);\n const rules = filterByExcludedPaths(\n filterByMode(new WorkflowHookRules().load(loaded).rules, mode, loaded.ruleRegistry),\n governedCwd,\n loaded.excludePaths,\n );\n const keyless = keylessBashRules(loaded, mode, governedCwd);\n if (rules.length === 0 && keyless.length === 0) return null;\n\n const locationBlock = l1LocationBlock(command, tree, aiType);\n if (locationBlock) return locationBlock;\n\n // Keep the feature-branch-guard cache warm on EVERY command (not just Write/Edit): the AI runs\n // far more bash than edits, so refreshing here means the guard's next file-edit check reads a\n // fresh status. Detached + fire-and-forget — never blocks the command. Only when the guard is\n // loaded (guards/all mode) and enabled, so a project that opted out never triggers git fetches.\n // Keyed on the JUDGED tree, so a worktree's cache is refreshed rather than the primary clone's.\n maybeRefreshMainSync(rules, tree.root, branchStateHangTimeout(loaded.rulesConfig));\n\n const groups = runBashRules([...rules, ...keyless], buildBashContext(command, tree));\n return bashPolicyResult(command, tree, loaded, groups);\n}\n\n// The bash report's subject line. It used to be the literal string `<bash>`, which told the agent\n// nothing; the command itself is what was blocked, so name it — truncated, because a heredoc-bearing\n// command can run to thousands of characters and the violation lines already carry the detail.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction commandLabel(command: string): string {\n const oneLine = command.replace(/\\s+/g, ' ').trim();\n const MAX = 100;\n return oneLine.length <= MAX ? oneLine : oneLine.slice(0, MAX) + '…';\n}\n\n// When a push/PR block fires AND the config exempts vendored/nested trees, surface the escape hatch the\n// AI cannot otherwise discover: git/gh run UNGUARDED inside those trees if it cd's there first (each is\n// governed by its own repo, not this one). Scoped to pr-creation-or-push-guard — for the other guards\n// \"cd into an exempt tree\" is not the remedy — and emitted only when such trees are actually configured,\n// so a repo without exemptions never sees the noise.\n//\n// The hint MUST state the precondition, not just the remedy. \"cd into it first\" is true only for a\n// LITERAL cd at the FRONT of the same command; `D=…; cd \"$D\"; git push` lands in the identical\n// directory and does NOT relocate the verdict. That used to be silent, then a near-miss paragraph\n// appended here; it is now misplacedCdBlock, which refuses the command outright — so by the time this\n// footer is reached, any `cd` in the command is already known to be leading and literal. The wording\n// still states the shape, because this is where an agent LEARNS it, before writing the next command.\n// webpieces-disable no-function-outside-class -- sibling of the module-scope runner helpers; the whole file is functions and a lone class here would break its shape\nfunction exemptTreesHint(groups: readonly RuleGroup[], exemptGuards: readonly string[]): string {\n if (exemptGuards.length === 0) return '';\n if (!groups.some((g: RuleGroup): boolean => g.ruleName === 'pr-creation-or-push-guard'))\n return '';\n\n return (\n `\\n\\nℹ️ Working in a nested repo under one of these exempt trees (${exemptGuards.join(', ')})? ` +\n `Put a LITERAL \\`cd\\` at the FRONT of the SAME command — \\`cd /abs/path/to/repo && git push\\` — and git/gh ` +\n `run normally there: the webpieces guards do NOT govern them (each is its own repo).` +\n `\\n \\`cd <literal path> && <work>\\` is the ONE shape that moves where a command is judged. A \\`cd\\` ` +\n `anywhere else in the line, or a non-literal target like \\`cd \"$DIR\"\\`, is refused outright rather than ` +\n `judged from somewhere you did not intend.`\n );\n}\n\n// webpieces-disable no-function-outside-class -- runner result assembly is a pure orchestration helper\nfunction bashPolicyResult(command: string, tree: EffectiveTree, loaded: LoadedConfig, groups: readonly RuleGroup[]): BlockedResult | null {\n const workspaceRoot = path.dirname(loaded.configPath!);\n if (groups.length === 0) {\n // Record the ALLOW only for git/gh commands — the operations the bash guards actually reason\n // about (branch create, commit, push, merge, PR). Skipping ls/cat/grep keeps the audit log\n // focused (the whole point of the log is \"why did/didn't a guard fire?\"). Blocks are always\n // logged below.\n if (/\\b(?:git|gh)\\b/.test(command)) {\n logGuardDecision(\n tree.root,\n new GuardDecision(\n '-',\n 'Bash',\n command,\n branchForLog(tree.root),\n 'ALLOW',\n 'no bash-guard block',\n '-',\n L0_FAULT_NONE,\n MATRIX_L2_UNROWED,\n ),\n );\n }\n return null;\n }\n\n const ruleNames = groups.map((g: RuleGroup): string => g.ruleName).join(',');\n logGuardDecision(\n tree.root,\n new GuardDecision(\n ruleNames,\n 'Bash',\n command,\n branchForLog(tree.root),\n 'BLOCK_AI_CURE',\n 'bash-guard block',\n '-',\n L0_FAULT_NONE,\n MATRIX_L2_UNROWED,\n ),\n );\n const report =\n new ExcludedPathEscapeHint(workspaceRoot, tree.effectiveCwd).render(\n command,\n loaded.excludePaths,\n ) +\n formatReport(commandLabel(command), groups, BASH_SUBJECT) +\n exemptTreesHint(groups, loaded.excludePaths.paths);\n return new BlockedResult(report);\n}\n\n// webpieces-disable no-function-outside-class -- orchestration helper for the explicit foreign-repository exemption\nfunction allowForeignTree(command: string, tree: EffectiveTree, workspaceRoot: string): boolean {\n if (tree.kind === 'foreign') {\n logGuardDecision(\n workspaceRoot,\n new GuardDecision(\n '-',\n 'Bash',\n command,\n branchForLog(workspaceRoot),\n 'ALLOW_EXEMPT',\n 'foreign git repo (out of scope)',\n '-',\n L0_FAULT_NONE,\n new MatrixRef('L1', '1'),\n ),\n );\n return true;\n }\n\n return false;\n}\n"]}
@@ -411,7 +411,7 @@ class VersionSyncGuard {
411
411
  ` 1. Release \`${branch}\` from this worktree (git refuses to check out a branch another`,
412
412
  ` worktree holds), then in the main tree: \`git switch ${branch} && pnpm install\` —`,
413
413
  ` that install puts the branch's OWN pinned release in charge of it.`,
414
- ` 2. Make the fix there and publish it with \`pnpm wp-upsert-hotfix-pr\`.`,
414
+ ` 2. Make the fix there and publish it with \`pnpm wp-upsert-hotfix-pr <tracker> <number>\`.`,
415
415
  ];
416
416
  }
417
417
  /**
@@ -426,7 +426,7 @@ class VersionSyncGuard {
426
426
  ` > ${this.show(quartet.worktree.pinned).trim()} — production's release — while the main tree ${tree.mainRoot} runs ${this.show(quartet.main.installed).trim()}.`,
427
427
  ` > A hotfix cannot run in a linked worktree, and its pin must not be raised. Please do this`,
428
428
  ` > hotfix in the MAIN tree: check \`${branch}\` out there, \`pnpm install\`, make the fix, and`,
429
- ` > publish it with \`pnpm wp-upsert-hotfix-pr\`. Do NOT redo it in another worktree.`,
429
+ ` > publish it with \`pnpm wp-upsert-hotfix-pr <tracker> <number>\`. Do NOT redo it in another worktree.`,
430
430
  ` Do NOT retry this call — RETRYING IS THE BUG. It re-fires this identical deny and buries the`,
431
431
  ` ask above; one subagent did it 13 times, 25 across that whole session.`,
432
432
  ...(aiType === 'codex' ? this.waitLines(aiType)
@@ -1 +1 @@
1
- {"version":3,"file":"version-sync.js","sourceRoot":"","sources":["../../../../../../packages/tooling/agent-workflow-rules/src/core/version-sync.ts"],"names":[],"mappings":";;;;AACA,iDAA0C;AAC1C,mDAA6B;AAC7B,8DAAuE;AAEvE,0DAA6D;AAC7D,sEAA+D;AAE/D,iEAAgE;AAChE,6DAA2F;AAE3F;;;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O,CAAC,QAAQ,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,iBAAiB,qCAAgB,EAAE,CAAC,CAAC;YACzH,KAAK,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;QACnF,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,MAAM,sEAAsE,CAAC,CAAC;YAC3G,KAAK,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;YAC7F,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,IAAI,CAAC,OAAsB;QAC/B,OAAO,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;CACJ;AAxiBD,4CAwiBC","sourcesContent":["import { AiType } from '@webpieces/hook-runtime';\nimport { spawnSync } from 'child_process';\nimport * as path from 'path';\nimport { DETACHED_HEAD, gitCheckout } from '@webpieces/tooling-common';\n\nimport { WORKSPACE_MANIFEST } from '@webpieces/rules-config';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { EffectiveTree } from '@webpieces/hook-runtime';\nimport { ReadOnlyInspectionScan } from './read-only-inspection';\nimport { UMBRELLA_PACKAGE, VersionQuartet, WebpiecesVersions } from './webpieces-versions';\n\n/**\n * L1 row 8 — a tree may not be worked in while its `@webpieces` version disagrees with the MAIN tree's.\n *\n * ─── WHY THIS EXISTS, and what it replaces ─────────────────────────────────────────────────────────\n * The guard hooks are registered ABSOLUTE (`$CLAUDE_PROJECT_DIR/...`), so the MAIN tree governs every\n * tree. That is not a new imposition — it is what was always happening, because a linked worktree has no\n * `node_modules` and ai-hook.sh's upward walk already executed the main tree's binary. The design now\n * says so out loud, which makes ONE case newly important: a worktree whose branch pins a DIFFERENT\n * release is being linted, validated and built by a release it never asked for.\n *\n * This guard makes that case LOUD instead of silent. It replaces `CoordinatorWorktreeGuard`, and the\n * replacement is strictly better on the axis that matters: the old guard keyed off WHO was asking\n * (coordinator vs subagent), and agent identity was measured untrustworthy — a worktree-isolated agent\n * whose tree is auto-reaped at a turn boundary silently resumes with its cwd on the primary clone\n * (reproduced twice, 2026-08-10). This guard keys off the PATH the command acts on, which cannot lie.\n *\n * ─── IT EXISTS TO STOP A LOOP, not to enforce tidiness ─────────────────────────────────────────────\n * A main/worktree manifest mismatch is exactly the shape that produced the founding incident: an agent\n * is shown a fault measured against one tree, runs the prescribed cure in another, the cure succeeds,\n * nothing the guard measures changes, and the guard re-denies. Five identical no-op `pnpm install`s and\n * a fabricated theory about the harness later, a human had to untangle it. Firing EARLY, with a message\n * that names all the versions and all their files, is the whole point. Any future proposal to soften\n * this to a warning must answer: what stops the five-install loop instead?\n *\n * ─── Never a deadlock ──────────────────────────────────────────────────────────────────────────────\n * Two structurally independent escapes, and neither depends on an allowlist regex staying in step:\n * 1. WORK IN THE MAIN TREE — a main-tree-targeted command cannot classify as `worktree`, so it never\n * reaches this guard at all. No allowlist entry can break it because none is involved.\n * 2. EDIT THE MANIFESTS — `pnpm-workspace.yaml` / `package.json` edits are carved out in the runner\n * (`runInternal`, beside the `webpieces.config.json` pass) and on the L0 allowlist\n * (`MANIFEST_FILENAMES` / `isAllowed`), so the cure is typable from inside the block.\n * Reads and read-only inspection are never blocked either, so an agent can always look before it fixes.\n *\n * THAT SECOND ESCAPE WAS FICTION UNTIL 2026-08-20, and this docblock asserted it anyway. Only\n * `CONFIG_FILENAME` was ever carved out, so the one cure the report told a blocked agent to perform —\n * raise this tree's pin — was itself blocked. It is real now, and the `main-ahead` branch of `fixLines`\n * is what spends it. A future edit that narrows either carve-out has to change this text too.\n *\n * ─── The MAIN tree is `tree.mainRoot`, never `tree.governedRoot` ───────────────────────────────────\n * The two differ for exactly the reader this guard is for. `governedRoot` is walked up from the payload\n * cwd to the nearest `webpieces.config.json`, and that file is TRACKED — a linked worktree has its own.\n * So for an agent resident in a worktree `governedRoot` IS the worktree, and comparing it against\n * `tree.root` compared the tree with ITSELF: trivially in sync, guard silent. `mainRoot` is git's\n * `<git-common-dir>/..`, i.e. the clone whose `node_modules` actually supplies the judging binary, and\n * it is the same answer from every checkout. Measured 2026-08-10: a worktree on 0.4.624 with its own\n * install, a main clone on 0.4.616, and not one word from this guard.\n */\n/** One version reduced to what an order compare needs. Data-only → a class, per CLAUDE.md. */\nclass VersionParts {\n constructor(\n /** The numeric core, most-significant first. */\n readonly core: readonly number[],\n /** The pre-release suffix INCLUDING its leading `-`, or '' for a plain release. */\n readonly pre: string,\n ) {}\n}\n\n/**\n * WHICH of the five states this skew is. The whole point of naming them is that they do NOT share a\n * cure, and printing the wrong one is what walked a real agent backwards through a downgrade:\n *\n * `main-inconsistent` — the MAIN tree disagrees with ITSELF (its pin ≠ its own node_modules). Nothing\n * about this worktree is wrong; only the main agent can fix it, with one install.\n * `bump` — this branch RAISED the pin on purpose. The deliverable is the pin, so every\n * ordinary cure would revert it. Main has to come up to meet it.\n * `main-ahead` — the governing tree already RUNS a newer release than this tree's pin asks for.\n * This is the common case, and it is the ONE case the worktree fixes ITSELF, by\n * raising its own pin. No escalation, nobody to ask, nothing to wait for.\n * `worktree-stale` — every PIN agrees and so does main's install; only this tree's OWN node_modules\n * lags. The one state where a bare `pnpm install` HERE is exactly right.\n * `main-behind` — main is genuinely older and must move forward. Only the main agent can pull it.\n * `hotfix` — this tree is on a `/hotfix/` branch, cut from the PRODUCTION sha, so its older\n * pin is the release production runs and is RIGHT. Raising it (the `main-ahead`\n * cure) would ship a webpieces upgrade inside a production hotfix (issue #1371).\n * A hotfix is worked in the MAIN tree, where its own pinned release governs it.\n */\ntype SkewCase = 'main-inconsistent' | 'hotfix' | 'bump' | 'main-ahead' | 'worktree-stale' | 'main-behind';\n\nexport class VersionSyncGuard {\n private readonly inspection = new ReadOnlyInspectionScan();\n private readonly versions = new WebpiecesVersions();\n private readonly branches = new BranchIdentity();\n\n /**\n * True when this tree is a linked worktree whose webpieces version disagrees with the main tree's.\n * This is the `V` dimension of the L1 matrix; the runner asks it for EVERY Bash call so the answer\n * lands in the audit log even when nothing blocks.\n */\n skewed(tree: EffectiveTree): boolean {\n if (!this.applies(tree)) return false;\n return !this.quartetFor(tree).inSync;\n }\n\n /** The deny report, or null to allow. */\n block(command: string, tree: EffectiveTree, aiType: AiType): string | null {\n if (!this.applies(tree)) return null;\n if (this.inspection.isReadOnlyInspection(command)) return null;\n if (this.isCureOrLook(command)) return null;\n const quartet = this.quartetFor(tree);\n if (quartet.inSync) return null;\n return this.report(tree, quartet, aiType);\n }\n\n /**\n * Commands that must pass EVEN WHILE THIS GUARD IS BLOCKING, because they are how you get unblocked\n * — or how you look at the tree first.\n *\n * `ReadOnlyInspectionScan` deliberately excludes git and gh OUTRIGHT (\"the guards exist to police\n * git, and read-only git is not a line worth drawing while flying blind\"), which is right for the\n * guards that police git but WRONG here: this guard's own prescribed cure is `git pull` in both\n * trees. Without this carve-out the guard would deny the exact command it tells the reader to run —\n * the single failure shape this repo has been burned by most often, and the reason the deny text is\n * allowed to promise \"STILL ALLOWED HERE: ... pnpm install, git pull/fetch\".\n *\n * Deliberately NARROW: fetching, pulling and installing cannot make a skew worse, and every one of\n * them moves the tree toward agreement. Anything that BUILDS, TESTS or COMMITS is still blocked,\n * because those are the operations that would be judged by the wrong release.\n */\n private isCureOrLook(command: string): boolean {\n const words = command.trim().split(/\\s+/);\n const head = words[0] ?? '';\n const sub = words[1] ?? '';\n if (head === 'git' || head === 'gh') {\n // `git -C <dir> <sub>` names its own directory; take the first non-flag word after it.\n const subcommand = sub === '-C' ? (words[3] ?? '') : sub;\n return ['pull', 'fetch', 'status', 'log', 'diff', 'show', 'branch', 'rev-parse', 'worktree'].includes(subcommand);\n }\n return (head === 'pnpm' || head === 'npm') && (sub === 'install' || sub === 'i');\n }\n\n /**\n * Is there a cross-tree comparison to make at all? TWO cheap conditions, no file read behind either:\n *\n * • K is `worktree` — git's `--git-dir ≠ --git-common-dir`, so a repo with no linked worktrees can\n * never reach the manifests. (In the primary clone this is also structural escape #1: \"do the\n * work in the main tree\" needs no allowlist entry to keep working.)\n * • the two roots are DIFFERENT directories — a tree compared with itself is not a skew, it is the\n * single-tree pin-vs-install question the L0 drift guard already owns.\n */\n private applies(tree: EffectiveTree): boolean {\n return tree.kind === 'worktree'\n && path.resolve(tree.mainRoot) !== path.resolve(tree.root);\n }\n\n /** Public so the runner can log all four versions on ALLOW as well as on BLOCK (audit, not just deny). */\n quartetFor(tree: EffectiveTree): VersionQuartet {\n return this.versions.quartet(tree.mainRoot, tree.root);\n }\n\n // Short on purpose — L0 ran a deliberate message diet and these blocks regress into a wall of text\n // if each one argues its case. State the skew, show every version WITH its file, give the git cure\n // first, then the two structural escapes, then what is still allowed.\n private report(tree: EffectiveTree, quartet: VersionQuartet, aiType: AiType): string {\n const skew = this.classify(tree, quartet);\n // The two SELF-SERVE cases print NO escalation, and that omission is the deliverable rather than\n // a saving: an escalation block on a cure the reader can perform HERE teaches it to stop and wait\n // for a main agent who has nothing to do. The other three genuinely need the main tree to move.\n const selfServe = skew === 'main-ahead' || skew === 'worktree-stale';\n const escalation = selfServe ? []\n : skew === 'hotfix' ? ['', ...this.hotfixEscalationLines(tree, quartet, aiType)]\n : ['', ...this.escalationLines(tree, quartet, skew, aiType)];\n return [\n `❌ @webpieces version SKEW — this worktree and the main tree disagree, so work here is blocked.`,\n '',\n ...this.versionLines(tree, quartet),\n '',\n ` Whichever tree's hooks are live, one of these two releases lints, validates and builds`,\n ` this worktree — and it may be the one this manifest does not ask for.`,\n '',\n ...this.fixLines(tree, quartet, skew),\n ...escalation,\n '',\n ` STILL ALLOWED HERE: every Read, read-only inspection, \\`pnpm install\\`, \\`git pull\\`/\\`fetch\\`,`,\n ` and edits to pnpm-workspace.yaml / package.json / webpieces.config.json.`,\n ` Do NOT lower the MAIN tree's pin to match — that downgrades every tree, including this`,\n ` session's own governor.`,\n ].join('\\n');\n }\n\n /**\n * WHICH of the five states this is — asked ONCE, so the FIX block and the escalation block can never\n * describe two different diagnoses of the same skew.\n *\n * Order is not arbitrary. `main-inconsistent` is asked FIRST because it is a fault in the governing\n * tree itself: comparing this worktree against a tree that disagrees with itself picks a direction\n * out of two numbers that are not yet one answer. `bump` next, because a deliberate raise is the one\n * shape where the direction is real but every ordinary cure is harmful.\n */\n private classify(tree: EffectiveTree, quartet: VersionQuartet): SkewCase {\n const mainPin = quartet.main.pinned;\n const mainInstalled = quartet.main.installed;\n if (mainPin !== null && mainInstalled !== null && mainPin !== mainInstalled) return 'main-inconsistent';\n const wtPin = quartet.worktree.pinned;\n const worktreeStale = mainInstalled !== null && wtPin === mainInstalled && quartet.worktree.installed !== null;\n // A hotfix whose pins AGREE and only lags its own install is plain `worktree-stale`: installing\n // the pin it already has ships nothing new. Every other hotfix skew is a pin production chose.\n if (!worktreeStale && this.isHotfix(tree)) return 'hotfix';\n if (this.isDeliberateBump(tree, quartet)) return 'bump';\n if (worktreeStale) return 'worktree-stale';\n return this.compare(mainInstalled, wtPin) > 0 ? 'main-ahead' : 'main-behind';\n }\n\n /**\n * SEMVER ORDER of two versions: 1 when `a` is newer, -1 when older, 0 when equal OR undecidable.\n *\n * 0 is the FAIL-SAFE answer and every caller must read it as \"no opinion\": an unreadable leg, a\n * dist-tag, two different pre-releases, or build metadata (which carries no precedence) all land\n * there, and `classify` then falls to `main-behind`, the branch that ASKS rather than acts. Guessing\n * a direction is how a downgrade gets prescribed, and this repo has already paid for that once.\n *\n * The same rules the shim's awk compare uses, so L0 and L1 cannot order one pair two ways: build\n * metadata stripped, numeric cores compared component-wise, and a pre-release sorting BELOW its\n * release.\n */\n private compare(a: string | null, b: string | null): number {\n if (a === null || b === null || a === b) return 0;\n const aParts = this.parts(a);\n const bParts = this.parts(b);\n if (aParts === null || bParts === null) return 0;\n const width = Math.max(aParts.core.length, bParts.core.length);\n for (let i = 0; i < width; i++) {\n const av = aParts.core[i] ?? 0;\n const bv = bParts.core[i] ?? 0;\n if (av !== bv) return av < bv ? -1 : 1;\n }\n if (aParts.pre === bParts.pre) return 0;\n if (aParts.pre !== '' && bParts.pre === '') return -1;\n if (aParts.pre === '' && bParts.pre !== '') return 1;\n return 0;\n }\n\n /** One version split into its numeric core and its pre-release suffix, or null if it is not numeric. */\n private parts(version: string): VersionParts | null {\n const noBuild = version.replace(/\\+.*$/, '');\n const core = noBuild.replace(/-.*$/, '');\n if (!/^[0-9]+(\\.[0-9]+)*$/.test(core)) return null;\n return new VersionParts(\n core.split('.').map((n: string): number => Number(n)),\n noBuild.slice(core.length),\n );\n }\n\n /**\n * The cure list, which is NOT the same list in both directions — but which, in BOTH directions, is a\n * list of things the reader ASKS FOR rather than runs.\n *\n * The ordinary skew is two trees sitting on different commits of main. The pin is tracked, so putting\n * both trees on the same commit and installing genuinely converges them. That cure is WRONG, and worse\n * than useless, when the branch bumped the pin ON PURPOSE: pulling would revert the deliverable, and\n * an install cannot move a pin in either tree. Printing the git cure first in that case is what sent a\n * real upgrade agent round the loop below.\n *\n * WHAT THIS BLOCK IS NOT ALLOWED TO SAY, in either branch: `git -C <the main tree> pull`. Two defects\n * rode on that one line, and it was printed ABOVE the escalation block, so it was the first thing read.\n * (a) A worktree-isolated SUBAGENT — the overwhelmingly common reader of this deny — CANNOT run\n * cross-tree git at all; the harness refuses it (shim-deny-reason.ts records the same\n * measurement). The one printed cure was the one thing the reader could not perform.\n * (b) A bare `git pull` acts on whatever branch that tree currently has checked out, and the primary\n * clone is normally sitting on a feature branch. It pulls the feature branch, the manifest never\n * moves, the pin never converges, and this guard fires again. The cure has to NAME main:\n * `cd <main> && git checkout main && git pull`.\n * So every step is prefixed `Tell main agent:` — INDIVIDUALLY, not under one shared header. That\n * repetition is deliberate and is the deliverable: a reader who skims exactly one of these lines must\n * still see it is not their own action. Do not factor it out.\n *\n * The FIX block still prints ABOVE the escalation block, on purpose. Moving it below would split the\n * numbered steps from the versions they refer to, and the do-not-retry beat has to stay last and stay\n * unique — a second shouted beat competing with it is exactly the wall-of-text regression the L0\n * message diet exists to prevent.\n * Labelling carries the \"not yours to run\" fact instead, which is what the caps header does.\n */\n private fixLines(tree: EffectiveTree, quartet: VersionQuartet, skew: SkewCase): readonly string[] {\n if (skew === 'main-inconsistent') return this.mainInconsistentFix(tree, quartet);\n if (skew === 'hotfix') return this.hotfixFix(tree, quartet);\n if (skew === 'main-ahead') return this.mainAheadFix(tree, quartet);\n if (skew === 'worktree-stale') {\n // Every PIN agrees, and so does main's install. The ONLY disagreeing leg is this tree's own\n // node_modules — so this is the one state where a bare `pnpm install` HERE is not a guess,\n // is not a downgrade, and needs nobody's permission. Saying so plainly matters because the\n // other cases all warn AGAINST reaching for it.\n return [\n ` FIX — THIS ONE IS YOURS, AND IT IS ONE COMMAND. Every pin already agrees; only this`,\n ` tree's own node_modules lags at ${this.show(quartet.worktree.installed).trim()}.`,\n ` 1. Run \\`pnpm install\\` HERE, in ${tree.root}.`,\n ` Nothing needs to move in the main tree and there is nobody to ask.`,\n ];\n }\n if (skew === 'bump') {\n return [\n ` THIS BRANCH BUMPED THE PIN ON PURPOSE (${this.show(quartet.main.pinned).trim()} → ${this.show(quartet.worktree.pinned).trim()}), so the usual cures do NOT apply:`,\n ` • \\`pnpm install\\` cannot help in EITHER tree — an install materializes a pin, never moves one.`,\n ` • \\`git pull\\` here would revert the bump, which is the whole deliverable.`,\n ` • Wiping this tree's node_modules does NOT help — the two PINS still disagree, and the`,\n ` L0 drift guard blocks in this guard's place.`,\n ` FIX — YOU CANNOT DO THIS FROM HERE. BOTH ways out need the MAIN tree, and cross-tree`,\n ` git is REFUSED to a subagent, so every step below is something you ASK FOR, not run:`,\n ` 1. Tell main agent: this task has to be redone in the MAIN tree ${tree.mainRoot}`,\n ` — a version bump cannot be done in a worktree at all.`,\n ` 2. Tell main agent: OR raise the MAIN tree's pin to ${this.show(quartet.worktree.pinned).trim()} in`,\n ` ${tree.mainRoot}/${WORKSPACE_MANIFEST} and run \\`pnpm install\\` there.`,\n ` 3. Tell main agent: to tell you when that is complete.`,\n ` THEN AND ONLY THEN will this worktree — and every other subagent — work again.`,\n ];\n }\n return [\n ` FIX — YOU CANNOT DO THIS FROM HERE. Cross-tree git is REFUSED to a subagent, and a bare`,\n ` \\`git pull\\` moves whatever branch that tree is on — so the cure must NAME main, in main:`,\n ` 1. Tell main agent: \\`cd ${tree.mainRoot} && git checkout main && git pull\\``,\n ` 2. Tell main agent: then run \\`pnpm install\\` in ${tree.mainRoot}`,\n ` 3. Tell main agent: then report back what \\`ls ${tree.mainRoot}/node_modules/@webpieces\\``,\n ` shows, so we know whether the hook shim needs re-upgrading too.`,\n ` 4. Tell main agent: to tell you when ALL of that is complete.`,\n ` THEN AND ONLY THEN will this worktree — and every other subagent — work again.`,\n ` The two structural escapes, if converging the trees is not what the coordinator wants:`,\n ` • Do the work in the MAIN tree instead — it is never blocked by this guard.`,\n ` • Or use a separate CLONE, not a worktree, if this tree genuinely needs a DIFFERENT`,\n ` version: a clone gets its own governance. A worktree MAY have its own node_modules, so`,\n ` installing here is fine; what it may not have is a DIFFERENT @webpieces version.`,\n ];\n }\n\n /**\n * CASE A — the MAIN tree disagrees with ITSELF: its `node_modules` is on one version while its own\n * `pnpm-workspace.yaml` pins another. Nothing in this worktree is wrong, and nothing this worktree\n * does can help.\n *\n * The cure is deliberately the SMALL one. The generic branch prints `git checkout main && git pull`\n * first, and that is over-prescribed here: both halves of the disagreement are already in that tree,\n * so an install materializes the pin it already has and the skew is gone. Printing the pull as well\n * invites a main agent to move main's commit for a fault that is not about main's commit at all.\n */\n private mainInconsistentFix(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n return [\n ` THE MAIN TREE IS INTERNALLY INCONSISTENT — its node_modules is on ${this.show(quartet.main.installed).trim()} but its own`,\n ` pin says ${this.show(quartet.main.pinned).trim()}. That is not this worktree's fault and not this worktree's to fix.`,\n ` FIX — YOU CANNOT DO THIS FROM HERE. Cross-tree git is REFUSED to a subagent:`,\n ` 1. Tell main agent: run \\`pnpm install\\` in ${tree.mainRoot} — no pull is needed, both`,\n ` halves are already in that tree.`,\n ` 2. Tell main agent: to tell you when that is complete.`,\n ` THEN AND ONLY THEN will this worktree — and every other subagent — work again.`,\n ];\n }\n\n /**\n * CASE B — the MAIN tree already RUNS a newer release than this tree's pin asks for. This is the\n * common case, and it is the one the old message got exactly backwards.\n *\n * It is the ONLY case a worktree fixes ITSELF. Nothing needs to move in the main tree — the version\n * the guards will judge this tree by is already installed there — so the entire fix is to raise this\n * tree's own pin to match, which is a one-line edit to a TRACKED file this tree owns. Printing an\n * escalation here (as every earlier revision did) tells an agent to stop and wait for a main agent\n * who has nothing to do, which is how a five-minute edit became a stalled turn.\n *\n * The edit is typable from inside the block because pnpm-workspace.yaml is on the L0 allowlist and\n * carved out in the runner's edit path. That carve-out and this text ship together on purpose: a\n * message prescribing a blocked call is the failure shape this repo has been burned by most often.\n *\n * ON A DETACHED HEAD the edit has no branch to belong to, so it is not offered — an edit that\n * survives nothing is worse than no edit. Get onto a branch, then read this message again.\n */\n private mainAheadFix(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n const target = this.show(quartet.main.installed).trim();\n if (this.isDetachedHead(tree.root)) {\n return [\n ` FIX — GET ONTO A BRANCH FIRST. \\`git branch --show-current\\` is empty in ${tree.root}, so`,\n ` HEAD is DETACHED and the one-line pin edit below would belong to no branch at all.`,\n ` 1. Check out a branch here, then re-run this command.`,\n ` 2. The fix is then yours alone: set ${WORKSPACE_MANIFEST}'s catalog pin to ${target}.`,\n ` Nothing needs to move in the main tree — it already runs ${target}.`,\n ];\n }\n const install = quartet.worktree.installed !== null\n ? [` 2. Then run \\`pnpm install\\` HERE — this tree has its own node_modules, so it must be`,\n ` materialized at ${target} too.`]\n : [` 2. Nothing else. This tree has no node_modules of its own, so there is nothing to install.`];\n return [\n ` FIX — THIS ONE IS YOURS, AND YOU CAN DO IT RIGHT HERE. The main tree is AHEAD: it already`,\n ` runs ${target}, so nothing has to move there and there is nobody to ask.`,\n ` 1. Edit ${tree.root}/${WORKSPACE_MANIFEST} — the catalog line for`,\n ` ${UMBRELLA_PACKAGE} — and set it to ${target}. That edit is ALLOWED`,\n ` right now, from inside this block.`,\n ...install,\n ` Do NOT run a bare \\`pnpm install\\` first: this tree's pin is the STALE side, so installing`,\n ` before the edit materializes the OLD release and this guard fires again.`,\n ];\n }\n\n /**\n * Is this tree checked out on a `/hotfix/` branch? BranchIdentity's ONE exact, case-sensitive\n * predicate, asked of the branch GitCheckout reads off this tree's own HEAD — no git process.\n */\n private isHotfix(tree: EffectiveTree): boolean {\n const branch = gitCheckout.branch(tree.root);\n return branch !== null && this.branches.isHotfix(branch);\n }\n\n /**\n * THE HOTFIX CASE (issue #1371). Exempting a hotfix worktree from this block was the first idea, and\n * it is unsafe for the reason this guard exists: the MAIN tree's newer release would then govern the\n * hotfix — validating its production-era webpieces.config.json against rules that release requires\n * (a new rule with no entry fails the config load) and linting its code by rules it never pinned — so\n * the hotfix would trade this block for a config fault whose cure is ALSO a webpieces change shipped\n * to production. And the cure this report would otherwise print, `main-ahead`'s \"raise your pin\",\n * ships exactly that upgrade. So the block stays, and the cure is the one that keeps production's\n * release: work the hotfix in the MAIN tree, where its own pin governs it.\n */\n private hotfixFix(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n const branch = gitCheckout.branch(tree.root) ?? '<hotfix branch>';\n return [\n ` THIS IS A /hotfix/ BRANCH (\\`${branch}\\`), cut from the production sha. Its pin`,\n ` ${this.show(quartet.worktree.pinned).trim()} is the release production runs, so it is RIGHT — do NOT raise it to`,\n ` match main: that ships a webpieces upgrade inside a production hotfix.`,\n ` A HOTFIX RUNS IN THE MAIN TREE, never in a linked worktree: here the main tree's newer release`,\n ` governs this branch, and judges its production-era config and code by rules it never pinned.`,\n ` FIX — move the hotfix to the main tree ${tree.mainRoot}:`,\n ` 1. Release \\`${branch}\\` from this worktree (git refuses to check out a branch another`,\n ` worktree holds), then in the main tree: \\`git switch ${branch} && pnpm install\\` —`,\n ` that install puts the branch's OWN pinned release in charge of it.`,\n ` 2. Make the fix there and publish it with \\`pnpm wp-upsert-hotfix-pr\\`.`,\n ];\n }\n\n /**\n * The forwardable ask for the hotfix case. NOT `escalationLines`: its afterward beat asks for a FRESH\n * worktree subagent to redo the task once main is synced, which is the one place a hotfix must not go.\n */\n private hotfixEscalationLines(tree: EffectiveTree, quartet: VersionQuartet, aiType: AiType): readonly string[] {\n const branch = gitCheckout.branch(tree.root) ?? '<hotfix branch>';\n return [\n ` SUBAGENT? Cross-tree git is REFUSED to you. Forward this to your coordinator verbatim:`,\n ` > My worktree ${tree.root} is on /hotfix/ branch \\`${branch}\\`, pinned to @webpieces`,\n ` > ${this.show(quartet.worktree.pinned).trim()} — production's release — while the main tree ${tree.mainRoot} runs ${this.show(quartet.main.installed).trim()}.`,\n ` > A hotfix cannot run in a linked worktree, and its pin must not be raised. Please do this`,\n ` > hotfix in the MAIN tree: check \\`${branch}\\` out there, \\`pnpm install\\`, make the fix, and`,\n ` > publish it with \\`pnpm wp-upsert-hotfix-pr\\`. Do NOT redo it in another worktree.`,\n ` Do NOT retry this call — RETRYING IS THE BUG. It re-fires this identical deny and buries the`,\n ` ask above; one subagent did it 13 times, 25 across that whole session.`,\n ...(aiType === 'codex' ? this.waitLines(aiType)\n : [` Nothing you can do from this tree clears it; the hotfix is done in the main tree.`]),\n ];\n }\n\n /**\n * Is HEAD DETACHED in this tree — i.e. is there no branch for a pin edit to belong to?\n *\n * Asked of GitCheckout, the one branch resolver (#1355): it answers an UNBORN branch with its name\n * (every freshly-created worktree is unborn until its first commit) and a detached HEAD with\n * DETACHED_HEAD, which is exactly the distinction case B needs.\n *\n * A git FAILURE is NOT detached, and the difference is load-bearing: GitCheckout answers null there,\n * never DETACHED_HEAD, so a tree git cannot read (no repo, git absent) is not told its HEAD is\n * detached — a confident diagnosis of a state nobody measured. It falls back to the ordinary branch\n * wording, whose worst case is prescribing an edit that turns out to be moot.\n */\n private isDetachedHead(root: string): boolean {\n return gitCheckout.branch(root) === DETACHED_HEAD;\n }\n\n /**\n * THE SUBAGENT CANNOT REACH THE MAIN TREE, so the message it is handed has to be the message it\n * FORWARDS. This used to be one sentence — \"report to your coordinator that one of you must move to\n * the other's version\" — with no command, no direction and nothing pasteable, and the result was a\n * subagent that correctly diagnosed the block, correctly escalated, and handed its coordinator a\n * request too vague to act on. Worse, the obvious guess (\"ask the coordinator to run `pnpm install`\n * in main\") is a NO-OP on a bump: it reinstalls main's own pin and nothing moves.\n *\n * So the escalation is rendered as literal text to forward, with the versions and the direction\n * already filled in. A human cannot sit with every agent; the deny has to carry the whole ask.\n *\n * The ask is ROUTED THROUGH THE MAIN AGENT rather than phrased as a command, and that distinction is\n * the whole point of this block. `git -C <mainRoot> pull` reads like something you run from wherever\n * you are standing — so a subagent reads it, tries it, and only then discovers that CROSS-TREE GIT IS\n * REFUSED to a worktree-isolated agent (same measurement shim-deny-reason.ts records: the harness\n * blocks `git -C <other tree>`, and it is git specifically). This skew needs a git pull in main, so\n * the one printed cure was the one thing this session cannot perform. Be precise about that and do\n * NOT overstate it into \"you cannot reach that tree at all\" — a local `cd <main> && pnpm install`\n * measurably DOES run, it simply cannot move main onto a different commit, which is what a skew\n * requires. The actor who can is the MAIN AGENT running in the MAIN git worktree, so the forwarded\n * text asks for exactly that — and asks to be TOLD WHEN IT IS DONE, because \"the work happened\" is\n * the event that unblocks this subagent and it has no way to observe it otherwise.\n *\n * And it has to refuse the RETRY, because forwarding is only half of what the subagent must do. One\n * measured subagent transcript re-fired this identical deny 13 TIMES (25 across the whole session,\n * counting two sibling subagents and two parent sessions): the subagent read it, escalated exactly\n * as asked — and then re-ran the blocked call. Every retry cost a round trip and pushed the one\n * message that mattered further up the scrollback. The block is not transient and no command from\n * this tree slips past it, so retrying is never a strategy; it is the bug.\n *\n * What it must NOT do is decide the agent's control flow. #679 first wrote this beat as \"STOP WORKING\n * NOW. Forwarding that message IS the end of your turn: make NO further tool calls\" — a turn-level\n * prescription, which `.claude/rules/never-tell-an-ai-to-end-its-turn.md` forbids (#902 deleted every\n * other one; this one survived because no spec rendered it — issue #1000). Refusing one futile\n * command is legitimate; ruling on when the turn ends is a judgement the agent is better placed to\n * make. So the beat names the retry, says why it is futile, and stops talking.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private escalationLines(tree: EffectiveTree, quartet: VersionQuartet, skew: SkewCase, aiType: AiType): readonly string[] {\n return [\n ` SUBAGENT? You cannot fix the main tree from here. Forward this to your coordinator verbatim:`,\n ` > My worktree ${tree.root} is on @webpieces ${this.show(quartet.worktree.pinned).trim()};`,\n ` > the main tree ${tree.mainRoot} is on ${this.show(quartet.main.pinned).trim()}.`,\n ...this.askLines(tree, quartet, skew),\n ...this.afterwardLines(aiType),\n ` Do NOT retry this call — RETRYING IS THE BUG. It re-fires this identical deny and buries the`,\n ` ask above; one subagent did it 13 times, 25 across that whole session.`,\n ...this.waitLines(aiType),\n ];\n }\n\n /**\n * What the coordinator does ONCE main is synced — and here the two harnesses need opposite answers.\n *\n * Codex runs every subagent in the coordinator's own checkout, so \"tell me when it is done so I can\n * continue\" is literally true: the same agent picks up where it stopped.\n *\n * Claude Code does NOT keep that tree for it. A worktree-isolated subagent that hands back with an\n * unchanged worktree has that worktree REAPED, and a subagent resumed afterwards (SendMessage) comes\n * back with its cwd on the PRIMARY clone — which happened to the first agent on issue #863 itself. So\n * asking to be resumed routes the work into the one tree it must never land in. The ask is therefore a\n * FRESH `isolation: \"worktree\"` subagent, and \"resume me\" / \"continue working\" must not appear.\n */\n private afterwardLines(aiType: AiType): readonly string[] {\n if (aiType === 'codex') {\n return [` > Tell me when that is complete so I can continue working.`];\n }\n return [\n ` > Once main is synced, spawn a FRESH isolation: \"worktree\" subagent to redo this task. Do NOT`,\n ` > message this agent again: my worktree is reaped on hand-back, and a re-messaged agent lands in the primary clone.`,\n ];\n }\n\n private waitLines(aiType: AiType): readonly string[] {\n if (aiType === 'codex') {\n // The three-move wait shape (never-tell-an-ai-to-end-its-turn.md): name the efficient option,\n // name the wasteful one, and say nothing about when a turn ends.\n return [\n ` Nothing you can do from this tree clears it. Be efficient with tokens: wait on the main`,\n ` agent's confirmation instead of re-running blocked calls to see whether it has cleared.`,\n ];\n }\n return [` Nothing you can do from this tree clears it; the coordinator redoes it in a fresh worktree.`];\n }\n\n /**\n * The forwardable ASK, one per case that needs one. `main-ahead` never reaches here — it has nothing\n * to ask for — so the three shapes below cover every escalating case. What happens AFTER the ask is\n * harness-specific and lives in {@link afterwardLines}, so none of these says \"tell me when\".\n *\n * The bump ask carries the upgrade sentence VERBATIM as Dean wrote it, because it answers the one\n * question an upgrade agent gets wrong: \"webpieces cannot be upgraded from a worktree\" is not a\n * missing permission it can route around, it is a property of who governs whom.\n */\n private askLines(tree: EffectiveTree, quartet: VersionQuartet, skew: SkewCase): readonly string[] {\n if (skew === 'bump') {\n return [\n ` > A \\`pnpm install\\` in main will NOT fix this — main's PIN has to move. Pick one:`,\n ` > (a) I redo this task in the MAIN tree (a version bump cannot be done in a worktree), or`,\n ` > (b) you TELL THE MAIN AGENT in the MAIN git worktree ${tree.mainRoot} to`,\n ` > raise main's catalog pin to ${this.show(quartet.worktree.pinned).trim()} and \\`pnpm install\\` there. I cannot reach that tree from here.`,\n ` If you are a subagent upgrading webpieces, STOP — only main agents in worktrees can do`,\n ` this. Otherwise your main agent must \\`git pull\\` main: main has an earlier version of`,\n ` webpieces pinned and must upgrade. You MUST tell the main agent to pull main and`,\n ` \\`pnpm install\\`.`,\n ];\n }\n if (skew === 'main-inconsistent') {\n return [\n ` > Please TELL THE MAIN AGENT in the MAIN git worktree ${tree.mainRoot} to run`,\n ` > \\`pnpm install\\` there — its node_modules is on ${this.show(quartet.main.installed).trim()} but its own pin says`,\n ` > ${this.show(quartet.main.pinned).trim()}, so no pull is needed. I cannot reach that tree from here.`,\n ];\n }\n return [\n ` > Please TELL THE MAIN AGENT in the MAIN git worktree ${tree.mainRoot} to run`,\n ` > \\`git checkout main && git pull && pnpm install\\` there — it must NAME main, since a bare`,\n ` > pull moves whatever branch that tree is on — so both trees are on the same release, and`,\n ` > to report what \\`ls node_modules/@webpieces\\` shows there. I cannot reach that tree from here.`,\n ];\n }\n\n /**\n * Did THIS BRANCH change the pin, as opposed to the two trees having drifted onto different commits?\n *\n * Only answerable now that both pin legs actually resolve — before the catalog reader followed YAML\n * anchors they both read null on the repos that pin via an anchor, so every skew looked alike and the\n * report could only ever print the one generic cure.\n *\n * Two git spawns worst case, on the BLOCK path only (this is never reached on an allow), and\n * best-effort: a git failure answers \"not a deliberate bump\", which falls back to the generic cure\n * that was the only text this report had before.\n */\n private isDeliberateBump(tree: EffectiveTree, quartet: VersionQuartet): boolean {\n if (quartet.main.pinned === null || quartet.worktree.pinned === null) return false;\n if (quartet.main.pinned === quartet.worktree.pinned) return false;\n return this.touchesWorkspaceFile(tree.root, ['status', '--porcelain', '--', WORKSPACE_MANIFEST])\n || this.touchesWorkspaceFile(tree.root, ['diff', '--name-only', 'origin/main...HEAD', '--', WORKSPACE_MANIFEST]);\n }\n\n private touchesWorkspaceFile(root: string, args: readonly string[]): boolean {\n const result = spawnSync('git', ['-C', root, ...args], { encoding: 'utf8' });\n return result.status === 0 && (result.stdout ?? '').trim() !== '';\n }\n\n // Every version WITH the file it came from. An agent that is told \"they disagree\" without being told\n // WHICH FILE to edit re-derives it by grepping, which is exactly the turn-burning this guard exists\n // to prevent. Unreadable legs are printed as `-` rather than omitted, so the reader can tell\n // \"this one is absent\" from \"I forgot to look\".\n private versionLines(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n const lines = [\n ` main pin ${this.show(quartet.main.pinned)} ${tree.mainRoot}/pnpm-workspace.yaml`,\n ` main installed ${this.show(quartet.main.installed)} ${tree.mainRoot}/node_modules/${UMBRELLA_PACKAGE}`,\n ` ^ the binary judging this very call`,\n ` this worktree ${this.show(quartet.worktree.pinned)} ${tree.root}/pnpm-workspace.yaml`,\n ];\n if (quartet.worktree.installed !== null) {\n lines.push(` its installed ${this.show(quartet.worktree.installed)} ${tree.root}/node_modules/${UMBRELLA_PACKAGE}`);\n lines.push(' ^ what nx, vitest and eslint load IN this tree');\n }\n const others = this.versions.otherWorktrees(tree.mainRoot, tree.root);\n if (others.length > 0) {\n lines.push(` NOTE ${others.length} other worktree(s) exist and are governed the same way — if they are`);\n lines.push(' skewed too, their agents are already mis-governed. Consider clones, or');\n lines.push(' serializing the work in the main tree.');\n }\n return lines;\n }\n\n private show(version: string | null): string {\n return (version ?? '-').padEnd(10);\n }\n}\n"]}
1
+ {"version":3,"file":"version-sync.js","sourceRoot":"","sources":["../../../../../../packages/tooling/agent-workflow-rules/src/core/version-sync.ts"],"names":[],"mappings":";;;;AACA,iDAA0C;AAC1C,mDAA6B;AAC7B,8DAAuE;AAEvE,0DAA6D;AAC7D,sEAA+D;AAE/D,iEAAgE;AAChE,6DAA2F;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,8FAA8F;AAC9F,MAAM,YAAY;IAGD;IAEA;IAJb;IACI,gDAAgD;IACvC,IAAuB;IAChC,mFAAmF;IAC1E,GAAW;QAFX,SAAI,GAAJ,IAAI,CAAmB;QAEvB,QAAG,GAAH,GAAG,CAAQ;IACrB,CAAC;CACP;AAuBD,MAAa,gBAAgB;IACR,UAAU,GAAG,IAAI,6CAAsB,EAAE,CAAC;IAC1C,QAAQ,GAAG,IAAI,sCAAiB,EAAE,CAAC;IACnC,QAAQ,GAAG,IAAI,mCAAc,EAAE,CAAC;IAEjD;;;;OAIG;IACH,MAAM,CA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AAE,CAAC;YACpB,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,MAAM,sEAAsE,CAAC,CAAC;YAC3G,KAAK,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;YAC7F,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,IAAI,CAAC,OAAsB;QAC/B,OAAO,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;CACJ;AAxiBD,4CAwiBC","sourcesContent":["import { AiType } from '@webpieces/hook-runtime';\nimport { spawnSync } from 'child_process';\nimport * as path from 'path';\nimport { DETACHED_HEAD, gitCheckout } from '@webpieces/tooling-common';\n\nimport { WORKSPACE_MANIFEST } from '@webpieces/rules-config';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { EffectiveTree } from '@webpieces/hook-runtime';\nimport { ReadOnlyInspectionScan } from './read-only-inspection';\nimport { UMBRELLA_PACKAGE, VersionQuartet, WebpiecesVersions } from './webpieces-versions';\n\n/**\n * L1 row 8 — a tree may not be worked in while its `@webpieces` version disagrees with the MAIN tree's.\n *\n * ─── WHY THIS EXISTS, and what it replaces ─────────────────────────────────────────────────────────\n * The guard hooks are registered ABSOLUTE (`$CLAUDE_PROJECT_DIR/...`), so the MAIN tree governs every\n * tree. That is not a new imposition — it is what was always happening, because a linked worktree has no\n * `node_modules` and ai-hook.sh's upward walk already executed the main tree's binary. The design now\n * says so out loud, which makes ONE case newly important: a worktree whose branch pins a DIFFERENT\n * release is being linted, validated and built by a release it never asked for.\n *\n * This guard makes that case LOUD instead of silent. It replaces `CoordinatorWorktreeGuard`, and the\n * replacement is strictly better on the axis that matters: the old guard keyed off WHO was asking\n * (coordinator vs subagent), and agent identity was measured untrustworthy — a worktree-isolated agent\n * whose tree is auto-reaped at a turn boundary silently resumes with its cwd on the primary clone\n * (reproduced twice, 2026-08-10). This guard keys off the PATH the command acts on, which cannot lie.\n *\n * ─── IT EXISTS TO STOP A LOOP, not to enforce tidiness ─────────────────────────────────────────────\n * A main/worktree manifest mismatch is exactly the shape that produced the founding incident: an agent\n * is shown a fault measured against one tree, runs the prescribed cure in another, the cure succeeds,\n * nothing the guard measures changes, and the guard re-denies. Five identical no-op `pnpm install`s and\n * a fabricated theory about the harness later, a human had to untangle it. Firing EARLY, with a message\n * that names all the versions and all their files, is the whole point. Any future proposal to soften\n * this to a warning must answer: what stops the five-install loop instead?\n *\n * ─── Never a deadlock ──────────────────────────────────────────────────────────────────────────────\n * Two structurally independent escapes, and neither depends on an allowlist regex staying in step:\n * 1. WORK IN THE MAIN TREE — a main-tree-targeted command cannot classify as `worktree`, so it never\n * reaches this guard at all. No allowlist entry can break it because none is involved.\n * 2. EDIT THE MANIFESTS — `pnpm-workspace.yaml` / `package.json` edits are carved out in the runner\n * (`runInternal`, beside the `webpieces.config.json` pass) and on the L0 allowlist\n * (`MANIFEST_FILENAMES` / `isAllowed`), so the cure is typable from inside the block.\n * Reads and read-only inspection are never blocked either, so an agent can always look before it fixes.\n *\n * THAT SECOND ESCAPE WAS FICTION UNTIL 2026-08-20, and this docblock asserted it anyway. Only\n * `CONFIG_FILENAME` was ever carved out, so the one cure the report told a blocked agent to perform —\n * raise this tree's pin — was itself blocked. It is real now, and the `main-ahead` branch of `fixLines`\n * is what spends it. A future edit that narrows either carve-out has to change this text too.\n *\n * ─── The MAIN tree is `tree.mainRoot`, never `tree.governedRoot` ───────────────────────────────────\n * The two differ for exactly the reader this guard is for. `governedRoot` is walked up from the payload\n * cwd to the nearest `webpieces.config.json`, and that file is TRACKED — a linked worktree has its own.\n * So for an agent resident in a worktree `governedRoot` IS the worktree, and comparing it against\n * `tree.root` compared the tree with ITSELF: trivially in sync, guard silent. `mainRoot` is git's\n * `<git-common-dir>/..`, i.e. the clone whose `node_modules` actually supplies the judging binary, and\n * it is the same answer from every checkout. Measured 2026-08-10: a worktree on 0.4.624 with its own\n * install, a main clone on 0.4.616, and not one word from this guard.\n */\n/** One version reduced to what an order compare needs. Data-only → a class, per CLAUDE.md. */\nclass VersionParts {\n constructor(\n /** The numeric core, most-significant first. */\n readonly core: readonly number[],\n /** The pre-release suffix INCLUDING its leading `-`, or '' for a plain release. */\n readonly pre: string,\n ) {}\n}\n\n/**\n * WHICH of the five states this skew is. The whole point of naming them is that they do NOT share a\n * cure, and printing the wrong one is what walked a real agent backwards through a downgrade:\n *\n * `main-inconsistent` — the MAIN tree disagrees with ITSELF (its pin ≠ its own node_modules). Nothing\n * about this worktree is wrong; only the main agent can fix it, with one install.\n * `bump` — this branch RAISED the pin on purpose. The deliverable is the pin, so every\n * ordinary cure would revert it. Main has to come up to meet it.\n * `main-ahead` — the governing tree already RUNS a newer release than this tree's pin asks for.\n * This is the common case, and it is the ONE case the worktree fixes ITSELF, by\n * raising its own pin. No escalation, nobody to ask, nothing to wait for.\n * `worktree-stale` — every PIN agrees and so does main's install; only this tree's OWN node_modules\n * lags. The one state where a bare `pnpm install` HERE is exactly right.\n * `main-behind` — main is genuinely older and must move forward. Only the main agent can pull it.\n * `hotfix` — this tree is on a `/hotfix/` branch, cut from the PRODUCTION sha, so its older\n * pin is the release production runs and is RIGHT. Raising it (the `main-ahead`\n * cure) would ship a webpieces upgrade inside a production hotfix (issue #1371).\n * A hotfix is worked in the MAIN tree, where its own pinned release governs it.\n */\ntype SkewCase = 'main-inconsistent' | 'hotfix' | 'bump' | 'main-ahead' | 'worktree-stale' | 'main-behind';\n\nexport class VersionSyncGuard {\n private readonly inspection = new ReadOnlyInspectionScan();\n private readonly versions = new WebpiecesVersions();\n private readonly branches = new BranchIdentity();\n\n /**\n * True when this tree is a linked worktree whose webpieces version disagrees with the main tree's.\n * This is the `V` dimension of the L1 matrix; the runner asks it for EVERY Bash call so the answer\n * lands in the audit log even when nothing blocks.\n */\n skewed(tree: EffectiveTree): boolean {\n if (!this.applies(tree)) return false;\n return !this.quartetFor(tree).inSync;\n }\n\n /** The deny report, or null to allow. */\n block(command: string, tree: EffectiveTree, aiType: AiType): string | null {\n if (!this.applies(tree)) return null;\n if (this.inspection.isReadOnlyInspection(command)) return null;\n if (this.isCureOrLook(command)) return null;\n const quartet = this.quartetFor(tree);\n if (quartet.inSync) return null;\n return this.report(tree, quartet, aiType);\n }\n\n /**\n * Commands that must pass EVEN WHILE THIS GUARD IS BLOCKING, because they are how you get unblocked\n * — or how you look at the tree first.\n *\n * `ReadOnlyInspectionScan` deliberately excludes git and gh OUTRIGHT (\"the guards exist to police\n * git, and read-only git is not a line worth drawing while flying blind\"), which is right for the\n * guards that police git but WRONG here: this guard's own prescribed cure is `git pull` in both\n * trees. Without this carve-out the guard would deny the exact command it tells the reader to run —\n * the single failure shape this repo has been burned by most often, and the reason the deny text is\n * allowed to promise \"STILL ALLOWED HERE: ... pnpm install, git pull/fetch\".\n *\n * Deliberately NARROW: fetching, pulling and installing cannot make a skew worse, and every one of\n * them moves the tree toward agreement. Anything that BUILDS, TESTS or COMMITS is still blocked,\n * because those are the operations that would be judged by the wrong release.\n */\n private isCureOrLook(command: string): boolean {\n const words = command.trim().split(/\\s+/);\n const head = words[0] ?? '';\n const sub = words[1] ?? '';\n if (head === 'git' || head === 'gh') {\n // `git -C <dir> <sub>` names its own directory; take the first non-flag word after it.\n const subcommand = sub === '-C' ? (words[3] ?? '') : sub;\n return ['pull', 'fetch', 'status', 'log', 'diff', 'show', 'branch', 'rev-parse', 'worktree'].includes(subcommand);\n }\n return (head === 'pnpm' || head === 'npm') && (sub === 'install' || sub === 'i');\n }\n\n /**\n * Is there a cross-tree comparison to make at all? TWO cheap conditions, no file read behind either:\n *\n * • K is `worktree` — git's `--git-dir ≠ --git-common-dir`, so a repo with no linked worktrees can\n * never reach the manifests. (In the primary clone this is also structural escape #1: \"do the\n * work in the main tree\" needs no allowlist entry to keep working.)\n * • the two roots are DIFFERENT directories — a tree compared with itself is not a skew, it is the\n * single-tree pin-vs-install question the L0 drift guard already owns.\n */\n private applies(tree: EffectiveTree): boolean {\n return tree.kind === 'worktree'\n && path.resolve(tree.mainRoot) !== path.resolve(tree.root);\n }\n\n /** Public so the runner can log all four versions on ALLOW as well as on BLOCK (audit, not just deny). */\n quartetFor(tree: EffectiveTree): VersionQuartet {\n return this.versions.quartet(tree.mainRoot, tree.root);\n }\n\n // Short on purpose — L0 ran a deliberate message diet and these blocks regress into a wall of text\n // if each one argues its case. State the skew, show every version WITH its file, give the git cure\n // first, then the two structural escapes, then what is still allowed.\n private report(tree: EffectiveTree, quartet: VersionQuartet, aiType: AiType): string {\n const skew = this.classify(tree, quartet);\n // The two SELF-SERVE cases print NO escalation, and that omission is the deliverable rather than\n // a saving: an escalation block on a cure the reader can perform HERE teaches it to stop and wait\n // for a main agent who has nothing to do. The other three genuinely need the main tree to move.\n const selfServe = skew === 'main-ahead' || skew === 'worktree-stale';\n const escalation = selfServe ? []\n : skew === 'hotfix' ? ['', ...this.hotfixEscalationLines(tree, quartet, aiType)]\n : ['', ...this.escalationLines(tree, quartet, skew, aiType)];\n return [\n `❌ @webpieces version SKEW — this worktree and the main tree disagree, so work here is blocked.`,\n '',\n ...this.versionLines(tree, quartet),\n '',\n ` Whichever tree's hooks are live, one of these two releases lints, validates and builds`,\n ` this worktree — and it may be the one this manifest does not ask for.`,\n '',\n ...this.fixLines(tree, quartet, skew),\n ...escalation,\n '',\n ` STILL ALLOWED HERE: every Read, read-only inspection, \\`pnpm install\\`, \\`git pull\\`/\\`fetch\\`,`,\n ` and edits to pnpm-workspace.yaml / package.json / webpieces.config.json.`,\n ` Do NOT lower the MAIN tree's pin to match — that downgrades every tree, including this`,\n ` session's own governor.`,\n ].join('\\n');\n }\n\n /**\n * WHICH of the five states this is — asked ONCE, so the FIX block and the escalation block can never\n * describe two different diagnoses of the same skew.\n *\n * Order is not arbitrary. `main-inconsistent` is asked FIRST because it is a fault in the governing\n * tree itself: comparing this worktree against a tree that disagrees with itself picks a direction\n * out of two numbers that are not yet one answer. `bump` next, because a deliberate raise is the one\n * shape where the direction is real but every ordinary cure is harmful.\n */\n private classify(tree: EffectiveTree, quartet: VersionQuartet): SkewCase {\n const mainPin = quartet.main.pinned;\n const mainInstalled = quartet.main.installed;\n if (mainPin !== null && mainInstalled !== null && mainPin !== mainInstalled) return 'main-inconsistent';\n const wtPin = quartet.worktree.pinned;\n const worktreeStale = mainInstalled !== null && wtPin === mainInstalled && quartet.worktree.installed !== null;\n // A hotfix whose pins AGREE and only lags its own install is plain `worktree-stale`: installing\n // the pin it already has ships nothing new. Every other hotfix skew is a pin production chose.\n if (!worktreeStale && this.isHotfix(tree)) return 'hotfix';\n if (this.isDeliberateBump(tree, quartet)) return 'bump';\n if (worktreeStale) return 'worktree-stale';\n return this.compare(mainInstalled, wtPin) > 0 ? 'main-ahead' : 'main-behind';\n }\n\n /**\n * SEMVER ORDER of two versions: 1 when `a` is newer, -1 when older, 0 when equal OR undecidable.\n *\n * 0 is the FAIL-SAFE answer and every caller must read it as \"no opinion\": an unreadable leg, a\n * dist-tag, two different pre-releases, or build metadata (which carries no precedence) all land\n * there, and `classify` then falls to `main-behind`, the branch that ASKS rather than acts. Guessing\n * a direction is how a downgrade gets prescribed, and this repo has already paid for that once.\n *\n * The same rules the shim's awk compare uses, so L0 and L1 cannot order one pair two ways: build\n * metadata stripped, numeric cores compared component-wise, and a pre-release sorting BELOW its\n * release.\n */\n private compare(a: string | null, b: string | null): number {\n if (a === null || b === null || a === b) return 0;\n const aParts = this.parts(a);\n const bParts = this.parts(b);\n if (aParts === null || bParts === null) return 0;\n const width = Math.max(aParts.core.length, bParts.core.length);\n for (let i = 0; i < width; i++) {\n const av = aParts.core[i] ?? 0;\n const bv = bParts.core[i] ?? 0;\n if (av !== bv) return av < bv ? -1 : 1;\n }\n if (aParts.pre === bParts.pre) return 0;\n if (aParts.pre !== '' && bParts.pre === '') return -1;\n if (aParts.pre === '' && bParts.pre !== '') return 1;\n return 0;\n }\n\n /** One version split into its numeric core and its pre-release suffix, or null if it is not numeric. */\n private parts(version: string): VersionParts | null {\n const noBuild = version.replace(/\\+.*$/, '');\n const core = noBuild.replace(/-.*$/, '');\n if (!/^[0-9]+(\\.[0-9]+)*$/.test(core)) return null;\n return new VersionParts(\n core.split('.').map((n: string): number => Number(n)),\n noBuild.slice(core.length),\n );\n }\n\n /**\n * The cure list, which is NOT the same list in both directions — but which, in BOTH directions, is a\n * list of things the reader ASKS FOR rather than runs.\n *\n * The ordinary skew is two trees sitting on different commits of main. The pin is tracked, so putting\n * both trees on the same commit and installing genuinely converges them. That cure is WRONG, and worse\n * than useless, when the branch bumped the pin ON PURPOSE: pulling would revert the deliverable, and\n * an install cannot move a pin in either tree. Printing the git cure first in that case is what sent a\n * real upgrade agent round the loop below.\n *\n * WHAT THIS BLOCK IS NOT ALLOWED TO SAY, in either branch: `git -C <the main tree> pull`. Two defects\n * rode on that one line, and it was printed ABOVE the escalation block, so it was the first thing read.\n * (a) A worktree-isolated SUBAGENT — the overwhelmingly common reader of this deny — CANNOT run\n * cross-tree git at all; the harness refuses it (shim-deny-reason.ts records the same\n * measurement). The one printed cure was the one thing the reader could not perform.\n * (b) A bare `git pull` acts on whatever branch that tree currently has checked out, and the primary\n * clone is normally sitting on a feature branch. It pulls the feature branch, the manifest never\n * moves, the pin never converges, and this guard fires again. The cure has to NAME main:\n * `cd <main> && git checkout main && git pull`.\n * So every step is prefixed `Tell main agent:` — INDIVIDUALLY, not under one shared header. That\n * repetition is deliberate and is the deliverable: a reader who skims exactly one of these lines must\n * still see it is not their own action. Do not factor it out.\n *\n * The FIX block still prints ABOVE the escalation block, on purpose. Moving it below would split the\n * numbered steps from the versions they refer to, and the do-not-retry beat has to stay last and stay\n * unique — a second shouted beat competing with it is exactly the wall-of-text regression the L0\n * message diet exists to prevent.\n * Labelling carries the \"not yours to run\" fact instead, which is what the caps header does.\n */\n private fixLines(tree: EffectiveTree, quartet: VersionQuartet, skew: SkewCase): readonly string[] {\n if (skew === 'main-inconsistent') return this.mainInconsistentFix(tree, quartet);\n if (skew === 'hotfix') return this.hotfixFix(tree, quartet);\n if (skew === 'main-ahead') return this.mainAheadFix(tree, quartet);\n if (skew === 'worktree-stale') {\n // Every PIN agrees, and so does main's install. The ONLY disagreeing leg is this tree's own\n // node_modules — so this is the one state where a bare `pnpm install` HERE is not a guess,\n // is not a downgrade, and needs nobody's permission. Saying so plainly matters because the\n // other cases all warn AGAINST reaching for it.\n return [\n ` FIX — THIS ONE IS YOURS, AND IT IS ONE COMMAND. Every pin already agrees; only this`,\n ` tree's own node_modules lags at ${this.show(quartet.worktree.installed).trim()}.`,\n ` 1. Run \\`pnpm install\\` HERE, in ${tree.root}.`,\n ` Nothing needs to move in the main tree and there is nobody to ask.`,\n ];\n }\n if (skew === 'bump') {\n return [\n ` THIS BRANCH BUMPED THE PIN ON PURPOSE (${this.show(quartet.main.pinned).trim()} → ${this.show(quartet.worktree.pinned).trim()}), so the usual cures do NOT apply:`,\n ` • \\`pnpm install\\` cannot help in EITHER tree — an install materializes a pin, never moves one.`,\n ` • \\`git pull\\` here would revert the bump, which is the whole deliverable.`,\n ` • Wiping this tree's node_modules does NOT help — the two PINS still disagree, and the`,\n ` L0 drift guard blocks in this guard's place.`,\n ` FIX — YOU CANNOT DO THIS FROM HERE. BOTH ways out need the MAIN tree, and cross-tree`,\n ` git is REFUSED to a subagent, so every step below is something you ASK FOR, not run:`,\n ` 1. Tell main agent: this task has to be redone in the MAIN tree ${tree.mainRoot}`,\n ` — a version bump cannot be done in a worktree at all.`,\n ` 2. Tell main agent: OR raise the MAIN tree's pin to ${this.show(quartet.worktree.pinned).trim()} in`,\n ` ${tree.mainRoot}/${WORKSPACE_MANIFEST} and run \\`pnpm install\\` there.`,\n ` 3. Tell main agent: to tell you when that is complete.`,\n ` THEN AND ONLY THEN will this worktree — and every other subagent — work again.`,\n ];\n }\n return [\n ` FIX — YOU CANNOT DO THIS FROM HERE. Cross-tree git is REFUSED to a subagent, and a bare`,\n ` \\`git pull\\` moves whatever branch that tree is on — so the cure must NAME main, in main:`,\n ` 1. Tell main agent: \\`cd ${tree.mainRoot} && git checkout main && git pull\\``,\n ` 2. Tell main agent: then run \\`pnpm install\\` in ${tree.mainRoot}`,\n ` 3. Tell main agent: then report back what \\`ls ${tree.mainRoot}/node_modules/@webpieces\\``,\n ` shows, so we know whether the hook shim needs re-upgrading too.`,\n ` 4. Tell main agent: to tell you when ALL of that is complete.`,\n ` THEN AND ONLY THEN will this worktree — and every other subagent — work again.`,\n ` The two structural escapes, if converging the trees is not what the coordinator wants:`,\n ` • Do the work in the MAIN tree instead — it is never blocked by this guard.`,\n ` • Or use a separate CLONE, not a worktree, if this tree genuinely needs a DIFFERENT`,\n ` version: a clone gets its own governance. A worktree MAY have its own node_modules, so`,\n ` installing here is fine; what it may not have is a DIFFERENT @webpieces version.`,\n ];\n }\n\n /**\n * CASE A — the MAIN tree disagrees with ITSELF: its `node_modules` is on one version while its own\n * `pnpm-workspace.yaml` pins another. Nothing in this worktree is wrong, and nothing this worktree\n * does can help.\n *\n * The cure is deliberately the SMALL one. The generic branch prints `git checkout main && git pull`\n * first, and that is over-prescribed here: both halves of the disagreement are already in that tree,\n * so an install materializes the pin it already has and the skew is gone. Printing the pull as well\n * invites a main agent to move main's commit for a fault that is not about main's commit at all.\n */\n private mainInconsistentFix(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n return [\n ` THE MAIN TREE IS INTERNALLY INCONSISTENT — its node_modules is on ${this.show(quartet.main.installed).trim()} but its own`,\n ` pin says ${this.show(quartet.main.pinned).trim()}. That is not this worktree's fault and not this worktree's to fix.`,\n ` FIX — YOU CANNOT DO THIS FROM HERE. Cross-tree git is REFUSED to a subagent:`,\n ` 1. Tell main agent: run \\`pnpm install\\` in ${tree.mainRoot} — no pull is needed, both`,\n ` halves are already in that tree.`,\n ` 2. Tell main agent: to tell you when that is complete.`,\n ` THEN AND ONLY THEN will this worktree — and every other subagent — work again.`,\n ];\n }\n\n /**\n * CASE B — the MAIN tree already RUNS a newer release than this tree's pin asks for. This is the\n * common case, and it is the one the old message got exactly backwards.\n *\n * It is the ONLY case a worktree fixes ITSELF. Nothing needs to move in the main tree — the version\n * the guards will judge this tree by is already installed there — so the entire fix is to raise this\n * tree's own pin to match, which is a one-line edit to a TRACKED file this tree owns. Printing an\n * escalation here (as every earlier revision did) tells an agent to stop and wait for a main agent\n * who has nothing to do, which is how a five-minute edit became a stalled turn.\n *\n * The edit is typable from inside the block because pnpm-workspace.yaml is on the L0 allowlist and\n * carved out in the runner's edit path. That carve-out and this text ship together on purpose: a\n * message prescribing a blocked call is the failure shape this repo has been burned by most often.\n *\n * ON A DETACHED HEAD the edit has no branch to belong to, so it is not offered — an edit that\n * survives nothing is worse than no edit. Get onto a branch, then read this message again.\n */\n private mainAheadFix(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n const target = this.show(quartet.main.installed).trim();\n if (this.isDetachedHead(tree.root)) {\n return [\n ` FIX — GET ONTO A BRANCH FIRST. \\`git branch --show-current\\` is empty in ${tree.root}, so`,\n ` HEAD is DETACHED and the one-line pin edit below would belong to no branch at all.`,\n ` 1. Check out a branch here, then re-run this command.`,\n ` 2. The fix is then yours alone: set ${WORKSPACE_MANIFEST}'s catalog pin to ${target}.`,\n ` Nothing needs to move in the main tree — it already runs ${target}.`,\n ];\n }\n const install = quartet.worktree.installed !== null\n ? [` 2. Then run \\`pnpm install\\` HERE — this tree has its own node_modules, so it must be`,\n ` materialized at ${target} too.`]\n : [` 2. Nothing else. This tree has no node_modules of its own, so there is nothing to install.`];\n return [\n ` FIX — THIS ONE IS YOURS, AND YOU CAN DO IT RIGHT HERE. The main tree is AHEAD: it already`,\n ` runs ${target}, so nothing has to move there and there is nobody to ask.`,\n ` 1. Edit ${tree.root}/${WORKSPACE_MANIFEST} — the catalog line for`,\n ` ${UMBRELLA_PACKAGE} — and set it to ${target}. That edit is ALLOWED`,\n ` right now, from inside this block.`,\n ...install,\n ` Do NOT run a bare \\`pnpm install\\` first: this tree's pin is the STALE side, so installing`,\n ` before the edit materializes the OLD release and this guard fires again.`,\n ];\n }\n\n /**\n * Is this tree checked out on a `/hotfix/` branch? BranchIdentity's ONE exact, case-sensitive\n * predicate, asked of the branch GitCheckout reads off this tree's own HEAD — no git process.\n */\n private isHotfix(tree: EffectiveTree): boolean {\n const branch = gitCheckout.branch(tree.root);\n return branch !== null && this.branches.isHotfix(branch);\n }\n\n /**\n * THE HOTFIX CASE (issue #1371). Exempting a hotfix worktree from this block was the first idea, and\n * it is unsafe for the reason this guard exists: the MAIN tree's newer release would then govern the\n * hotfix — validating its production-era webpieces.config.json against rules that release requires\n * (a new rule with no entry fails the config load) and linting its code by rules it never pinned — so\n * the hotfix would trade this block for a config fault whose cure is ALSO a webpieces change shipped\n * to production. And the cure this report would otherwise print, `main-ahead`'s \"raise your pin\",\n * ships exactly that upgrade. So the block stays, and the cure is the one that keeps production's\n * release: work the hotfix in the MAIN tree, where its own pin governs it.\n */\n private hotfixFix(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n const branch = gitCheckout.branch(tree.root) ?? '<hotfix branch>';\n return [\n ` THIS IS A /hotfix/ BRANCH (\\`${branch}\\`), cut from the production sha. Its pin`,\n ` ${this.show(quartet.worktree.pinned).trim()} is the release production runs, so it is RIGHT — do NOT raise it to`,\n ` match main: that ships a webpieces upgrade inside a production hotfix.`,\n ` A HOTFIX RUNS IN THE MAIN TREE, never in a linked worktree: here the main tree's newer release`,\n ` governs this branch, and judges its production-era config and code by rules it never pinned.`,\n ` FIX — move the hotfix to the main tree ${tree.mainRoot}:`,\n ` 1. Release \\`${branch}\\` from this worktree (git refuses to check out a branch another`,\n ` worktree holds), then in the main tree: \\`git switch ${branch} && pnpm install\\` —`,\n ` that install puts the branch's OWN pinned release in charge of it.`,\n ` 2. Make the fix there and publish it with \\`pnpm wp-upsert-hotfix-pr <tracker> <number>\\`.`,\n ];\n }\n\n /**\n * The forwardable ask for the hotfix case. NOT `escalationLines`: its afterward beat asks for a FRESH\n * worktree subagent to redo the task once main is synced, which is the one place a hotfix must not go.\n */\n private hotfixEscalationLines(tree: EffectiveTree, quartet: VersionQuartet, aiType: AiType): readonly string[] {\n const branch = gitCheckout.branch(tree.root) ?? '<hotfix branch>';\n return [\n ` SUBAGENT? Cross-tree git is REFUSED to you. Forward this to your coordinator verbatim:`,\n ` > My worktree ${tree.root} is on /hotfix/ branch \\`${branch}\\`, pinned to @webpieces`,\n ` > ${this.show(quartet.worktree.pinned).trim()} — production's release — while the main tree ${tree.mainRoot} runs ${this.show(quartet.main.installed).trim()}.`,\n ` > A hotfix cannot run in a linked worktree, and its pin must not be raised. Please do this`,\n ` > hotfix in the MAIN tree: check \\`${branch}\\` out there, \\`pnpm install\\`, make the fix, and`,\n ` > publish it with \\`pnpm wp-upsert-hotfix-pr <tracker> <number>\\`. Do NOT redo it in another worktree.`,\n ` Do NOT retry this call — RETRYING IS THE BUG. It re-fires this identical deny and buries the`,\n ` ask above; one subagent did it 13 times, 25 across that whole session.`,\n ...(aiType === 'codex' ? this.waitLines(aiType)\n : [` Nothing you can do from this tree clears it; the hotfix is done in the main tree.`]),\n ];\n }\n\n /**\n * Is HEAD DETACHED in this tree — i.e. is there no branch for a pin edit to belong to?\n *\n * Asked of GitCheckout, the one branch resolver (#1355): it answers an UNBORN branch with its name\n * (every freshly-created worktree is unborn until its first commit) and a detached HEAD with\n * DETACHED_HEAD, which is exactly the distinction case B needs.\n *\n * A git FAILURE is NOT detached, and the difference is load-bearing: GitCheckout answers null there,\n * never DETACHED_HEAD, so a tree git cannot read (no repo, git absent) is not told its HEAD is\n * detached — a confident diagnosis of a state nobody measured. It falls back to the ordinary branch\n * wording, whose worst case is prescribing an edit that turns out to be moot.\n */\n private isDetachedHead(root: string): boolean {\n return gitCheckout.branch(root) === DETACHED_HEAD;\n }\n\n /**\n * THE SUBAGENT CANNOT REACH THE MAIN TREE, so the message it is handed has to be the message it\n * FORWARDS. This used to be one sentence — \"report to your coordinator that one of you must move to\n * the other's version\" — with no command, no direction and nothing pasteable, and the result was a\n * subagent that correctly diagnosed the block, correctly escalated, and handed its coordinator a\n * request too vague to act on. Worse, the obvious guess (\"ask the coordinator to run `pnpm install`\n * in main\") is a NO-OP on a bump: it reinstalls main's own pin and nothing moves.\n *\n * So the escalation is rendered as literal text to forward, with the versions and the direction\n * already filled in. A human cannot sit with every agent; the deny has to carry the whole ask.\n *\n * The ask is ROUTED THROUGH THE MAIN AGENT rather than phrased as a command, and that distinction is\n * the whole point of this block. `git -C <mainRoot> pull` reads like something you run from wherever\n * you are standing — so a subagent reads it, tries it, and only then discovers that CROSS-TREE GIT IS\n * REFUSED to a worktree-isolated agent (same measurement shim-deny-reason.ts records: the harness\n * blocks `git -C <other tree>`, and it is git specifically). This skew needs a git pull in main, so\n * the one printed cure was the one thing this session cannot perform. Be precise about that and do\n * NOT overstate it into \"you cannot reach that tree at all\" — a local `cd <main> && pnpm install`\n * measurably DOES run, it simply cannot move main onto a different commit, which is what a skew\n * requires. The actor who can is the MAIN AGENT running in the MAIN git worktree, so the forwarded\n * text asks for exactly that — and asks to be TOLD WHEN IT IS DONE, because \"the work happened\" is\n * the event that unblocks this subagent and it has no way to observe it otherwise.\n *\n * And it has to refuse the RETRY, because forwarding is only half of what the subagent must do. One\n * measured subagent transcript re-fired this identical deny 13 TIMES (25 across the whole session,\n * counting two sibling subagents and two parent sessions): the subagent read it, escalated exactly\n * as asked — and then re-ran the blocked call. Every retry cost a round trip and pushed the one\n * message that mattered further up the scrollback. The block is not transient and no command from\n * this tree slips past it, so retrying is never a strategy; it is the bug.\n *\n * What it must NOT do is decide the agent's control flow. #679 first wrote this beat as \"STOP WORKING\n * NOW. Forwarding that message IS the end of your turn: make NO further tool calls\" — a turn-level\n * prescription, which `.claude/rules/never-tell-an-ai-to-end-its-turn.md` forbids (#902 deleted every\n * other one; this one survived because no spec rendered it — issue #1000). Refusing one futile\n * command is legitimate; ruling on when the turn ends is a judgement the agent is better placed to\n * make. So the beat names the retry, says why it is futile, and stops talking.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private escalationLines(tree: EffectiveTree, quartet: VersionQuartet, skew: SkewCase, aiType: AiType): readonly string[] {\n return [\n ` SUBAGENT? You cannot fix the main tree from here. Forward this to your coordinator verbatim:`,\n ` > My worktree ${tree.root} is on @webpieces ${this.show(quartet.worktree.pinned).trim()};`,\n ` > the main tree ${tree.mainRoot} is on ${this.show(quartet.main.pinned).trim()}.`,\n ...this.askLines(tree, quartet, skew),\n ...this.afterwardLines(aiType),\n ` Do NOT retry this call — RETRYING IS THE BUG. It re-fires this identical deny and buries the`,\n ` ask above; one subagent did it 13 times, 25 across that whole session.`,\n ...this.waitLines(aiType),\n ];\n }\n\n /**\n * What the coordinator does ONCE main is synced — and here the two harnesses need opposite answers.\n *\n * Codex runs every subagent in the coordinator's own checkout, so \"tell me when it is done so I can\n * continue\" is literally true: the same agent picks up where it stopped.\n *\n * Claude Code does NOT keep that tree for it. A worktree-isolated subagent that hands back with an\n * unchanged worktree has that worktree REAPED, and a subagent resumed afterwards (SendMessage) comes\n * back with its cwd on the PRIMARY clone — which happened to the first agent on issue #863 itself. So\n * asking to be resumed routes the work into the one tree it must never land in. The ask is therefore a\n * FRESH `isolation: \"worktree\"` subagent, and \"resume me\" / \"continue working\" must not appear.\n */\n private afterwardLines(aiType: AiType): readonly string[] {\n if (aiType === 'codex') {\n return [` > Tell me when that is complete so I can continue working.`];\n }\n return [\n ` > Once main is synced, spawn a FRESH isolation: \"worktree\" subagent to redo this task. Do NOT`,\n ` > message this agent again: my worktree is reaped on hand-back, and a re-messaged agent lands in the primary clone.`,\n ];\n }\n\n private waitLines(aiType: AiType): readonly string[] {\n if (aiType === 'codex') {\n // The three-move wait shape (never-tell-an-ai-to-end-its-turn.md): name the efficient option,\n // name the wasteful one, and say nothing about when a turn ends.\n return [\n ` Nothing you can do from this tree clears it. Be efficient with tokens: wait on the main`,\n ` agent's confirmation instead of re-running blocked calls to see whether it has cleared.`,\n ];\n }\n return [` Nothing you can do from this tree clears it; the coordinator redoes it in a fresh worktree.`];\n }\n\n /**\n * The forwardable ASK, one per case that needs one. `main-ahead` never reaches here — it has nothing\n * to ask for — so the three shapes below cover every escalating case. What happens AFTER the ask is\n * harness-specific and lives in {@link afterwardLines}, so none of these says \"tell me when\".\n *\n * The bump ask carries the upgrade sentence VERBATIM as Dean wrote it, because it answers the one\n * question an upgrade agent gets wrong: \"webpieces cannot be upgraded from a worktree\" is not a\n * missing permission it can route around, it is a property of who governs whom.\n */\n private askLines(tree: EffectiveTree, quartet: VersionQuartet, skew: SkewCase): readonly string[] {\n if (skew === 'bump') {\n return [\n ` > A \\`pnpm install\\` in main will NOT fix this — main's PIN has to move. Pick one:`,\n ` > (a) I redo this task in the MAIN tree (a version bump cannot be done in a worktree), or`,\n ` > (b) you TELL THE MAIN AGENT in the MAIN git worktree ${tree.mainRoot} to`,\n ` > raise main's catalog pin to ${this.show(quartet.worktree.pinned).trim()} and \\`pnpm install\\` there. I cannot reach that tree from here.`,\n ` If you are a subagent upgrading webpieces, STOP — only main agents in worktrees can do`,\n ` this. Otherwise your main agent must \\`git pull\\` main: main has an earlier version of`,\n ` webpieces pinned and must upgrade. You MUST tell the main agent to pull main and`,\n ` \\`pnpm install\\`.`,\n ];\n }\n if (skew === 'main-inconsistent') {\n return [\n ` > Please TELL THE MAIN AGENT in the MAIN git worktree ${tree.mainRoot} to run`,\n ` > \\`pnpm install\\` there — its node_modules is on ${this.show(quartet.main.installed).trim()} but its own pin says`,\n ` > ${this.show(quartet.main.pinned).trim()}, so no pull is needed. I cannot reach that tree from here.`,\n ];\n }\n return [\n ` > Please TELL THE MAIN AGENT in the MAIN git worktree ${tree.mainRoot} to run`,\n ` > \\`git checkout main && git pull && pnpm install\\` there — it must NAME main, since a bare`,\n ` > pull moves whatever branch that tree is on — so both trees are on the same release, and`,\n ` > to report what \\`ls node_modules/@webpieces\\` shows there. I cannot reach that tree from here.`,\n ];\n }\n\n /**\n * Did THIS BRANCH change the pin, as opposed to the two trees having drifted onto different commits?\n *\n * Only answerable now that both pin legs actually resolve — before the catalog reader followed YAML\n * anchors they both read null on the repos that pin via an anchor, so every skew looked alike and the\n * report could only ever print the one generic cure.\n *\n * Two git spawns worst case, on the BLOCK path only (this is never reached on an allow), and\n * best-effort: a git failure answers \"not a deliberate bump\", which falls back to the generic cure\n * that was the only text this report had before.\n */\n private isDeliberateBump(tree: EffectiveTree, quartet: VersionQuartet): boolean {\n if (quartet.main.pinned === null || quartet.worktree.pinned === null) return false;\n if (quartet.main.pinned === quartet.worktree.pinned) return false;\n return this.touchesWorkspaceFile(tree.root, ['status', '--porcelain', '--', WORKSPACE_MANIFEST])\n || this.touchesWorkspaceFile(tree.root, ['diff', '--name-only', 'origin/main...HEAD', '--', WORKSPACE_MANIFEST]);\n }\n\n private touchesWorkspaceFile(root: string, args: readonly string[]): boolean {\n const result = spawnSync('git', ['-C', root, ...args], { encoding: 'utf8' });\n return result.status === 0 && (result.stdout ?? '').trim() !== '';\n }\n\n // Every version WITH the file it came from. An agent that is told \"they disagree\" without being told\n // WHICH FILE to edit re-derives it by grepping, which is exactly the turn-burning this guard exists\n // to prevent. Unreadable legs are printed as `-` rather than omitted, so the reader can tell\n // \"this one is absent\" from \"I forgot to look\".\n private versionLines(tree: EffectiveTree, quartet: VersionQuartet): readonly string[] {\n const lines = [\n ` main pin ${this.show(quartet.main.pinned)} ${tree.mainRoot}/pnpm-workspace.yaml`,\n ` main installed ${this.show(quartet.main.installed)} ${tree.mainRoot}/node_modules/${UMBRELLA_PACKAGE}`,\n ` ^ the binary judging this very call`,\n ` this worktree ${this.show(quartet.worktree.pinned)} ${tree.root}/pnpm-workspace.yaml`,\n ];\n if (quartet.worktree.installed !== null) {\n lines.push(` its installed ${this.show(quartet.worktree.installed)} ${tree.root}/node_modules/${UMBRELLA_PACKAGE}`);\n lines.push(' ^ what nx, vitest and eslint load IN this tree');\n }\n const others = this.versions.otherWorktrees(tree.mainRoot, tree.root);\n if (others.length > 0) {\n lines.push(` NOTE ${others.length} other worktree(s) exist and are governed the same way — if they are`);\n lines.push(' skewed too, their agents are already mis-governed. Consider clones, or');\n lines.push(' serializing the work in the main tree.');\n }\n return lines;\n }\n\n private show(version: string | null): string {\n return (version ?? '-').padEnd(10);\n }\n}\n"]}
@@ -7,7 +7,7 @@ exports.ruleMigrations = [
7
7
  new rules_sdk_1.RetiredConfigKey("rule", "pr-merge-cleanup", "pr-lifecycle-guard", "Rename the key to \"pr-lifecycle-guard\" (merging its value into that entry if you already have one — the four PR/merge guards share one key now). Its mode and escape hatches carry over.", "[pr-merge-cleanup]", false),
8
8
  new rules_sdk_1.RetiredConfigKey("rule", "pr-creation-guard", "pr-lifecycle-guard", "Rename the key to \"pr-lifecycle-guard\" (merging its value into that entry if you already have one — the four PR/merge guards share one key now). Its mode and escape hatches carry over; the old \"upsertPrCommand\" field does NOT — that string lives only in commands.guardHints.prCreationOrPush.", "[pr-creation-guard]", false),
9
9
  new rules_sdk_1.RetiredConfigKey("rule", "main-stale-guard", "branch-state-guard", "Rename the key to \"branch-state-guard\" (merging its value into that entry if you already have one — the four branch-state guards share one key now). Its mode and escape hatches carry over. Note the widened scope: that key arms the Write, Read AND Bash halves of the branch-state policy, not just the Read block this key used to name.", "[main-stale-guard]", false),
10
- new rules_sdk_1.RetiredConfigKey("rule", "whole-repo-build-guard", "~/.webpieces/config.json → experimental.whole-repo-build-guard", "DELETE this entry from webpieces.config.json — no repo config key controls this guard any more. The guard is OFF by default for everyone, with no file and no key required. To turn it ON for YOUR machine only, put {\"experimental\": {\"whole-repo-build-guard\": true}} in ~/.webpieces/config.json — that file is optional and is tracked by no repo.", "[whole-repo-build-guard]", true),
10
+ new rules_sdk_1.RetiredConfigKey("rule", "whole-repo-build-guard", "nowhere — the guard is always on (issue #1494)", "DELETE this entry from webpieces.config.json — no config key controls this guard any more. It is permanent and always ON for everyone, with no file and no key required.", "[whole-repo-build-guard]", true),
11
11
  new rules_sdk_1.RetiredConfigKey("rule", "feature-branch-guard", "branch-state-guard", "MERGE it into ONE \"branch-state-guard\" entry under \"hookGuards\". All four of feature-branch-guard, read-stale-guard, stale-main-bash-guard and merged-branch-bash-guard now read that single entry — they are one policy (\"may I work here, and is what I read current?\") implemented by four classes, and configuring them separately let you switch on half of it. Keep \"mode\", \"turnOffRuleUntilEpoch\" and \"turnOffRuleWhileOnBranch\"; the ONE \"hangTimeoutMinutes\" survives (there was only ever one refresher and one cache, so at most one of the four values could ever take effect); \"branchNamingConvention\" survives from feature-branch-guard. If the four disagreed on \"mode\", pick the one you meant — \"ON\" arms the whole policy including the Read block. Then DELETE this key.", "[feature-branch-guard]", false),
12
12
  new rules_sdk_1.RetiredConfigKey("rule", "read-stale-guard", "branch-state-guard", "MERGE it into ONE \"branch-state-guard\" entry under \"hookGuards\". All four of feature-branch-guard, read-stale-guard, stale-main-bash-guard and merged-branch-bash-guard now read that single entry — they are one policy (\"may I work here, and is what I read current?\") implemented by four classes, and configuring them separately let you switch on half of it. Keep \"mode\", \"turnOffRuleUntilEpoch\" and \"turnOffRuleWhileOnBranch\"; the ONE \"hangTimeoutMinutes\" survives (there was only ever one refresher and one cache, so at most one of the four values could ever take effect); \"branchNamingConvention\" survives from feature-branch-guard. If the four disagreed on \"mode\", pick the one you meant — \"ON\" arms the whole policy including the Read block. Then DELETE this key.", "[read-stale-guard]", false),
13
13
  new rules_sdk_1.RetiredConfigKey("rule", "stale-main-bash-guard", "branch-state-guard", "MERGE it into ONE \"branch-state-guard\" entry under \"hookGuards\". All four of feature-branch-guard, read-stale-guard, stale-main-bash-guard and merged-branch-bash-guard now read that single entry — they are one policy (\"may I work here, and is what I read current?\") implemented by four classes, and configuring them separately let you switch on half of it. Keep \"mode\", \"turnOffRuleUntilEpoch\" and \"turnOffRuleWhileOnBranch\"; the ONE \"hangTimeoutMinutes\" survives (there was only ever one refresher and one cache, so at most one of the four values could ever take effect); \"branchNamingConvention\" survives from feature-branch-guard. If the four disagreed on \"mode\", pick the one you meant — \"ON\" arms the whole policy including the Read block. Then DELETE this key.", "[stale-main-bash-guard]", false),