@webpieces/agent-workflow-rules 0.0.0-stage → 0.0.1
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.
- package/README.md +23 -2
- package/package.json +45 -4
- package/src/adapters/agent-response.d.ts +5 -0
- package/src/adapters/agent-response.js +86 -0
- package/src/adapters/agent-response.js.map +1 -0
- package/src/adapters/codex-subagent-guard.d.ts +45 -0
- package/src/adapters/codex-subagent-guard.js +88 -0
- package/src/adapters/codex-subagent-guard.js.map +1 -0
- package/src/adapters/guards-hook.d.ts +3 -0
- package/src/adapters/guards-hook.js +30 -0
- package/src/adapters/guards-hook.js.map +1 -0
- package/src/adapters/hook-app-fixtures.d.ts +68 -0
- package/src/adapters/hook-app-fixtures.js +170 -0
- package/src/adapters/hook-app-fixtures.js.map +1 -0
- package/src/adapters/hook-core.d.ts +22 -0
- package/src/adapters/hook-core.js +359 -0
- package/src/adapters/hook-core.js.map +1 -0
- package/src/adapters/hook-pipeline-evaluator.d.ts +5 -0
- package/src/adapters/hook-pipeline-evaluator.js +18 -0
- package/src/adapters/hook-pipeline-evaluator.js.map +1 -0
- package/src/adapters/review-identity-stamper.d.ts +20 -0
- package/src/adapters/review-identity-stamper.js +34 -0
- package/src/adapters/review-identity-stamper.js.map +1 -0
- package/src/bin/codex-trust.d.ts +105 -0
- package/src/bin/codex-trust.js +205 -0
- package/src/bin/codex-trust.js.map +1 -0
- package/src/bin/dev-hook-install.d.ts +1 -0
- package/src/bin/dev-hook-install.js +80 -0
- package/src/bin/dev-hook-install.js.map +1 -0
- package/src/bin/dev-hook-uninstall.d.ts +1 -0
- package/src/bin/dev-hook-uninstall.js +45 -0
- package/src/bin/dev-hook-uninstall.js.map +1 -0
- package/src/bin/hook-registration.d.ts +429 -0
- package/src/bin/hook-registration.js +661 -0
- package/src/bin/hook-registration.js.map +1 -0
- package/src/bin/install-entry.d.ts +19 -0
- package/src/bin/install-entry.js +128 -0
- package/src/bin/install-entry.js.map +1 -0
- package/src/bin/l0-allowlist.d.ts +46 -0
- package/src/bin/l0-allowlist.js +527 -0
- package/src/bin/l0-allowlist.js.map +1 -0
- package/src/bin/l0-codex-read.d.ts +20 -0
- package/src/bin/l0-codex-read.js +108 -0
- package/src/bin/l0-codex-read.js.map +1 -0
- package/src/bin/l0-decide.d.ts +49 -0
- package/src/bin/l0-decide.js +90 -0
- package/src/bin/l0-decide.js.map +1 -0
- package/src/bin/l0-entry.d.ts +103 -0
- package/src/bin/l0-entry.js +98 -0
- package/src/bin/l0-entry.js.map +1 -0
- package/src/bin/l0-ignored-tools.d.ts +38 -0
- package/src/bin/l0-ignored-tools.js +44 -0
- package/src/bin/l0-ignored-tools.js.map +1 -0
- package/src/bin/managed-env.d.ts +46 -0
- package/src/bin/managed-env.js +50 -0
- package/src/bin/managed-env.js.map +1 -0
- package/src/bin/neighbour-hooks.d.ts +42 -0
- package/src/bin/neighbour-hooks.js +177 -0
- package/src/bin/neighbour-hooks.js.map +1 -0
- package/src/bin/reviewer-agent.d.ts +19 -0
- package/src/bin/reviewer-agent.js +135 -0
- package/src/bin/reviewer-agent.js.map +1 -0
- package/src/bin/settings-shape.d.ts +37 -0
- package/src/bin/settings-shape.js +17 -0
- package/src/bin/settings-shape.js.map +1 -0
- package/src/bin/setup-config.d.ts +20 -0
- package/src/bin/setup-config.js +371 -0
- package/src/bin/setup-config.js.map +1 -0
- package/src/bin/setup.d.ts +78 -0
- package/src/bin/setup.js +411 -0
- package/src/bin/setup.js.map +1 -0
- package/src/bin/shim-audit-log.d.ts +119 -0
- package/src/bin/shim-audit-log.js +286 -0
- package/src/bin/shim-audit-log.js.map +1 -0
- package/src/bin/shim-deny-reason.d.ts +1 -0
- package/src/bin/shim-deny-reason.js +244 -0
- package/src/bin/shim-deny-reason.js.map +1 -0
- package/src/bin/shim-drift-fix.d.ts +1 -0
- package/src/bin/shim-drift-fix.js +73 -0
- package/src/bin/shim-drift-fix.js.map +1 -0
- package/src/bin/shim-testkit.d.ts +107 -0
- package/src/bin/shim-testkit.js +197 -0
- package/src/bin/shim-testkit.js.map +1 -0
- package/src/bin/shim-version-drift.d.ts +1 -0
- package/src/bin/shim-version-drift.js +164 -0
- package/src/bin/shim-version-drift.js.map +1 -0
- package/src/bin/shim.d.ts +16 -0
- package/src/bin/shim.js +641 -0
- package/src/bin/shim.js.map +1 -0
- package/src/bin/upgrade-shim.d.ts +18 -0
- package/src/bin/upgrade-shim.js +283 -0
- package/src/bin/upgrade-shim.js.map +1 -0
- package/src/configs/main-sync-guard-configs.d.ts +38 -0
- package/src/configs/main-sync-guard-configs.js +54 -0
- package/src/configs/main-sync-guard-configs.js.map +1 -0
- package/src/configs/rule-configs.d.ts +47 -0
- package/src/configs/rule-configs.js +96 -0
- package/src/configs/rule-configs.js.map +1 -0
- package/src/core/ai-type-context.d.ts +36 -0
- package/src/core/ai-type-context.js +45 -0
- package/src/core/ai-type-context.js.map +1 -0
- package/src/core/decision-log.d.ts +190 -0
- package/src/core/decision-log.js +409 -0
- package/src/core/decision-log.js.map +1 -0
- package/src/core/excluded-path-escape.d.ts +101 -0
- package/src/core/excluded-path-escape.js +236 -0
- package/src/core/excluded-path-escape.js.map +1 -0
- package/src/core/force-to-root.d.ts +32 -0
- package/src/core/force-to-root.js +60 -0
- package/src/core/force-to-root.js.map +1 -0
- package/src/core/guard-index-doc.d.ts +63 -0
- package/src/core/guard-index-doc.js +172 -0
- package/src/core/guard-index-doc.js.map +1 -0
- package/src/core/instruct-ai-writer.d.ts +1 -0
- package/src/core/instruct-ai-writer.js +6 -0
- package/src/core/instruct-ai-writer.js.map +1 -0
- package/src/core/l0-matrix.d.ts +102 -0
- package/src/core/l0-matrix.js +357 -0
- package/src/core/l0-matrix.js.map +1 -0
- package/src/core/l0-tooling-doc.d.ts +45 -0
- package/src/core/l0-tooling-doc.js +258 -0
- package/src/core/l0-tooling-doc.js.map +1 -0
- package/src/core/l1-doc.d.ts +7 -0
- package/src/core/l1-doc.js +340 -0
- package/src/core/l1-doc.js.map +1 -0
- package/src/core/l1-matrix-doc.d.ts +31 -0
- package/src/core/l1-matrix-doc.js +111 -0
- package/src/core/l1-matrix-doc.js.map +1 -0
- package/src/core/l1-rows.d.ts +167 -0
- package/src/core/l1-rows.js +262 -0
- package/src/core/l1-rows.js.map +1 -0
- package/src/core/l2-doc.d.ts +7 -0
- package/src/core/l2-doc.js +385 -0
- package/src/core/l2-doc.js.map +1 -0
- package/src/core/l2-matrix-doc.d.ts +23 -0
- package/src/core/l2-matrix-doc.js +72 -0
- package/src/core/l2-matrix-doc.js.map +1 -0
- package/src/core/l2-row.d.ts +54 -0
- package/src/core/l2-row.js +75 -0
- package/src/core/l2-row.js.map +1 -0
- package/src/core/l2-rows.d.ts +56 -0
- package/src/core/l2-rows.js +272 -0
- package/src/core/l2-rows.js.map +1 -0
- package/src/core/load-rules.d.ts +9 -0
- package/src/core/load-rules.js +65 -0
- package/src/core/load-rules.js.map +1 -0
- package/src/core/log-stream.d.ts +117 -0
- package/src/core/log-stream.js +156 -0
- package/src/core/log-stream.js.map +1 -0
- package/src/core/log-streams.d.ts +48 -0
- package/src/core/log-streams.js +55 -0
- package/src/core/log-streams.js.map +1 -0
- package/src/core/log-target.d.ts +21 -0
- package/src/core/log-target.js +29 -0
- package/src/core/log-target.js.map +1 -0
- package/src/core/main-sync-log.d.ts +16 -0
- package/src/core/main-sync-log.js +108 -0
- package/src/core/main-sync-log.js.map +1 -0
- package/src/core/main-sync-refresh.d.ts +39 -0
- package/src/core/main-sync-refresh.js +96 -0
- package/src/core/main-sync-refresh.js.map +1 -0
- package/src/core/main-sync-timeout.d.ts +33 -0
- package/src/core/main-sync-timeout.js +95 -0
- package/src/core/main-sync-timeout.js.map +1 -0
- package/src/core/matrix-cures.d.ts +12 -0
- package/src/core/matrix-cures.js +56 -0
- package/src/core/matrix-cures.js.map +1 -0
- package/src/core/missing-directory.d.ts +38 -0
- package/src/core/missing-directory.js +66 -0
- package/src/core/missing-directory.js.map +1 -0
- package/src/core/read-only-inspection.d.ts +34 -0
- package/src/core/read-only-inspection.js +88 -0
- package/src/core/read-only-inspection.js.map +1 -0
- package/src/core/rejection-log.d.ts +9 -0
- package/src/core/rejection-log.js +262 -0
- package/src/core/rejection-log.js.map +1 -0
- package/src/core/rules/branch-creation-guard.d.ts +113 -0
- package/src/core/rules/branch-creation-guard.js +425 -0
- package/src/core/rules/branch-creation-guard.js.map +1 -0
- package/src/core/rules/branch-switch-scan.d.ts +43 -0
- package/src/core/rules/branch-switch-scan.js +132 -0
- package/src/core/rules/branch-switch-scan.js.map +1 -0
- package/src/core/rules/build-output-pipe-guard.d.ts +56 -0
- package/src/core/rules/build-output-pipe-guard.js +120 -0
- package/src/core/rules/build-output-pipe-guard.js.map +1 -0
- package/src/core/rules/build-output-pipe-scan.d.ts +47 -0
- package/src/core/rules/build-output-pipe-scan.js +84 -0
- package/src/core/rules/build-output-pipe-scan.js.map +1 -0
- package/src/core/rules/cap-remedies.d.ts +39 -0
- package/src/core/rules/cap-remedies.js +59 -0
- package/src/core/rules/cap-remedies.js.map +1 -0
- package/src/core/rules/commit-message-substitution-guard.d.ts +72 -0
- package/src/core/rules/commit-message-substitution-guard.js +134 -0
- package/src/core/rules/commit-message-substitution-guard.js.map +1 -0
- package/src/core/rules/commit-message-substitution-scan.d.ts +42 -0
- package/src/core/rules/commit-message-substitution-scan.js +145 -0
- package/src/core/rules/commit-message-substitution-scan.js.map +1 -0
- package/src/core/rules/content-read-scan.d.ts +76 -0
- package/src/core/rules/content-read-scan.js +176 -0
- package/src/core/rules/content-read-scan.js.map +1 -0
- package/src/core/rules/cure-prefix-scan.d.ts +64 -0
- package/src/core/rules/cure-prefix-scan.js +133 -0
- package/src/core/rules/cure-prefix-scan.js.map +1 -0
- package/src/core/rules/feature-branch-guard.d.ts +121 -0
- package/src/core/rules/feature-branch-guard.js +327 -0
- package/src/core/rules/feature-branch-guard.js.map +1 -0
- package/src/core/rules/index.d.ts +1 -0
- package/src/core/rules/index.js +5 -0
- package/src/core/rules/index.js.map +1 -0
- package/src/core/rules/judged-tree.d.ts +66 -0
- package/src/core/rules/judged-tree.js +97 -0
- package/src/core/rules/judged-tree.js.map +1 -0
- package/src/core/rules/main-freshness.d.ts +37 -0
- package/src/core/rules/main-freshness.js +61 -0
- package/src/core/rules/main-freshness.js.map +1 -0
- package/src/core/rules/merge-in-progress-guard.d.ts +17 -0
- package/src/core/rules/merge-in-progress-guard.js +124 -0
- package/src/core/rules/merge-in-progress-guard.js.map +1 -0
- package/src/core/rules/merged-branch-bash-guard.d.ts +62 -0
- package/src/core/rules/merged-branch-bash-guard.js +171 -0
- package/src/core/rules/merged-branch-bash-guard.js.map +1 -0
- package/src/core/rules/merged-branch-message.d.ts +59 -0
- package/src/core/rules/merged-branch-message.js +137 -0
- package/src/core/rules/merged-branch-message.js.map +1 -0
- package/src/core/rules/pr-creation-or-push-guard.d.ts +26 -0
- package/src/core/rules/pr-creation-or-push-guard.js +150 -0
- package/src/core/rules/pr-creation-or-push-guard.js.map +1 -0
- package/src/core/rules/pr-merge-guard.d.ts +36 -0
- package/src/core/rules/pr-merge-guard.js +87 -0
- package/src/core/rules/pr-merge-guard.js.map +1 -0
- package/src/core/rules/read-stale-guard.d.ts +136 -0
- package/src/core/rules/read-stale-guard.js +328 -0
- package/src/core/rules/read-stale-guard.js.map +1 -0
- package/src/core/rules/recovery-allowlist.d.ts +49 -0
- package/src/core/rules/recovery-allowlist.js +187 -0
- package/src/core/rules/recovery-allowlist.js.map +1 -0
- package/src/core/rules/redirect-how-to-merge-main.d.ts +16 -0
- package/src/core/rules/redirect-how-to-merge-main.js +159 -0
- package/src/core/rules/redirect-how-to-merge-main.js.map +1 -0
- package/src/core/rules/stale-main-bash-guard.d.ts +198 -0
- package/src/core/rules/stale-main-bash-guard.js +363 -0
- package/src/core/rules/stale-main-bash-guard.js.map +1 -0
- package/src/core/rules/stale-main-message.d.ts +62 -0
- package/src/core/rules/stale-main-message.js +102 -0
- package/src/core/rules/stale-main-message.js.map +1 -0
- package/src/core/rules/tree-recovery.d.ts +92 -0
- package/src/core/rules/tree-recovery.js +165 -0
- package/src/core/rules/tree-recovery.js.map +1 -0
- package/src/core/rules/wait-spin-guard.d.ts +128 -0
- package/src/core/rules/wait-spin-guard.js +211 -0
- package/src/core/rules/wait-spin-guard.js.map +1 -0
- package/src/core/rules/wait-spin-scan.d.ts +118 -0
- package/src/core/rules/wait-spin-scan.js +203 -0
- package/src/core/rules/wait-spin-scan.js.map +1 -0
- package/src/core/rules/whole-repo-build-guard.d.ts +125 -0
- package/src/core/rules/whole-repo-build-guard.js +257 -0
- package/src/core/rules/whole-repo-build-guard.js.map +1 -0
- package/src/core/rules/whole-repo-build-scan.d.ts +28 -0
- package/src/core/rules/whole-repo-build-scan.js +198 -0
- package/src/core/rules/whole-repo-build-scan.js.map +1 -0
- package/src/core/runner.d.ts +19 -0
- package/src/core/runner.js +482 -0
- package/src/core/runner.js.map +1 -0
- package/src/core/session-call-history.d.ts +44 -0
- package/src/core/session-call-history.js +79 -0
- package/src/core/session-call-history.js.map +1 -0
- package/src/core/sync-main.d.ts +46 -0
- package/src/core/sync-main.js +176 -0
- package/src/core/sync-main.js.map +1 -0
- package/src/core/version-sync.d.ts +219 -0
- package/src/core/version-sync.js +558 -0
- package/src/core/version-sync.js.map +1 -0
- package/src/core/webpieces-versions.d.ts +98 -0
- package/src/core/webpieces-versions.js +206 -0
- package/src/core/webpieces-versions.js.map +1 -0
- package/src/core/workflow-hook-rules.d.ts +5 -0
- package/src/core/workflow-hook-rules.js +15 -0
- package/src/core/workflow-hook-rules.js.map +1 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +28 -0
- package/src/index.js.map +1 -0
- package/src/policy-keys.d.ts +2 -0
- package/src/policy-keys.js +6 -0
- package/src/policy-keys.js.map +1 -0
- package/src/rule-migrations.d.ts +3 -0
- package/src/rule-migrations.js +22 -0
- package/src/rule-migrations.js.map +1 -0
- package/src/rule-pack.d.ts +2 -0
- package/src/rule-pack.js +20 -0
- package/src/rule-pack.js.map +1 -0
- package/src/rule-settings.d.ts +5 -0
- package/src/rule-settings.js +31 -0
- package/src/rule-settings.js.map +1 -0
- package/src/safeguard-catalog.d.ts +3 -0
- package/src/safeguard-catalog.js +16 -0
- package/src/safeguard-catalog.js.map +1 -0
- package/templates/ai-hook.sh +497 -0
- package/templates/claude-settings-hook.json +28 -0
- package/templates/webpieces-reviewer.md +60 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Opening marker of the generated block, as it appears in guards/L0-tooling.md. */
|
|
2
|
+
export declare const L0_DOC_BEGIN = "<!-- BEGIN GENERATED \u2014 L0ToolingDoc.render() in agent-workflow-rules/src/core/l0-tooling-doc.ts; run `pnpm guards:generate` -->";
|
|
3
|
+
/** Closing marker. Everything between the two is machine-owned; everything outside is prose. */
|
|
4
|
+
export declare const L0_DOC_END = "<!-- END GENERATED \u2014 hand-written prose resumes here -->";
|
|
5
|
+
/**
|
|
6
|
+
* The generated section of guards/L0-tooling.md, and the splice that puts it there.
|
|
7
|
+
*
|
|
8
|
+
* A class rather than a family of module functions (see l1-doc.ts, which predates the rule): the
|
|
9
|
+
* renderer, the extractor and the splicer are one unit, and the spec drives all three.
|
|
10
|
+
*/
|
|
11
|
+
export declare class L0ToolingDoc {
|
|
12
|
+
/** The whole generated block, WITHOUT the markers — those belong to the file, not to the renderer. */
|
|
13
|
+
render(): string;
|
|
14
|
+
/**
|
|
15
|
+
* The generated text of `doc`, exactly as committed. Throws when a marker is missing or doubled —
|
|
16
|
+
* a silently-unspliced doc is the drift this whole arrangement exists to end.
|
|
17
|
+
*/
|
|
18
|
+
extract(doc: string): string;
|
|
19
|
+
/** `doc` with the generated block replaced by today's render. Preserves every byte outside it. */
|
|
20
|
+
splice(doc: string): string;
|
|
21
|
+
/** A markdown cell: a literal `|` inside a value would end the column. */
|
|
22
|
+
private cell;
|
|
23
|
+
private preamble;
|
|
24
|
+
private faultTable;
|
|
25
|
+
/**
|
|
26
|
+
* The cures, one row per option. LITERAL commands only, rendered from `L0_FAULTS[].cures` — the same
|
|
27
|
+
* array `webpieces.guard-matrix.md` renders its Fix sections from, so the two can never prescribe
|
|
28
|
+
* different commands for one fault.
|
|
29
|
+
*/
|
|
30
|
+
private fixTable;
|
|
31
|
+
private matrixTable;
|
|
32
|
+
private allowlistTable;
|
|
33
|
+
/**
|
|
34
|
+
* Fault `S`'s subject: the managed things, and every registration rendered from the harness's own
|
|
35
|
+
* `shimCommand()` — which is what makes "they are ABSOLUTE" a fact this doc cannot get wrong, and
|
|
36
|
+
* what keeps it from describing Claude Code's matcher as if it were Codex's.
|
|
37
|
+
*/
|
|
38
|
+
private managedSurface;
|
|
39
|
+
/**
|
|
40
|
+
* The audit line, rendered from `SHIM_LOG_FIELDS` + `SHIM_LOG_VERDICTS`. The optional field prints
|
|
41
|
+
* in brackets because that is exactly what it is: `bin=` appears only when it differs from `shim=`.
|
|
42
|
+
*/
|
|
43
|
+
private auditLine;
|
|
44
|
+
private logPaths;
|
|
45
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.L0ToolingDoc = exports.L0_DOC_END = exports.L0_DOC_BEGIN = void 0;
|
|
4
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
5
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
6
|
+
const shim_1 = require("../bin/shim");
|
|
7
|
+
const hook_registration_1 = require("../bin/hook-registration");
|
|
8
|
+
const rules_config_2 = require("@webpieces/rules-config");
|
|
9
|
+
const log_streams_1 = require("./log-streams");
|
|
10
|
+
const l0_matrix_1 = require("./l0-matrix");
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// THE GENERATED HALF OF guards/L0-tooling.md.
|
|
13
|
+
//
|
|
14
|
+
// That file is the largest guard doc in the repo and, unlike its two siblings, it was hand-written from
|
|
15
|
+
// end to end — so it went stale twice in one session: it described FOUR managed surfaces after there
|
|
16
|
+
// were three, and a 7-field audit line after `shim=`/`bin=`/`layer=`/`row=` had joined it.
|
|
17
|
+
//
|
|
18
|
+
// The split, and WHY it is a split rather than a whole-file renderer:
|
|
19
|
+
//
|
|
20
|
+
// GENERATED (here) anything that is a COORDINATE of the code — the fault codes and their guard
|
|
21
|
+
// names, the cures, the three matrix rows, the allowlist, the managed surfaces,
|
|
22
|
+
// the audit-line fields and the verdict vocabulary. Every one of those is
|
|
23
|
+
// already an array somewhere; a doc that re-types them is a second spelling.
|
|
24
|
+
// HAND-WRITTEN (there) the incident histories, the config-validation invariant, the known gaps, the
|
|
25
|
+
// worked example. That is argument, not data, and a renderer would mangle it.
|
|
26
|
+
//
|
|
27
|
+
// The section is spliced BETWEEN two literal markers, the pattern renderL1Doc() already uses for its
|
|
28
|
+
// prose/table interleave, so the prose surrounds the tables instead of being swallowed by them.
|
|
29
|
+
// `pnpm guards:generate` rewrites the block and `l0-tooling-doc.spec.ts` locks it byte-for-byte.
|
|
30
|
+
//
|
|
31
|
+
// EVERY COMMAND PRINTED HERE COMES FROM A CONSTANT, never a retyped literal: the L0 allowlist matches
|
|
32
|
+
// WHOLE command strings, so a paraphrased cure in a doc is an unrunnable cure. The spec re-asserts that
|
|
33
|
+
// by running isAllowed() over every command this renderer prints.
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
/** Opening marker of the generated block, as it appears in guards/L0-tooling.md. */
|
|
36
|
+
exports.L0_DOC_BEGIN = '<!-- BEGIN GENERATED — L0ToolingDoc.render() in agent-workflow-rules/src/core/l0-tooling-doc.ts; run `pnpm guards:generate` -->';
|
|
37
|
+
/** Closing marker. Everything between the two is machine-owned; everything outside is prose. */
|
|
38
|
+
exports.L0_DOC_END = '<!-- END GENERATED — hand-written prose resumes here -->';
|
|
39
|
+
/**
|
|
40
|
+
* The generated section of guards/L0-tooling.md, and the splice that puts it there.
|
|
41
|
+
*
|
|
42
|
+
* A class rather than a family of module functions (see l1-doc.ts, which predates the rule): the
|
|
43
|
+
* renderer, the extractor and the splicer are one unit, and the spec drives all three.
|
|
44
|
+
*/
|
|
45
|
+
class L0ToolingDoc {
|
|
46
|
+
/** The whole generated block, WITHOUT the markers — those belong to the file, not to the renderer. */
|
|
47
|
+
render() {
|
|
48
|
+
return [
|
|
49
|
+
...this.preamble(),
|
|
50
|
+
...this.faultTable(),
|
|
51
|
+
...this.fixTable(),
|
|
52
|
+
...this.matrixTable(),
|
|
53
|
+
...this.allowlistTable(),
|
|
54
|
+
...this.managedSurface(),
|
|
55
|
+
...this.auditLine(),
|
|
56
|
+
].join('\n');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The generated text of `doc`, exactly as committed. Throws when a marker is missing or doubled —
|
|
60
|
+
* a silently-unspliced doc is the drift this whole arrangement exists to end.
|
|
61
|
+
*/
|
|
62
|
+
extract(doc) {
|
|
63
|
+
const opens = doc.split(exports.L0_DOC_BEGIN).length - 1;
|
|
64
|
+
const closes = doc.split(exports.L0_DOC_END).length - 1;
|
|
65
|
+
if (opens !== 1 || closes !== 1) {
|
|
66
|
+
throw new Error(`guards/L0-tooling.md must carry exactly one BEGIN/END marker pair, found ${String(opens)}/${String(closes)}`);
|
|
67
|
+
}
|
|
68
|
+
const afterBegin = doc.slice(doc.indexOf(exports.L0_DOC_BEGIN) + exports.L0_DOC_BEGIN.length);
|
|
69
|
+
return afterBegin.slice(0, afterBegin.indexOf(exports.L0_DOC_END)).replace(/^\n/, '').replace(/\n$/, '');
|
|
70
|
+
}
|
|
71
|
+
/** `doc` with the generated block replaced by today's render. Preserves every byte outside it. */
|
|
72
|
+
splice(doc) {
|
|
73
|
+
const head = doc.slice(0, doc.indexOf(exports.L0_DOC_BEGIN) + exports.L0_DOC_BEGIN.length);
|
|
74
|
+
const tail = doc.slice(doc.indexOf(exports.L0_DOC_END));
|
|
75
|
+
// extract() is called for its VALIDATION — one marker pair — before anything is rewritten.
|
|
76
|
+
this.extract(doc);
|
|
77
|
+
return `${head}\n${this.render()}\n${tail}`;
|
|
78
|
+
}
|
|
79
|
+
/** A markdown cell: a literal `|` inside a value would end the column. */
|
|
80
|
+
cell(value) {
|
|
81
|
+
return value.split('|').join('\\|');
|
|
82
|
+
}
|
|
83
|
+
preamble() {
|
|
84
|
+
return [
|
|
85
|
+
'> **GENERATED — do not hand-edit between the markers.** Rendered by `L0ToolingDoc.render()`',
|
|
86
|
+
'> (`agent-workflow-rules/src/core/l0-tooling-doc.ts`) from `L0_FAULTS`, `L0_ALLOWLIST`, the managed-surface',
|
|
87
|
+
'> constants and `SHIM_LOG_FIELDS` — the same arrays the guard consults. `pnpm guards:generate`',
|
|
88
|
+
'> rewrites it; `l0-tooling-doc.spec.ts` locks it byte-for-byte. The prose outside the markers is',
|
|
89
|
+
'> hand-written and stays that way.',
|
|
90
|
+
'',
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
faultTable() {
|
|
94
|
+
return [
|
|
95
|
+
'### The faults',
|
|
96
|
+
'',
|
|
97
|
+
'| code | guard name | fault | detected by | enforced in |',
|
|
98
|
+
'|---|---|---|---|---|',
|
|
99
|
+
...l0_matrix_1.L0_FAULTS.map((f) => `| \`${f.code}\` | \`${rules_config_2.L0_FAULT_NAMES[f.code]}\` | ${this.cell(f.name)} | ${f.detectedBy} | ${f.enforcedIn} |`),
|
|
100
|
+
'',
|
|
101
|
+
`First match wins. \`${rules_config_2.L0_SH_FAULT_CODES.join('`/`')}\` are decided in POSIX \`sh\` inside the committed shim, BEFORE`,
|
|
102
|
+
`the guard bin runs — a stale, missing or broken validator cannot be trusted to validate itself.`,
|
|
103
|
+
`\`${rules_config_2.L0_JS_FAULT_CODES.join('`/`')}\` are decided inside the bin, in JS.`,
|
|
104
|
+
'',
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The cures, one row per option. LITERAL commands only, rendered from `L0_FAULTS[].cures` — the same
|
|
109
|
+
* array `webpieces.guard-matrix.md` renders its Fix sections from, so the two can never prescribe
|
|
110
|
+
* different commands for one fault.
|
|
111
|
+
*/
|
|
112
|
+
fixTable() {
|
|
113
|
+
const rows = [];
|
|
114
|
+
for (const fault of l0_matrix_1.L0_FAULTS) {
|
|
115
|
+
fault.cures.forEach((cure, i) => {
|
|
116
|
+
const literal = cure.isCommand() ? `\`${cure.call.command}\`` : `edit \`${cure.mention}\` yourself`;
|
|
117
|
+
const option = `${String(i + 1)}${cure.preferred ? ' (preferred)' : ''}`;
|
|
118
|
+
rows.push(`| \`${fault.code}\` | ${option} | ${this.cell(literal)} | ${this.cell(cure.discriminator)} |`);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return [
|
|
122
|
+
'### The fix, per fault — type the option EXACTLY as written, and run nothing else on that line',
|
|
123
|
+
'',
|
|
124
|
+
'| fault | option | run EXACTLY | pick this when |',
|
|
125
|
+
'|---|---|---|---|',
|
|
126
|
+
...rows,
|
|
127
|
+
'',
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
matrixTable() {
|
|
131
|
+
return [
|
|
132
|
+
'### The matrix — three rows, and the fault only picks the MESSAGE',
|
|
133
|
+
'',
|
|
134
|
+
`| row | fault | on the allowlist? | outcome | logged as |`,
|
|
135
|
+
'|---|---|---|---|---|',
|
|
136
|
+
`| ${rules_config_2.L0_ROW_HANDED_DOWN} | none | — | hand down to the next guard layer | \`layer=${rules_config_2.L0_LAYER} row=${rules_config_2.L0_ROW_HANDED_DOWN}\` |`,
|
|
137
|
+
`| ${rules_config_2.L0_ROW_ALLOWLISTED} | any | yes | PASS or ALLOW (see the entry) | \`layer=${rules_config_2.L0_LAYER} row=${rules_config_2.L0_ROW_ALLOWLISTED}\` |`,
|
|
138
|
+
`| ${rules_config_2.L0_ROW_BLOCKED} | any | no | BLOCK — **only the message varies by fault** | \`layer=${rules_config_2.L0_LAYER} row=${rules_config_2.L0_ROW_BLOCKED}\` |`,
|
|
139
|
+
'',
|
|
140
|
+
'The tool is not a dimension either: "any Read" is an allowlist ENTRY, not a tool check. Those are',
|
|
141
|
+
'the same coordinates every L0 deny opens with, so a deny, a log line and this table join by eye.',
|
|
142
|
+
'',
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
allowlistTable() {
|
|
146
|
+
return [
|
|
147
|
+
'### The allowlist — ONE list, consulted identically by every fault',
|
|
148
|
+
'',
|
|
149
|
+
'| # | allowed | outcome | bypasses L1 on a HEALTHY tree? |',
|
|
150
|
+
'|---|---|---|---|',
|
|
151
|
+
...shim_1.L0_ALLOWLIST.map((e, i) => `| ${String(i + 1)} | ${this.cell(e.label)} | ${e.kind.toUpperCase()} | ${e.cure ? 'yes — it REPAIRS the tooling' : 'no — it repairs nothing, so L1 still judges it'} |`),
|
|
152
|
+
'',
|
|
153
|
+
'- **PASS** — L0 has no objection; the call falls THROUGH so downstream guards still judge it.',
|
|
154
|
+
'- **ALLOW** — terminal; bypasses everything, because a cure must stay reachable even when a',
|
|
155
|
+
' downstream guard would block it.',
|
|
156
|
+
'',
|
|
157
|
+
'Every Bash entry is anchored to the WHOLE command. Appending `&& git status` makes it a DIFFERENT',
|
|
158
|
+
'command and it is rejected again — that is not the guard refusing its own cure.',
|
|
159
|
+
'',
|
|
160
|
+
'On an UNGATED entry a leading `cd <dir> &&`, a trailing `2>&1` and a pipe into `tail`/`head` are',
|
|
161
|
+
'tolerated; nothing else. **The harness-gated read row tolerates NONE of the three** — not the',
|
|
162
|
+
'`cd` prefix, not the redirect, not the pipe — so `cat f 2>&1` and `cat f | head -20` are both',
|
|
163
|
+
'rejected. That is deliberate, not an oversight: the row means exactly what',
|
|
164
|
+
'`core/shell-read-parity.ts` means by "this is a read", and that module treats a pipe or a',
|
|
165
|
+
'redirect as proof the command is more than one. Type the bare command.',
|
|
166
|
+
'',
|
|
167
|
+
'`git merge` and a **bare** `git pull` are both deliberately absent — see "The git-sync split"',
|
|
168
|
+
'below for why the one safe pull spelling is on the list and the bare one is not. Main is merged',
|
|
169
|
+
'ONLY through the 3-point fork merge (`pnpm wp-start-update`, or `pnpm wp-start-upsert-pr` when a',
|
|
170
|
+
'PR is already open).',
|
|
171
|
+
'',
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Fault `S`'s subject: the managed things, and every registration rendered from the harness's own
|
|
176
|
+
* `shimCommand()` — which is what makes "they are ABSOLUTE" a fact this doc cannot get wrong, and
|
|
177
|
+
* what keeps it from describing Claude Code's matcher as if it were Codex's.
|
|
178
|
+
*/
|
|
179
|
+
managedSurface() {
|
|
180
|
+
const surfaces = [
|
|
181
|
+
hook_registration_1.SHIM_SURFACE,
|
|
182
|
+
...hook_registration_1.HARNESS_REGISTRATIONS.flatMap((h) => [h.registrationSurface, h.neighbourSurface]),
|
|
183
|
+
hook_registration_1.ENV_SURFACE,
|
|
184
|
+
hook_registration_1.REVIEWER_AGENT_SURFACE,
|
|
185
|
+
];
|
|
186
|
+
const registrations = [];
|
|
187
|
+
for (const harness of hook_registration_1.HARNESS_REGISTRATIONS) {
|
|
188
|
+
registrations.push(`# ${harness.label}`);
|
|
189
|
+
registrations.push(harness.shimCommand(hook_registration_1.GUARDS_BIN));
|
|
190
|
+
registrations.push(harness.shimCommand(hook_registration_1.RULES_BIN));
|
|
191
|
+
}
|
|
192
|
+
return [
|
|
193
|
+
`### The managed hook surface — what fault \`S\` compares (${String(surfaces.length)} things, one set)`,
|
|
194
|
+
'',
|
|
195
|
+
'| # | surface |',
|
|
196
|
+
'|---|---|',
|
|
197
|
+
// The shim is a bare PATH and the others are prose naming a file, so only the first is
|
|
198
|
+
// wrapped in code ticks — the same rendering this table has always had, now generated.
|
|
199
|
+
...surfaces.map((surface, i) => `| ${String(i + 1)} | ${i === 0 ? `\`${surface}\`` : this.cell(surface)} |`),
|
|
200
|
+
'',
|
|
201
|
+
'The registration is TWO PreToolUse entries per harness, and all of them are ABSOLUTE — they',
|
|
202
|
+
'resolve from any cwd:',
|
|
203
|
+
'',
|
|
204
|
+
'```',
|
|
205
|
+
...registrations,
|
|
206
|
+
'```',
|
|
207
|
+
'',
|
|
208
|
+
`\`${shim_1.UPGRADE_SHIM_CMD}\` repairs all ${String(surfaces.length)}. \`${shim_1.RESTORE_SHIM_CMD}\``,
|
|
209
|
+
`repairs \`${hook_registration_1.SHIM_SURFACE}\` and nothing else, so it is the fallback for an installed release too old`,
|
|
210
|
+
'to carry the first.',
|
|
211
|
+
'',
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The audit line, rendered from `SHIM_LOG_FIELDS` + `SHIM_LOG_VERDICTS`. The optional field prints
|
|
216
|
+
* in brackets because that is exactly what it is: `bin=` appears only when it differs from `shim=`.
|
|
217
|
+
*/
|
|
218
|
+
auditLine() {
|
|
219
|
+
const shape = shim_1.SHIM_LOG_FIELDS.map((f) => (f.optional ? `[${f.label}]` : f.label)).join(' ');
|
|
220
|
+
return [
|
|
221
|
+
'### The L0 audit line — one tab-separated line per tool call',
|
|
222
|
+
'',
|
|
223
|
+
'```',
|
|
224
|
+
shape,
|
|
225
|
+
'```',
|
|
226
|
+
'',
|
|
227
|
+
'| # | field | means |',
|
|
228
|
+
'|---|---|---|',
|
|
229
|
+
...shim_1.SHIM_LOG_FIELDS.map((f, i) => `| ${String(i + 1)} | \`${this.cell(f.label)}\` | ${this.cell(f.means)} |`),
|
|
230
|
+
'',
|
|
231
|
+
'| verdict | means |',
|
|
232
|
+
'|---|---|',
|
|
233
|
+
...shim_1.SHIM_LOG_VERDICTS.map((v) => `| \`${v.label}\` | ${this.cell(v.means)} |`),
|
|
234
|
+
'',
|
|
235
|
+
...this.logPaths(),
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
logPaths() {
|
|
239
|
+
const stream = `${tooling_common_1.LOGS_STATE_DIR}/${log_streams_1.L0_SHIM_STREAM}/<session>-<agent|coordinator>-<binName>.log`;
|
|
240
|
+
return [
|
|
241
|
+
'It lands in the log directory of the tree the CALL was made in, centralized under the primary clone',
|
|
242
|
+
'so that removing a worktree does not take its audit trail with it:',
|
|
243
|
+
'',
|
|
244
|
+
'```',
|
|
245
|
+
`<primary>/${tooling_common_1.WEBPIECES_TMP_DIR}/${tooling_common_1.WORKTREE_STATE_DIR}/<tree>/${stream}`,
|
|
246
|
+
`<primary>/${tooling_common_1.WEBPIECES_TMP_DIR}/${stream} # from the primary clone itself`,
|
|
247
|
+
'```',
|
|
248
|
+
'',
|
|
249
|
+
`The binary stamps the same \`layer=\`/\`row=\`/\`fault=\` fields onto its OWN streams —`,
|
|
250
|
+
`\`${log_streams_1.L1_LOCATION_STREAM}/\`, \`${log_streams_1.L2_DECISIONS_STREAM}/\`, \`${log_streams_1.CALLS_STREAM}/\` and \`${log_streams_1.REJECTIONS_STREAM}/\` under the same`,
|
|
251
|
+
`\`${tooling_common_1.LOGS_STATE_DIR}/\` — so one grep spans the whole trail. A \`${rules_config_1.CONFIG_FILENAME}\` fault (\`C\`/\`Y\`) is`,
|
|
252
|
+
'therefore visible there and never on an `L0-shim` line, which only ever carries the `sh`-side codes.',
|
|
253
|
+
'',
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.L0ToolingDoc = L0ToolingDoc;
|
|
258
|
+
//# sourceMappingURL=l0-tooling-doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l0-tooling-doc.js","sourceRoot":"","sources":["../../../../../../packages/tooling/agent-workflow-rules/src/core/l0-tooling-doc.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAC1D,8DAAkG;AAElG,sCAA+J;AAC/J,gEAAgK;AAChK,0DAA8K;AAC9K,+CAAyH;AACzH,2CAAyD;AAEzD,8EAA8E;AAC9E,8CAA8C;AAC9C,EAAE;AACF,wGAAwG;AACxG,qGAAqG;AACrG,2FAA2F;AAC3F,EAAE;AACF,sEAAsE;AACtE,EAAE;AACF,sGAAsG;AACtG,wGAAwG;AACxG,kGAAkG;AAClG,qGAAqG;AACrG,uGAAuG;AACvG,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Q,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;YAC/E,EAAE;YACF,qBAAqB;YACrB,WAAW;YACX,GAAG,wBAAiB,CAAC,GAAG,CAAC,CAAC,CAAiB,EAAU,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;YACrG,EAAE;YACF,GAAG,IAAI,CAAC,QAAQ,EAAE;SACrB,CAAC;IACN,CAAC;IAEO,QAAQ;QACZ,MAAM,MAAM,GAAG,GAAG,+BAAc,IAAI,4BAAc,8CAA8C,CAAC;QACjG,OAAO;YACH,qGAAqG;YACrG,oEAAoE;YACpE,EAAE;YACF,KAAK;YACL,aAAa,kCAAiB,IAAI,mCAAkB,WAAW,MAAM,EAAE;YACvE,aAAa,kCAAiB,IAAI,MAAM,oCAAoC;YAC5E,KAAK;YACL,EAAE;YACF,yFAAyF;YACzF,KAAK,gCAAkB,UAAU,iCAAmB,UAAU,0BAAY,aAAa,+BAAiB,oBAAoB;YAC5H,KAAK,+BAAc,gDAAgD,8BAAe,2BAA2B;YAC7G,sGAAsG;YACtG,EAAE;SACL,CAAC;IACN,CAAC;CACJ;AAlOD,oCAkOC","sourcesContent":["import { CONFIG_FILENAME } from '@webpieces/rules-config';\nimport { LOGS_STATE_DIR, WEBPIECES_TMP_DIR, WORKTREE_STATE_DIR } from '@webpieces/tooling-common';\n\nimport { L0AllowEntry, L0_ALLOWLIST, RESTORE_SHIM_CMD, SHIM_LOG_FIELDS, SHIM_LOG_VERDICTS, ShimLogField, ShimLogVerdict, UPGRADE_SHIM_CMD } from '../bin/shim';\nimport { ENV_SURFACE, GUARDS_BIN, RULES_BIN, SHIM_SURFACE, HARNESS_REGISTRATIONS, HarnessRegistration, REVIEWER_AGENT_SURFACE } from '../bin/hook-registration';\nimport { L0FaultCode, L0_FAULT_NAMES, L0_JS_FAULT_CODES, L0_LAYER, L0_ROW_ALLOWLISTED, L0_ROW_BLOCKED, L0_ROW_HANDED_DOWN, L0_SH_FAULT_CODES } from '@webpieces/rules-config';\nimport { CALLS_STREAM, L0_SHIM_STREAM, L1_LOCATION_STREAM, L2_DECISIONS_STREAM, REJECTIONS_STREAM } from './log-streams';\nimport { L0Cure, L0Fault, L0_FAULTS } from './l0-matrix';\n\n// ---------------------------------------------------------------------------\n// THE GENERATED HALF OF guards/L0-tooling.md.\n//\n// That file is the largest guard doc in the repo and, unlike its two siblings, it was hand-written from\n// end to end — so it went stale twice in one session: it described FOUR managed surfaces after there\n// were three, and a 7-field audit line after `shim=`/`bin=`/`layer=`/`row=` had joined it.\n//\n// The split, and WHY it is a split rather than a whole-file renderer:\n//\n// GENERATED (here) anything that is a COORDINATE of the code — the fault codes and their guard\n// names, the cures, the three matrix rows, the allowlist, the managed surfaces,\n// the audit-line fields and the verdict vocabulary. Every one of those is\n// already an array somewhere; a doc that re-types them is a second spelling.\n// HAND-WRITTEN (there) the incident histories, the config-validation invariant, the known gaps, the\n// worked example. That is argument, not data, and a renderer would mangle it.\n//\n// The section is spliced BETWEEN two literal markers, the pattern renderL1Doc() already uses for its\n// prose/table interleave, so the prose surrounds the tables instead of being swallowed by them.\n// `pnpm guards:generate` rewrites the block and `l0-tooling-doc.spec.ts` locks it byte-for-byte.\n//\n// EVERY COMMAND PRINTED HERE COMES FROM A CONSTANT, never a retyped literal: the L0 allowlist matches\n// WHOLE command strings, so a paraphrased cure in a doc is an unrunnable cure. The spec re-asserts that\n// by running isAllowed() over every command this renderer prints.\n// ---------------------------------------------------------------------------\n\n/** Opening marker of the generated block, as it appears in guards/L0-tooling.md. */\nexport const L0_DOC_BEGIN = '<!-- BEGIN GENERATED — L0ToolingDoc.render() in agent-workflow-rules/src/core/l0-tooling-doc.ts; run `pnpm guards:generate` -->';\n\n/** Closing marker. Everything between the two is machine-owned; everything outside is prose. */\nexport const L0_DOC_END = '<!-- END GENERATED — hand-written prose resumes here -->';\n\n/**\n * The generated section of guards/L0-tooling.md, and the splice that puts it there.\n *\n * A class rather than a family of module functions (see l1-doc.ts, which predates the rule): the\n * renderer, the extractor and the splicer are one unit, and the spec drives all three.\n */\nexport class L0ToolingDoc {\n /** The whole generated block, WITHOUT the markers — those belong to the file, not to the renderer. */\n render(): string {\n return [\n ...this.preamble(),\n ...this.faultTable(),\n ...this.fixTable(),\n ...this.matrixTable(),\n ...this.allowlistTable(),\n ...this.managedSurface(),\n ...this.auditLine(),\n ].join('\\n');\n }\n\n /**\n * The generated text of `doc`, exactly as committed. Throws when a marker is missing or doubled —\n * a silently-unspliced doc is the drift this whole arrangement exists to end.\n */\n extract(doc: string): string {\n const opens = doc.split(L0_DOC_BEGIN).length - 1;\n const closes = doc.split(L0_DOC_END).length - 1;\n if (opens !== 1 || closes !== 1) {\n throw new Error(`guards/L0-tooling.md must carry exactly one BEGIN/END marker pair, found ${String(opens)}/${String(closes)}`);\n }\n const afterBegin = doc.slice(doc.indexOf(L0_DOC_BEGIN) + L0_DOC_BEGIN.length);\n return afterBegin.slice(0, afterBegin.indexOf(L0_DOC_END)).replace(/^\\n/, '').replace(/\\n$/, '');\n }\n\n /** `doc` with the generated block replaced by today's render. Preserves every byte outside it. */\n splice(doc: string): string {\n const head = doc.slice(0, doc.indexOf(L0_DOC_BEGIN) + L0_DOC_BEGIN.length);\n const tail = doc.slice(doc.indexOf(L0_DOC_END));\n // extract() is called for its VALIDATION — one marker pair — before anything is rewritten.\n this.extract(doc);\n return `${head}\\n${this.render()}\\n${tail}`;\n }\n\n /** A markdown cell: a literal `|` inside a value would end the column. */\n private cell(value: string): string {\n return value.split('|').join('\\\\|');\n }\n\n private preamble(): string[] {\n return [\n '> **GENERATED — do not hand-edit between the markers.** Rendered by `L0ToolingDoc.render()`',\n '> (`agent-workflow-rules/src/core/l0-tooling-doc.ts`) from `L0_FAULTS`, `L0_ALLOWLIST`, the managed-surface',\n '> constants and `SHIM_LOG_FIELDS` — the same arrays the guard consults. `pnpm guards:generate`',\n '> rewrites it; `l0-tooling-doc.spec.ts` locks it byte-for-byte. The prose outside the markers is',\n '> hand-written and stays that way.',\n '',\n ];\n }\n\n private faultTable(): string[] {\n return [\n '### The faults',\n '',\n '| code | guard name | fault | detected by | enforced in |',\n '|---|---|---|---|---|',\n ...L0_FAULTS.map((f: L0Fault): string =>\n `| \\`${f.code}\\` | \\`${L0_FAULT_NAMES[f.code as L0FaultCode]}\\` | ${this.cell(f.name)} | ${f.detectedBy} | ${f.enforcedIn} |`),\n '',\n `First match wins. \\`${L0_SH_FAULT_CODES.join('`/`')}\\` are decided in POSIX \\`sh\\` inside the committed shim, BEFORE`,\n `the guard bin runs — a stale, missing or broken validator cannot be trusted to validate itself.`,\n `\\`${L0_JS_FAULT_CODES.join('`/`')}\\` are decided inside the bin, in JS.`,\n '',\n ];\n }\n\n /**\n * The cures, one row per option. LITERAL commands only, rendered from `L0_FAULTS[].cures` — the same\n * array `webpieces.guard-matrix.md` renders its Fix sections from, so the two can never prescribe\n * different commands for one fault.\n */\n private fixTable(): string[] {\n const rows: string[] = [];\n for (const fault of L0_FAULTS) {\n fault.cures.forEach((cure: L0Cure, i: number): void => {\n const literal = cure.isCommand() ? `\\`${cure.call.command}\\`` : `edit \\`${cure.mention}\\` yourself`;\n const option = `${String(i + 1)}${cure.preferred ? ' (preferred)' : ''}`;\n rows.push(`| \\`${fault.code}\\` | ${option} | ${this.cell(literal)} | ${this.cell(cure.discriminator)} |`);\n });\n }\n return [\n '### The fix, per fault — type the option EXACTLY as written, and run nothing else on that line',\n '',\n '| fault | option | run EXACTLY | pick this when |',\n '|---|---|---|---|',\n ...rows,\n '',\n ];\n }\n\n private matrixTable(): string[] {\n return [\n '### The matrix — three rows, and the fault only picks the MESSAGE',\n '',\n `| row | fault | on the allowlist? | outcome | logged as |`,\n '|---|---|---|---|---|',\n `| ${L0_ROW_HANDED_DOWN} | none | — | hand down to the next guard layer | \\`layer=${L0_LAYER} row=${L0_ROW_HANDED_DOWN}\\` |`,\n `| ${L0_ROW_ALLOWLISTED} | any | yes | PASS or ALLOW (see the entry) | \\`layer=${L0_LAYER} row=${L0_ROW_ALLOWLISTED}\\` |`,\n `| ${L0_ROW_BLOCKED} | any | no | BLOCK — **only the message varies by fault** | \\`layer=${L0_LAYER} row=${L0_ROW_BLOCKED}\\` |`,\n '',\n 'The tool is not a dimension either: \"any Read\" is an allowlist ENTRY, not a tool check. Those are',\n 'the same coordinates every L0 deny opens with, so a deny, a log line and this table join by eye.',\n '',\n ];\n }\n\n private allowlistTable(): string[] {\n return [\n '### The allowlist — ONE list, consulted identically by every fault',\n '',\n '| # | allowed | outcome | bypasses L1 on a HEALTHY tree? |',\n '|---|---|---|---|',\n ...L0_ALLOWLIST.map((e: L0AllowEntry, i: number): string =>\n `| ${String(i + 1)} | ${this.cell(e.label)} | ${e.kind.toUpperCase()} | ${e.cure ? 'yes — it REPAIRS the tooling' : 'no — it repairs nothing, so L1 still judges it'} |`),\n '',\n '- **PASS** — L0 has no objection; the call falls THROUGH so downstream guards still judge it.',\n '- **ALLOW** — terminal; bypasses everything, because a cure must stay reachable even when a',\n ' downstream guard would block it.',\n '',\n 'Every Bash entry is anchored to the WHOLE command. Appending `&& git status` makes it a DIFFERENT',\n 'command and it is rejected again — that is not the guard refusing its own cure.',\n '',\n 'On an UNGATED entry a leading `cd <dir> &&`, a trailing `2>&1` and a pipe into `tail`/`head` are',\n 'tolerated; nothing else. **The harness-gated read row tolerates NONE of the three** — not the',\n '`cd` prefix, not the redirect, not the pipe — so `cat f 2>&1` and `cat f | head -20` are both',\n 'rejected. That is deliberate, not an oversight: the row means exactly what',\n '`core/shell-read-parity.ts` means by \"this is a read\", and that module treats a pipe or a',\n 'redirect as proof the command is more than one. Type the bare command.',\n '',\n '`git merge` and a **bare** `git pull` are both deliberately absent — see \"The git-sync split\"',\n 'below for why the one safe pull spelling is on the list and the bare one is not. Main is merged',\n 'ONLY through the 3-point fork merge (`pnpm wp-start-update`, or `pnpm wp-start-upsert-pr` when a',\n 'PR is already open).',\n '',\n ];\n }\n\n /**\n * Fault `S`'s subject: the managed things, and every registration rendered from the harness's own\n * `shimCommand()` — which is what makes \"they are ABSOLUTE\" a fact this doc cannot get wrong, and\n * what keeps it from describing Claude Code's matcher as if it were Codex's.\n */\n private managedSurface(): string[] {\n const surfaces = [\n SHIM_SURFACE,\n ...HARNESS_REGISTRATIONS.flatMap((h: HarnessRegistration): readonly string[] => [h.registrationSurface, h.neighbourSurface]),\n ENV_SURFACE,\n REVIEWER_AGENT_SURFACE,\n ];\n const registrations: string[] = [];\n for (const harness of HARNESS_REGISTRATIONS) {\n registrations.push(`# ${harness.label}`);\n registrations.push(harness.shimCommand(GUARDS_BIN));\n registrations.push(harness.shimCommand(RULES_BIN));\n }\n return [\n `### The managed hook surface — what fault \\`S\\` compares (${String(surfaces.length)} things, one set)`,\n '',\n '| # | surface |',\n '|---|---|',\n // The shim is a bare PATH and the others are prose naming a file, so only the first is\n // wrapped in code ticks — the same rendering this table has always had, now generated.\n ...surfaces.map((surface: string, i: number): string =>\n `| ${String(i + 1)} | ${i === 0 ? `\\`${surface}\\`` : this.cell(surface)} |`),\n '',\n 'The registration is TWO PreToolUse entries per harness, and all of them are ABSOLUTE — they',\n 'resolve from any cwd:',\n '',\n '```',\n ...registrations,\n '```',\n '',\n `\\`${UPGRADE_SHIM_CMD}\\` repairs all ${String(surfaces.length)}. \\`${RESTORE_SHIM_CMD}\\``,\n `repairs \\`${SHIM_SURFACE}\\` and nothing else, so it is the fallback for an installed release too old`,\n 'to carry the first.',\n '',\n ];\n }\n\n /**\n * The audit line, rendered from `SHIM_LOG_FIELDS` + `SHIM_LOG_VERDICTS`. The optional field prints\n * in brackets because that is exactly what it is: `bin=` appears only when it differs from `shim=`.\n */\n private auditLine(): string[] {\n const shape = SHIM_LOG_FIELDS.map((f: ShimLogField): string => (f.optional ? `[${f.label}]` : f.label)).join(' ');\n return [\n '### The L0 audit line — one tab-separated line per tool call',\n '',\n '```',\n shape,\n '```',\n '',\n '| # | field | means |',\n '|---|---|---|',\n ...SHIM_LOG_FIELDS.map((f: ShimLogField, i: number): string =>\n `| ${String(i + 1)} | \\`${this.cell(f.label)}\\` | ${this.cell(f.means)} |`),\n '',\n '| verdict | means |',\n '|---|---|',\n ...SHIM_LOG_VERDICTS.map((v: ShimLogVerdict): string => `| \\`${v.label}\\` | ${this.cell(v.means)} |`),\n '',\n ...this.logPaths(),\n ];\n }\n\n private logPaths(): string[] {\n const stream = `${LOGS_STATE_DIR}/${L0_SHIM_STREAM}/<session>-<agent|coordinator>-<binName>.log`;\n return [\n 'It lands in the log directory of the tree the CALL was made in, centralized under the primary clone',\n 'so that removing a worktree does not take its audit trail with it:',\n '',\n '```',\n `<primary>/${WEBPIECES_TMP_DIR}/${WORKTREE_STATE_DIR}/<tree>/${stream}`,\n `<primary>/${WEBPIECES_TMP_DIR}/${stream} # from the primary clone itself`,\n '```',\n '',\n `The binary stamps the same \\`layer=\\`/\\`row=\\`/\\`fault=\\` fields onto its OWN streams —`,\n `\\`${L1_LOCATION_STREAM}/\\`, \\`${L2_DECISIONS_STREAM}/\\`, \\`${CALLS_STREAM}/\\` and \\`${REJECTIONS_STREAM}/\\` under the same`,\n `\\`${LOGS_STATE_DIR}/\\` — so one grep spans the whole trail. A \\`${CONFIG_FILENAME}\\` fault (\\`C\\`/\\`Y\\`) is`,\n 'therefore visible there and never on an `L0-shim` line, which only ever carries the `sh`-side codes.',\n '',\n ];\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render guards/L1-location.md.
|
|
3
|
+
*
|
|
4
|
+
* Split into three consecutive halves purely to stay inside the method-line budget — the join order is
|
|
5
|
+
* what makes them one file, so keep them adjacent and keep the byte-lock test as the arbiter.
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderL1Doc(): string;
|