@webpieces/ai-hook-rules 0.4.839 → 0.4.840
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 +12 -140
- package/package.json +7 -15
- package/src/adapters/hook-app-fixtures.d.ts +1 -1
- package/src/adapters/hook-app-fixtures.js +0 -8
- package/src/adapters/hook-app-fixtures.js.map +1 -1
- package/src/adapters/hook-core.d.ts +1 -21
- package/src/adapters/hook-core.js +22 -341
- package/src/adapters/hook-core.js.map +1 -1
- package/src/core/load-rules.d.ts +4 -39
- package/src/core/load-rules.js +15 -127
- package/src/core/load-rules.js.map +1 -1
- package/src/core/rules/catch-error-pattern.d.ts +3 -3
- package/src/core/rules/catch-error-pattern.js +13 -13
- package/src/core/rules/catch-error-pattern.js.map +1 -1
- package/src/core/rules/index.d.ts +1 -14
- package/src/core/rules/index.js +1 -17
- package/src/core/rules/index.js.map +1 -1
- package/src/core/rules/match-rule.d.ts +3 -3
- package/src/core/rules/match-rule.js +6 -6
- package/src/core/rules/match-rule.js.map +1 -1
- package/src/core/rules/max-file-lines.d.ts +3 -3
- package/src/core/rules/max-file-lines.js +7 -7
- package/src/core/rules/max-file-lines.js.map +1 -1
- package/src/core/rules/no-any-unknown.d.ts +3 -3
- package/src/core/rules/no-any-unknown.js +6 -6
- package/src/core/rules/no-any-unknown.js.map +1 -1
- package/src/core/rules/no-custom-css.d.ts +3 -3
- package/src/core/rules/no-custom-css.js +7 -7
- package/src/core/rules/no-custom-css.js.map +1 -1
- package/src/core/rules/no-destructure.d.ts +3 -3
- package/src/core/rules/no-destructure.js +7 -7
- package/src/core/rules/no-destructure.js.map +1 -1
- package/src/core/rules/no-implicit-any.d.ts +3 -3
- package/src/core/rules/no-implicit-any.js +6 -6
- package/src/core/rules/no-implicit-any.js.map +1 -1
- package/src/core/rules/no-js-files.d.ts +3 -3
- package/src/core/rules/no-js-files.js +6 -6
- package/src/core/rules/no-js-files.js.map +1 -1
- package/src/core/rules/no-process-exit-outside-main.d.ts +3 -3
- package/src/core/rules/no-process-exit-outside-main.js +7 -7
- package/src/core/rules/no-process-exit-outside-main.js.map +1 -1
- package/src/core/rules/no-symbol-di-tokens.d.ts +3 -3
- package/src/core/rules/no-symbol-di-tokens.js +7 -7
- package/src/core/rules/no-symbol-di-tokens.js.map +1 -1
- package/src/core/rules/no-unmanaged-exceptions.d.ts +3 -3
- package/src/core/rules/no-unmanaged-exceptions.js +9 -9
- package/src/core/rules/no-unmanaged-exceptions.js.map +1 -1
- package/src/core/rules/require-return-type.d.ts +3 -3
- package/src/core/rules/require-return-type.js +6 -6
- package/src/core/rules/require-return-type.js.map +1 -1
- package/src/core/rules/throw-cause-required.d.ts +3 -3
- package/src/core/rules/throw-cause-required.js +9 -9
- package/src/core/rules/throw-cause-required.js.map +1 -1
- package/src/core/rules/validate-ts-in-src.d.ts +3 -3
- package/src/core/rules/validate-ts-in-src.js +7 -7
- package/src/core/rules/validate-ts-in-src.js.map +1 -1
- package/src/core/runner.d.ts +10 -19
- package/src/core/runner.js +24 -622
- package/src/core/runner.js.map +1 -1
- package/src/index.d.ts +2 -15
- package/src/index.js +4 -54
- package/src/index.js.map +1 -1
- package/openclaw.plugin.json +0 -15
- package/src/adapters/agent-adapters.d.ts +0 -13
- package/src/adapters/agent-adapters.js +0 -23
- package/src/adapters/agent-adapters.js.map +0 -1
- package/src/adapters/agent-payload.d.ts +0 -48
- package/src/adapters/agent-payload.js +0 -30
- package/src/adapters/agent-payload.js.map +0 -1
- package/src/adapters/agent-response.d.ts +0 -5
- package/src/adapters/agent-response.js +0 -86
- package/src/adapters/agent-response.js.map +0 -1
- package/src/adapters/claude-code-adapter.d.ts +0 -26
- package/src/adapters/claude-code-adapter.js +0 -69
- package/src/adapters/claude-code-adapter.js.map +0 -1
- package/src/adapters/codex-adapter.d.ts +0 -19
- package/src/adapters/codex-adapter.js +0 -48
- package/src/adapters/codex-adapter.js.map +0 -1
- package/src/adapters/codex-subagent-guard.d.ts +0 -45
- package/src/adapters/codex-subagent-guard.js +0 -88
- package/src/adapters/codex-subagent-guard.js.map +0 -1
- package/src/adapters/detect-ai.d.ts +0 -70
- package/src/adapters/detect-ai.js +0 -82
- package/src/adapters/detect-ai.js.map +0 -1
- package/src/adapters/guards-hook.d.ts +0 -3
- package/src/adapters/guards-hook.js +0 -30
- package/src/adapters/guards-hook.js.map +0 -1
- package/src/adapters/openclaw-plugin.d.ts +0 -14
- package/src/adapters/openclaw-plugin.js +0 -87
- package/src/adapters/openclaw-plugin.js.map +0 -1
- package/src/adapters/review-identity-stamper.d.ts +0 -20
- package/src/adapters/review-identity-stamper.js +0 -34
- package/src/adapters/review-identity-stamper.js.map +0 -1
- package/src/bin/codex-trust.d.ts +0 -105
- package/src/bin/codex-trust.js +0 -205
- package/src/bin/codex-trust.js.map +0 -1
- package/src/bin/dev-hook-install.d.ts +0 -1
- package/src/bin/dev-hook-install.js +0 -82
- package/src/bin/dev-hook-install.js.map +0 -1
- package/src/bin/dev-hook-uninstall.d.ts +0 -1
- package/src/bin/dev-hook-uninstall.js +0 -45
- package/src/bin/dev-hook-uninstall.js.map +0 -1
- package/src/bin/hook-registration.d.ts +0 -429
- package/src/bin/hook-registration.js +0 -661
- package/src/bin/hook-registration.js.map +0 -1
- package/src/bin/install-entry.d.ts +0 -19
- package/src/bin/install-entry.js +0 -128
- package/src/bin/install-entry.js.map +0 -1
- package/src/bin/l0-allowlist.d.ts +0 -49
- package/src/bin/l0-allowlist.js +0 -528
- package/src/bin/l0-allowlist.js.map +0 -1
- package/src/bin/l0-codex-read.d.ts +0 -21
- package/src/bin/l0-codex-read.js +0 -109
- package/src/bin/l0-codex-read.js.map +0 -1
- package/src/bin/l0-decide.d.ts +0 -50
- package/src/bin/l0-decide.js +0 -103
- package/src/bin/l0-decide.js.map +0 -1
- package/src/bin/l0-entry.d.ts +0 -103
- package/src/bin/l0-entry.js +0 -98
- package/src/bin/l0-entry.js.map +0 -1
- package/src/bin/l0-ignored-tools.d.ts +0 -38
- package/src/bin/l0-ignored-tools.js +0 -44
- package/src/bin/l0-ignored-tools.js.map +0 -1
- package/src/bin/managed-env.d.ts +0 -46
- package/src/bin/managed-env.js +0 -50
- package/src/bin/managed-env.js.map +0 -1
- package/src/bin/neighbour-hooks.d.ts +0 -42
- package/src/bin/neighbour-hooks.js +0 -177
- package/src/bin/neighbour-hooks.js.map +0 -1
- package/src/bin/reviewer-agent.d.ts +0 -19
- package/src/bin/reviewer-agent.js +0 -135
- package/src/bin/reviewer-agent.js.map +0 -1
- package/src/bin/settings-shape.d.ts +0 -37
- package/src/bin/settings-shape.js +0 -17
- package/src/bin/settings-shape.js.map +0 -1
- package/src/bin/setup-config.d.ts +0 -19
- package/src/bin/setup-config.js +0 -370
- package/src/bin/setup-config.js.map +0 -1
- package/src/bin/setup.d.ts +0 -78
- package/src/bin/setup.js +0 -400
- package/src/bin/setup.js.map +0 -1
- package/src/bin/shim-audit-log.d.ts +0 -119
- package/src/bin/shim-audit-log.js +0 -286
- package/src/bin/shim-audit-log.js.map +0 -1
- package/src/bin/shim-deny-reason.d.ts +0 -1
- package/src/bin/shim-deny-reason.js +0 -244
- package/src/bin/shim-deny-reason.js.map +0 -1
- package/src/bin/shim-drift-fix.d.ts +0 -1
- package/src/bin/shim-drift-fix.js +0 -72
- package/src/bin/shim-drift-fix.js.map +0 -1
- package/src/bin/shim-testkit.d.ts +0 -107
- package/src/bin/shim-testkit.js +0 -197
- package/src/bin/shim-testkit.js.map +0 -1
- package/src/bin/shim-version-drift.d.ts +0 -1
- package/src/bin/shim-version-drift.js +0 -164
- package/src/bin/shim-version-drift.js.map +0 -1
- package/src/bin/shim.d.ts +0 -16
- package/src/bin/shim.js +0 -636
- package/src/bin/shim.js.map +0 -1
- package/src/bin/upgrade-shim.d.ts +0 -18
- package/src/bin/upgrade-shim.js +0 -283
- package/src/bin/upgrade-shim.js.map +0 -1
- package/src/core/ai-type-context.d.ts +0 -36
- package/src/core/ai-type-context.js +0 -45
- package/src/core/ai-type-context.js.map +0 -1
- package/src/core/apply-patch-parse.d.ts +0 -36
- package/src/core/apply-patch-parse.js +0 -154
- package/src/core/apply-patch-parse.js.map +0 -1
- package/src/core/build-context.d.ts +0 -10
- package/src/core/build-context.js +0 -66
- package/src/core/build-context.js.map +0 -1
- package/src/core/command-scan.d.ts +0 -122
- package/src/core/command-scan.js +0 -282
- package/src/core/command-scan.js.map +0 -1
- package/src/core/custom-rule-adapter.d.ts +0 -22
- package/src/core/custom-rule-adapter.js +0 -50
- package/src/core/custom-rule-adapter.js.map +0 -1
- package/src/core/decision-log.d.ts +0 -190
- package/src/core/decision-log.js +0 -406
- package/src/core/decision-log.js.map +0 -1
- package/src/core/delete-scoped-rules.d.ts +0 -8
- package/src/core/delete-scoped-rules.js +0 -31
- package/src/core/delete-scoped-rules.js.map +0 -1
- package/src/core/disable-directives.d.ts +0 -8
- package/src/core/disable-directives.js +0 -80
- package/src/core/disable-directives.js.map +0 -1
- package/src/core/effective-tree.d.ts +0 -204
- package/src/core/effective-tree.js +0 -277
- package/src/core/effective-tree.js.map +0 -1
- package/src/core/excluded-path-escape.d.ts +0 -101
- package/src/core/excluded-path-escape.js +0 -236
- package/src/core/excluded-path-escape.js.map +0 -1
- package/src/core/excluded-paths.d.ts +0 -23
- package/src/core/excluded-paths.js +0 -54
- package/src/core/excluded-paths.js.map +0 -1
- package/src/core/fix-hint.d.ts +0 -40
- package/src/core/fix-hint.js +0 -53
- package/src/core/fix-hint.js.map +0 -1
- package/src/core/force-to-root.d.ts +0 -32
- package/src/core/force-to-root.js +0 -60
- package/src/core/force-to-root.js.map +0 -1
- package/src/core/guard-index-doc.d.ts +0 -63
- package/src/core/guard-index-doc.js +0 -172
- package/src/core/guard-index-doc.js.map +0 -1
- package/src/core/instruct-ai-writer.d.ts +0 -1
- package/src/core/instruct-ai-writer.js +0 -6
- package/src/core/instruct-ai-writer.js.map +0 -1
- package/src/core/l0-fault-codes.d.ts +0 -85
- package/src/core/l0-fault-codes.js +0 -121
- package/src/core/l0-fault-codes.js.map +0 -1
- package/src/core/l0-matrix.d.ts +0 -114
- package/src/core/l0-matrix.js +0 -416
- package/src/core/l0-matrix.js.map +0 -1
- package/src/core/l0-tooling-doc.d.ts +0 -45
- package/src/core/l0-tooling-doc.js +0 -258
- package/src/core/l0-tooling-doc.js.map +0 -1
- package/src/core/l1-doc.d.ts +0 -7
- package/src/core/l1-doc.js +0 -340
- package/src/core/l1-doc.js.map +0 -1
- package/src/core/l1-matrix-doc.d.ts +0 -31
- package/src/core/l1-matrix-doc.js +0 -111
- package/src/core/l1-matrix-doc.js.map +0 -1
- package/src/core/l1-rows.d.ts +0 -167
- package/src/core/l1-rows.js +0 -262
- package/src/core/l1-rows.js.map +0 -1
- package/src/core/l2-doc.d.ts +0 -7
- package/src/core/l2-doc.js +0 -385
- package/src/core/l2-doc.js.map +0 -1
- package/src/core/l2-matrix-doc.d.ts +0 -23
- package/src/core/l2-matrix-doc.js +0 -72
- package/src/core/l2-matrix-doc.js.map +0 -1
- package/src/core/l2-row.d.ts +0 -54
- package/src/core/l2-row.js +0 -75
- package/src/core/l2-row.js.map +0 -1
- package/src/core/l2-rows.d.ts +0 -56
- package/src/core/l2-rows.js +0 -272
- package/src/core/l2-rows.js.map +0 -1
- package/src/core/load-config.d.ts +0 -1
- package/src/core/load-config.js +0 -9
- package/src/core/load-config.js.map +0 -1
- package/src/core/log-stream.d.ts +0 -117
- package/src/core/log-stream.js +0 -156
- package/src/core/log-stream.js.map +0 -1
- package/src/core/log-streams.d.ts +0 -48
- package/src/core/log-streams.js +0 -55
- package/src/core/log-streams.js.map +0 -1
- package/src/core/log-target.d.ts +0 -21
- package/src/core/log-target.js +0 -29
- package/src/core/log-target.js.map +0 -1
- package/src/core/main-sync-log.d.ts +0 -16
- package/src/core/main-sync-log.js +0 -105
- package/src/core/main-sync-log.js.map +0 -1
- package/src/core/main-sync-refresh.d.ts +0 -39
- package/src/core/main-sync-refresh.js +0 -96
- package/src/core/main-sync-refresh.js.map +0 -1
- package/src/core/main-sync-timeout.d.ts +0 -32
- package/src/core/main-sync-timeout.js +0 -94
- package/src/core/main-sync-timeout.js.map +0 -1
- package/src/core/matrix-cures.d.ts +0 -12
- package/src/core/matrix-cures.js +0 -56
- package/src/core/matrix-cures.js.map +0 -1
- package/src/core/missing-directory.d.ts +0 -38
- package/src/core/missing-directory.js +0 -66
- package/src/core/missing-directory.js.map +0 -1
- package/src/core/read-only-inspection.d.ts +0 -34
- package/src/core/read-only-inspection.js +0 -88
- package/src/core/read-only-inspection.js.map +0 -1
- package/src/core/rejection-log.d.ts +0 -9
- package/src/core/rejection-log.js +0 -258
- package/src/core/rejection-log.js.map +0 -1
- package/src/core/report.d.ts +0 -21
- package/src/core/report.js +0 -73
- package/src/core/report.js.map +0 -1
- package/src/core/rule-base.d.ts +0 -39
- package/src/core/rule-base.js +0 -36
- package/src/core/rule-base.js.map +0 -1
- package/src/core/rules/branch-creation-guard.d.ts +0 -113
- package/src/core/rules/branch-creation-guard.js +0 -422
- package/src/core/rules/branch-creation-guard.js.map +0 -1
- package/src/core/rules/branch-switch-scan.d.ts +0 -43
- package/src/core/rules/branch-switch-scan.js +0 -132
- package/src/core/rules/branch-switch-scan.js.map +0 -1
- package/src/core/rules/build-output-pipe-guard.d.ts +0 -56
- package/src/core/rules/build-output-pipe-guard.js +0 -120
- package/src/core/rules/build-output-pipe-guard.js.map +0 -1
- package/src/core/rules/build-output-pipe-scan.d.ts +0 -47
- package/src/core/rules/build-output-pipe-scan.js +0 -84
- package/src/core/rules/build-output-pipe-scan.js.map +0 -1
- package/src/core/rules/cap-remedies.d.ts +0 -39
- package/src/core/rules/cap-remedies.js +0 -59
- package/src/core/rules/cap-remedies.js.map +0 -1
- package/src/core/rules/commit-message-substitution-guard.d.ts +0 -72
- package/src/core/rules/commit-message-substitution-guard.js +0 -134
- package/src/core/rules/commit-message-substitution-guard.js.map +0 -1
- package/src/core/rules/commit-message-substitution-scan.d.ts +0 -42
- package/src/core/rules/commit-message-substitution-scan.js +0 -145
- package/src/core/rules/commit-message-substitution-scan.js.map +0 -1
- package/src/core/rules/content-read-scan.d.ts +0 -76
- package/src/core/rules/content-read-scan.js +0 -176
- package/src/core/rules/content-read-scan.js.map +0 -1
- package/src/core/rules/cure-prefix-scan.d.ts +0 -64
- package/src/core/rules/cure-prefix-scan.js +0 -133
- package/src/core/rules/cure-prefix-scan.js.map +0 -1
- package/src/core/rules/feature-branch-guard.d.ts +0 -121
- package/src/core/rules/feature-branch-guard.js +0 -326
- package/src/core/rules/feature-branch-guard.js.map +0 -1
- package/src/core/rules/judged-tree.d.ts +0 -66
- package/src/core/rules/judged-tree.js +0 -97
- package/src/core/rules/judged-tree.js.map +0 -1
- package/src/core/rules/main-freshness.d.ts +0 -37
- package/src/core/rules/main-freshness.js +0 -61
- package/src/core/rules/main-freshness.js.map +0 -1
- package/src/core/rules/merge-in-progress-guard.d.ts +0 -17
- package/src/core/rules/merge-in-progress-guard.js +0 -122
- package/src/core/rules/merge-in-progress-guard.js.map +0 -1
- package/src/core/rules/merged-branch-bash-guard.d.ts +0 -62
- package/src/core/rules/merged-branch-bash-guard.js +0 -170
- package/src/core/rules/merged-branch-bash-guard.js.map +0 -1
- package/src/core/rules/merged-branch-message.d.ts +0 -59
- package/src/core/rules/merged-branch-message.js +0 -137
- package/src/core/rules/merged-branch-message.js.map +0 -1
- package/src/core/rules/pr-creation-or-push-guard.d.ts +0 -26
- package/src/core/rules/pr-creation-or-push-guard.js +0 -146
- package/src/core/rules/pr-creation-or-push-guard.js.map +0 -1
- package/src/core/rules/pr-merge-guard.d.ts +0 -36
- package/src/core/rules/pr-merge-guard.js +0 -86
- package/src/core/rules/pr-merge-guard.js.map +0 -1
- package/src/core/rules/read-stale-guard.d.ts +0 -136
- package/src/core/rules/read-stale-guard.js +0 -326
- package/src/core/rules/read-stale-guard.js.map +0 -1
- package/src/core/rules/recovery-allowlist.d.ts +0 -49
- package/src/core/rules/recovery-allowlist.js +0 -187
- package/src/core/rules/recovery-allowlist.js.map +0 -1
- package/src/core/rules/redirect-how-to-merge-main.d.ts +0 -16
- package/src/core/rules/redirect-how-to-merge-main.js +0 -157
- package/src/core/rules/redirect-how-to-merge-main.js.map +0 -1
- package/src/core/rules/shell-segment-scan.d.ts +0 -64
- package/src/core/rules/shell-segment-scan.js +0 -88
- package/src/core/rules/shell-segment-scan.js.map +0 -1
- package/src/core/rules/stale-main-bash-guard.d.ts +0 -198
- package/src/core/rules/stale-main-bash-guard.js +0 -361
- package/src/core/rules/stale-main-bash-guard.js.map +0 -1
- package/src/core/rules/stale-main-message.d.ts +0 -62
- package/src/core/rules/stale-main-message.js +0 -102
- package/src/core/rules/stale-main-message.js.map +0 -1
- package/src/core/rules/tree-recovery.d.ts +0 -92
- package/src/core/rules/tree-recovery.js +0 -165
- package/src/core/rules/tree-recovery.js.map +0 -1
- package/src/core/rules/wait-spin-guard.d.ts +0 -128
- package/src/core/rules/wait-spin-guard.js +0 -211
- package/src/core/rules/wait-spin-guard.js.map +0 -1
- package/src/core/rules/wait-spin-scan.d.ts +0 -118
- package/src/core/rules/wait-spin-scan.js +0 -203
- package/src/core/rules/wait-spin-scan.js.map +0 -1
- package/src/core/rules/whole-repo-build-guard.d.ts +0 -125
- package/src/core/rules/whole-repo-build-guard.js +0 -257
- package/src/core/rules/whole-repo-build-guard.js.map +0 -1
- package/src/core/rules/whole-repo-build-scan.d.ts +0 -28
- package/src/core/rules/whole-repo-build-scan.js +0 -198
- package/src/core/rules/whole-repo-build-scan.js.map +0 -1
- package/src/core/session-call-history.d.ts +0 -44
- package/src/core/session-call-history.js +0 -79
- package/src/core/session-call-history.js.map +0 -1
- package/src/core/shell-read-parity.d.ts +0 -56
- package/src/core/shell-read-parity.js +0 -155
- package/src/core/shell-read-parity.js.map +0 -1
- package/src/core/strip-ts-noise.d.ts +0 -1
- package/src/core/strip-ts-noise.js +0 -185
- package/src/core/strip-ts-noise.js.map +0 -1
- package/src/core/sync-main.d.ts +0 -46
- package/src/core/sync-main.js +0 -175
- package/src/core/sync-main.js.map +0 -1
- package/src/core/target-tree.d.ts +0 -84
- package/src/core/target-tree.js +0 -148
- package/src/core/target-tree.js.map +0 -1
- package/src/core/to-error.d.ts +0 -5
- package/src/core/to-error.js +0 -37
- package/src/core/to-error.js.map +0 -1
- package/src/core/types.d.ts +0 -152
- package/src/core/types.js +0 -200
- package/src/core/types.js.map +0 -1
- package/src/core/version-sync.d.ts +0 -219
- package/src/core/version-sync.js +0 -558
- package/src/core/version-sync.js.map +0 -1
- package/src/core/webpieces-versions.d.ts +0 -98
- package/src/core/webpieces-versions.js +0 -206
- package/src/core/webpieces-versions.js.map +0 -1
- package/templates/ai-hook.sh +0 -497
- package/templates/claude-settings-hook.json +0 -28
- package/templates/webpieces-reviewer.md +0 -60
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { StreamIdentity } from './log-stream';
|
|
2
|
-
export declare function resetMainSyncRefreshLatchForTest(): void;
|
|
3
|
-
/**
|
|
4
|
-
* The detached child's argv, spawner side. Positions here are offset by two from the child's
|
|
5
|
-
* `process.argv` (node + script path), so this array's 3/4/5 are the child's 4/5/6 — which is what
|
|
6
|
-
* `sync-main.ts:spawnerIdentity` reads. The two are pinned against each other by ONE test, because a
|
|
7
|
-
* silent disagreement about these positions IS the bug being fixed: the child previously received no
|
|
8
|
-
* identity at all and wrote every line to the shared `unknown-coordinator-hook-` stream.
|
|
9
|
-
*/
|
|
10
|
-
export declare function refresherArgv(refresher: string, workspaceRoot: string, hangTimeoutMinutes: number, identity: StreamIdentity): string[];
|
|
11
|
-
/**
|
|
12
|
-
* Fire-and-forget spawn of the detached refresher (sync-main.js in this same dir — spawned by path,
|
|
13
|
-
* not a bin). The child outlives this hook process (`detached` + `unref`), does the slow
|
|
14
|
-
* merged-PR/fetch/merge-base/overlap work, and writes the cache the feature-branch-guard reads on
|
|
15
|
-
* the NEXT call. This is the first detached spawn in the codebase — every existing hook is synchronous.
|
|
16
|
-
*
|
|
17
|
-
* Observability: we log SPAWN_ATTEMPT here and the child logs START/FINISH/ERROR, all to
|
|
18
|
-
* `.webpieces/logs/async-refresh/<writer>.log` (LogStream names every writer). The child's
|
|
19
|
-
* stdout/stderr are redirected to a sibling file (not
|
|
20
|
-
* /dev/null) so a crash before the child's own logging is still captured. If the async-refresh stream shows
|
|
21
|
-
* SPAWN_ATTEMPT but never START, the detached child was killed before it ran.
|
|
22
|
-
*
|
|
23
|
-
* `hangTimeoutMinutes` IS REQUIRED, deliberately. It used to default to DEFAULT_HANG_TIMEOUT_MINUTES,
|
|
24
|
-
* and that default is the mechanism by which three of the four configured values could never reach a
|
|
25
|
-
* spawn: two callers ran before any guard and simply omitted the argument, and the at-most-once latch
|
|
26
|
-
* below then meant the guard's own call — the one carrying the configured value — was a no-op. An
|
|
27
|
-
* omitted argument that silently means "the default" is unreadable at the call site and impossible to
|
|
28
|
-
* grep. Required makes every caller say which value it is passing, and makes forgetting a compile error.
|
|
29
|
-
*
|
|
30
|
-
* THE IDENTITY GOES ON ARGV, and that is what makes the sentence above true. The child is a separate
|
|
31
|
-
* node process whose `logStream` starts unidentified, so it used to write every line to the shared
|
|
32
|
-
* `unknown-coordinator-hook.log` while this parent wrote SPAWN_ATTEMPT to its own
|
|
33
|
-
* prefixed stream. One cycle, two files — the SPAWN_ATTEMPT-without-START check then read as a
|
|
34
|
-
* failure on every cycle even when the child ran perfectly — and every agent's child appending to
|
|
35
|
-
* that one shared path is exactly the multi-writer tearing LogStream exists to remove. Passing
|
|
36
|
-
* session/agent/hook through (positional argv, alongside the root and timeout the child already
|
|
37
|
-
* takes) puts the whole cycle back in ONE file.
|
|
38
|
-
*/
|
|
39
|
-
export declare function triggerMainSyncRefresh(workspaceRoot: string, hangTimeoutMinutes: number): void;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetMainSyncRefreshLatchForTest = resetMainSyncRefreshLatchForTest;
|
|
4
|
-
exports.refresherArgv = refresherArgv;
|
|
5
|
-
exports.triggerMainSyncRefresh = triggerMainSyncRefresh;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
9
|
-
const path = tslib_1.__importStar(require("path"));
|
|
10
|
-
const to_error_1 = require("./to-error");
|
|
11
|
-
const main_sync_log_1 = require("./main-sync-log");
|
|
12
|
-
const log_stream_1 = require("./log-stream");
|
|
13
|
-
// Per-process latch for the spawn below. A hook process handles exactly one tool call, so this makes
|
|
14
|
-
// the refresher at-most-once per tool call. Exported reset is test-only.
|
|
15
|
-
let alreadyTriggered = false;
|
|
16
|
-
// webpieces-disable no-function-outside-class -- test-only latch reset, matching this module's function shape
|
|
17
|
-
function resetMainSyncRefreshLatchForTest() {
|
|
18
|
-
alreadyTriggered = false;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The detached child's argv, spawner side. Positions here are offset by two from the child's
|
|
22
|
-
* `process.argv` (node + script path), so this array's 3/4/5 are the child's 4/5/6 — which is what
|
|
23
|
-
* `sync-main.ts:spawnerIdentity` reads. The two are pinned against each other by ONE test, because a
|
|
24
|
-
* silent disagreement about these positions IS the bug being fixed: the child previously received no
|
|
25
|
-
* identity at all and wrote every line to the shared `unknown-coordinator-hook-` stream.
|
|
26
|
-
*/
|
|
27
|
-
// webpieces-disable no-function-outside-class -- argv builder for this module's spawn, matching its function shape
|
|
28
|
-
function refresherArgv(refresher, workspaceRoot, hangTimeoutMinutes, identity) {
|
|
29
|
-
return [refresher, workspaceRoot, String(hangTimeoutMinutes), identity.sessionId, identity.agentId, identity.hook];
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Fire-and-forget spawn of the detached refresher (sync-main.js in this same dir — spawned by path,
|
|
33
|
-
* not a bin). The child outlives this hook process (`detached` + `unref`), does the slow
|
|
34
|
-
* merged-PR/fetch/merge-base/overlap work, and writes the cache the feature-branch-guard reads on
|
|
35
|
-
* the NEXT call. This is the first detached spawn in the codebase — every existing hook is synchronous.
|
|
36
|
-
*
|
|
37
|
-
* Observability: we log SPAWN_ATTEMPT here and the child logs START/FINISH/ERROR, all to
|
|
38
|
-
* `.webpieces/logs/async-refresh/<writer>.log` (LogStream names every writer). The child's
|
|
39
|
-
* stdout/stderr are redirected to a sibling file (not
|
|
40
|
-
* /dev/null) so a crash before the child's own logging is still captured. If the async-refresh stream shows
|
|
41
|
-
* SPAWN_ATTEMPT but never START, the detached child was killed before it ran.
|
|
42
|
-
*
|
|
43
|
-
* `hangTimeoutMinutes` IS REQUIRED, deliberately. It used to default to DEFAULT_HANG_TIMEOUT_MINUTES,
|
|
44
|
-
* and that default is the mechanism by which three of the four configured values could never reach a
|
|
45
|
-
* spawn: two callers ran before any guard and simply omitted the argument, and the at-most-once latch
|
|
46
|
-
* below then meant the guard's own call — the one carrying the configured value — was a no-op. An
|
|
47
|
-
* omitted argument that silently means "the default" is unreadable at the call site and impossible to
|
|
48
|
-
* grep. Required makes every caller say which value it is passing, and makes forgetting a compile error.
|
|
49
|
-
*
|
|
50
|
-
* THE IDENTITY GOES ON ARGV, and that is what makes the sentence above true. The child is a separate
|
|
51
|
-
* node process whose `logStream` starts unidentified, so it used to write every line to the shared
|
|
52
|
-
* `unknown-coordinator-hook.log` while this parent wrote SPAWN_ATTEMPT to its own
|
|
53
|
-
* prefixed stream. One cycle, two files — the SPAWN_ATTEMPT-without-START check then read as a
|
|
54
|
-
* failure on every cycle even when the child ran perfectly — and every agent's child appending to
|
|
55
|
-
* that one shared path is exactly the multi-writer tearing LogStream exists to remove. Passing
|
|
56
|
-
* session/agent/hook through (positional argv, alongside the root and timeout the child already
|
|
57
|
-
* takes) puts the whole cycle back in ONE file.
|
|
58
|
-
*/
|
|
59
|
-
// webpieces-disable no-function-outside-class -- the module's one entry point, beside refresherArgv; a detached fire-and-forget spawn has no state to inject and must stay callable from a tree too broken to build a DI container
|
|
60
|
-
function triggerMainSyncRefresh(workspaceRoot, hangTimeoutMinutes) {
|
|
61
|
-
// ONE refresher per hook process. Several call sites fire this on a single tool call — the Read
|
|
62
|
-
// fast path in hook-core AND read-stale-guard's own check(), for one — which is why the log showed
|
|
63
|
-
// two SPAWN_ATTEMPTs ~20ms apart from the same pid on every cycle. The loser only ever reached the
|
|
64
|
-
// lock and exited, so the second child was pure waste (and one more `git fetch` racing the
|
|
65
|
-
// agent's). The child's lock still guards against refreshers from OTHER hook processes.
|
|
66
|
-
if (alreadyTriggered)
|
|
67
|
-
return;
|
|
68
|
-
alreadyTriggered = true;
|
|
69
|
-
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
70
|
-
try {
|
|
71
|
-
const refresher = path.join(__dirname, 'sync-main.js');
|
|
72
|
-
// SPAWN_ATTEMPT first — this also creates .webpieces/logs so the stderr fd below can open.
|
|
73
|
-
(0, main_sync_log_1.logSyncEvent)(workspaceRoot, new main_sync_log_1.SyncLogEvent('SPAWN_ATTEMPT', process.pid, '-', `refresher=${refresher}`));
|
|
74
|
-
// Redirect the detached child's stdout+stderr to a file (not /dev/null) so an uncaught crash
|
|
75
|
-
// before the child's own logging — e.g. a module-load failure — is still captured.
|
|
76
|
-
const errFd = fs.openSync((0, main_sync_log_1.refresherChildStdioPath)(workspaceRoot), 'a');
|
|
77
|
-
const child = (0, child_process_1.spawn)(process.execPath, refresherArgv(refresher, workspaceRoot, hangTimeoutMinutes, log_stream_1.logStream.identity()), {
|
|
78
|
-
detached: true,
|
|
79
|
-
stdio: ['ignore', errFd, errFd],
|
|
80
|
-
});
|
|
81
|
-
// spawn errors (e.g. ENOENT) arrive asynchronously; record one if it fires. The hook may exit
|
|
82
|
-
// before this handler runs, but on POSIX a successful exec has already happened by now.
|
|
83
|
-
child.once('error', (err) => {
|
|
84
|
-
(0, main_sync_log_1.logSyncEvent)(workspaceRoot, new main_sync_log_1.SyncLogEvent('ERROR', child.pid ?? -1, '-', `spawn failed: ${err.message}`));
|
|
85
|
-
});
|
|
86
|
-
child.unref();
|
|
87
|
-
// The child has its own dup'd copy of the fd after spawn; close the parent's copy.
|
|
88
|
-
fs.closeSync(errFd);
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
const error = (0, to_error_1.toError)(err);
|
|
92
|
-
void error;
|
|
93
|
-
// Spawning the background refresh must never block or fail the tool call.
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=main-sync-refresh.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main-sync-refresh.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/main-sync-refresh.ts"],"names":[],"mappings":";;AAaA,4EAEC;AAUD,sCAEC;AA+BD,wDAmCC;;AA7FD,iDAAsC;AACtC,+CAAyB;AACzB,mDAA6B;AAE7B,yCAAqC;AACrC,mDAAsF;AACtF,6CAAyD;AAEzD,qGAAqG;AACrG,yEAAyE;AACzE,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B,8GAA8G;AAC9G,SAAgB,gCAAgC;IAC5C,gBAAgB,GAAG,KAAK,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,mHAAmH;AACnH,SAAgB,aAAa,CAAC,SAAiB,EAAE,aAAqB,EAAE,kBAA0B,EAAE,QAAwB;IACxH,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,MAAM,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AACvH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,mOAAmO;AACnO,SAAgB,sBAAsB,CAAC,aAAqB,EAAE,kBAA0B;IACpF,gGAAgG;IAChG,mGAAmG;IACnG,mGAAmG;IACnG,2FAA2F;IAC3F,wFAAwF;IACxF,IAAI,gBAAgB;QAAE,OAAO;IAC7B,gBAAgB,GAAG,IAAI,CAAC;IAExB,8DAA8D;IAC9D,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACvD,2FAA2F;QAC3F,IAAA,4BAAY,EAAC,aAAa,EAAE,IAAI,4BAAY,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,aAAa,SAAS,EAAE,CAAC,CAAC,CAAC;QAE3G,6FAA6F;QAC7F,mFAAmF;QACnF,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAA,uCAAuB,EAAC,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,IAAA,qBAAK,EAAC,OAAO,CAAC,QAAQ,EAAE,aAAa,CAAC,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAS,CAAC,QAAQ,EAAE,CAAC,EAAE;YACrH,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC;SAClC,CAAC,CAAC;QACH,8FAA8F;QAC9F,wFAAwF;QACxF,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAU,EAAQ,EAAE;YACrC,IAAA,4BAAY,EAAC,aAAa,EAAE,IAAI,4BAAY,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,iBAAiB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACjH,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,mFAAmF;QACnF,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,KAAK,KAAK,CAAC;QACX,0EAA0E;IAC9E,CAAC;AACL,CAAC","sourcesContent":["import { spawn } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { toError } from './to-error';\nimport { logSyncEvent, SyncLogEvent, refresherChildStdioPath } from './main-sync-log';\nimport { logStream, StreamIdentity } from './log-stream';\n\n// Per-process latch for the spawn below. A hook process handles exactly one tool call, so this makes\n// the refresher at-most-once per tool call. Exported reset is test-only.\nlet alreadyTriggered = false;\n\n// webpieces-disable no-function-outside-class -- test-only latch reset, matching this module's function shape\nexport function resetMainSyncRefreshLatchForTest(): void {\n alreadyTriggered = false;\n}\n\n/**\n * The detached child's argv, spawner side. Positions here are offset by two from the child's\n * `process.argv` (node + script path), so this array's 3/4/5 are the child's 4/5/6 — which is what\n * `sync-main.ts:spawnerIdentity` reads. The two are pinned against each other by ONE test, because a\n * silent disagreement about these positions IS the bug being fixed: the child previously received no\n * identity at all and wrote every line to the shared `unknown-coordinator-hook-` stream.\n */\n// webpieces-disable no-function-outside-class -- argv builder for this module's spawn, matching its function shape\nexport function refresherArgv(refresher: string, workspaceRoot: string, hangTimeoutMinutes: number, identity: StreamIdentity): string[] {\n return [refresher, workspaceRoot, String(hangTimeoutMinutes), identity.sessionId, identity.agentId, identity.hook];\n}\n\n/**\n * Fire-and-forget spawn of the detached refresher (sync-main.js in this same dir — spawned by path,\n * not a bin). The child outlives this hook process (`detached` + `unref`), does the slow\n * merged-PR/fetch/merge-base/overlap work, and writes the cache the feature-branch-guard reads on\n * the NEXT call. This is the first detached spawn in the codebase — every existing hook is synchronous.\n *\n * Observability: we log SPAWN_ATTEMPT here and the child logs START/FINISH/ERROR, all to\n * `.webpieces/logs/async-refresh/<writer>.log` (LogStream names every writer). The child's\n * stdout/stderr are redirected to a sibling file (not\n * /dev/null) so a crash before the child's own logging is still captured. If the async-refresh stream shows\n * SPAWN_ATTEMPT but never START, the detached child was killed before it ran.\n *\n * `hangTimeoutMinutes` IS REQUIRED, deliberately. It used to default to DEFAULT_HANG_TIMEOUT_MINUTES,\n * and that default is the mechanism by which three of the four configured values could never reach a\n * spawn: two callers ran before any guard and simply omitted the argument, and the at-most-once latch\n * below then meant the guard's own call — the one carrying the configured value — was a no-op. An\n * omitted argument that silently means \"the default\" is unreadable at the call site and impossible to\n * grep. Required makes every caller say which value it is passing, and makes forgetting a compile error.\n *\n * THE IDENTITY GOES ON ARGV, and that is what makes the sentence above true. The child is a separate\n * node process whose `logStream` starts unidentified, so it used to write every line to the shared\n * `unknown-coordinator-hook.log` while this parent wrote SPAWN_ATTEMPT to its own\n * prefixed stream. One cycle, two files — the SPAWN_ATTEMPT-without-START check then read as a\n * failure on every cycle even when the child ran perfectly — and every agent's child appending to\n * that one shared path is exactly the multi-writer tearing LogStream exists to remove. Passing\n * session/agent/hook through (positional argv, alongside the root and timeout the child already\n * takes) puts the whole cycle back in ONE file.\n */\n// webpieces-disable no-function-outside-class -- the module's one entry point, beside refresherArgv; a detached fire-and-forget spawn has no state to inject and must stay callable from a tree too broken to build a DI container\nexport function triggerMainSyncRefresh(workspaceRoot: string, hangTimeoutMinutes: number): void {\n // ONE refresher per hook process. Several call sites fire this on a single tool call — the Read\n // fast path in hook-core AND read-stale-guard's own check(), for one — which is why the log showed\n // two SPAWN_ATTEMPTs ~20ms apart from the same pid on every cycle. The loser only ever reached the\n // lock and exited, so the second child was pure waste (and one more `git fetch` racing the\n // agent's). The child's lock still guards against refreshers from OTHER hook processes.\n if (alreadyTriggered) return;\n alreadyTriggered = true;\n\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const refresher = path.join(__dirname, 'sync-main.js');\n // SPAWN_ATTEMPT first — this also creates .webpieces/logs so the stderr fd below can open.\n logSyncEvent(workspaceRoot, new SyncLogEvent('SPAWN_ATTEMPT', process.pid, '-', `refresher=${refresher}`));\n\n // Redirect the detached child's stdout+stderr to a file (not /dev/null) so an uncaught crash\n // before the child's own logging — e.g. a module-load failure — is still captured.\n const errFd = fs.openSync(refresherChildStdioPath(workspaceRoot), 'a');\n const child = spawn(process.execPath, refresherArgv(refresher, workspaceRoot, hangTimeoutMinutes, logStream.identity()), {\n detached: true,\n stdio: ['ignore', errFd, errFd],\n });\n // spawn errors (e.g. ENOENT) arrive asynchronously; record one if it fires. The hook may exit\n // before this handler runs, but on POSIX a successful exec has already happened by now.\n child.once('error', (err: Error): void => {\n logSyncEvent(workspaceRoot, new SyncLogEvent('ERROR', child.pid ?? -1, '-', `spawn failed: ${err.message}`));\n });\n child.unref();\n // The child has its own dup'd copy of the fd after spawn; close the parent's copy.\n fs.closeSync(errFd);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n // Spawning the background refresh must never block or fail the tool call.\n }\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { WebpiecesRulesConfig, BranchStateGuardConfig } from '@webpieces/rules-config';
|
|
2
|
-
import type { Rule } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* The value on a branch-state ENTRY, or the default — for the four guard classes, which are handed
|
|
5
|
-
* their own typed config and never see the whole file.
|
|
6
|
-
*
|
|
7
|
-
* The four used to spell this inline as `this.config.hangTimeoutMinutes ?? DEFAULT_HANG_TIMEOUT_MINUTES`,
|
|
8
|
-
* which is a fourth copy of the resolution and exactly the shape that let the four DECLARATIONS drift
|
|
9
|
-
* apart in the first place. One reader, one fallback.
|
|
10
|
-
*/
|
|
11
|
-
export declare function hangTimeoutOf(config: BranchStateGuardConfig): number;
|
|
12
|
-
/** The configured value for a caller that has ALREADY loaded the whole config. */
|
|
13
|
-
export declare function branchStateHangTimeout(config: WebpiecesRulesConfig): number;
|
|
14
|
-
/**
|
|
15
|
-
* The configured value for a caller that has NOT loaded the config — the hook adapter's two pre-rule
|
|
16
|
-
* refresh triggers (the webpieces.config.json edit bypass, and the Read fast path).
|
|
17
|
-
*
|
|
18
|
-
* Fails back to the default on an unloadable config: warming a cache must never throw on the tool path.
|
|
19
|
-
*/
|
|
20
|
-
export declare function branchStateHangTimeoutFor(cwd: string): number;
|
|
21
|
-
/** Test-only: clears the per-process memo above. */
|
|
22
|
-
export declare function resetHangTimeoutCacheForTest(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Fire-and-forget the detached refresher when the branch-state policy is loaded and active, so the
|
|
25
|
-
* cache stays fresh as the AI works. The guard rules themselves also trigger it; this covers the Bash
|
|
26
|
-
* path so the cache is warm on every command.
|
|
27
|
-
*
|
|
28
|
-
* Keyed on `feature-branch-guard` — the rule NAME, not the config key. Any of the four branch-state
|
|
29
|
-
* classes would do (they share one entry, so they are on or off together); this one is asked because it
|
|
30
|
-
* is the class whose cache freshness matters on the very next Write.
|
|
31
|
-
*/
|
|
32
|
-
export declare function maybeRefreshMainSync(rules: readonly Rule[], workspaceRoot: string, hangTimeoutMinutes: number): void;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hangTimeoutOf = hangTimeoutOf;
|
|
4
|
-
exports.branchStateHangTimeout = branchStateHangTimeout;
|
|
5
|
-
exports.branchStateHangTimeoutFor = branchStateHangTimeoutFor;
|
|
6
|
-
exports.resetHangTimeoutCacheForTest = resetHangTimeoutCacheForTest;
|
|
7
|
-
exports.maybeRefreshMainSync = maybeRefreshMainSync;
|
|
8
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
9
|
-
const repo_workflow_core_1 = require("@webpieces/repo-workflow-core");
|
|
10
|
-
const to_error_1 = require("./to-error");
|
|
11
|
-
const main_sync_refresh_1 = require("./main-sync-refresh");
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// THE ONE `hangTimeoutMinutes`, and every caller that has to read it.
|
|
14
|
-
//
|
|
15
|
-
// There is ONE detached refresher writing ONE cache (.webpieces/main-sync-status.json), so there is one
|
|
16
|
-
// knob: `hookGuards.branch-state-guard.hangTimeoutMinutes`, which tunes the stale-lock reclaim window.
|
|
17
|
-
//
|
|
18
|
-
// It used to be declared FOUR times — once per branch-state guard class — and read four times, and
|
|
19
|
-
// three of those four values were structurally unable to take effect. Two things conspired:
|
|
20
|
-
// `triggerMainSyncRefresh` latches at most one spawn per hook process, and two callers ran BEFORE any
|
|
21
|
-
// guard's own call while passing the hardcoded default. So on the Bash path and the Read path (the two
|
|
22
|
-
// hottest) the default always won the latch and the configured value never reached a spawn.
|
|
23
|
-
//
|
|
24
|
-
// Collapsing four declarations into one only fixes that if EVERY caller reads the one. This module is
|
|
25
|
-
// where they do, which is also why it is a module rather than three helpers in runner.ts: the callers
|
|
26
|
-
// live in two files (the runner and the hook adapter) and a knob honoured in one of them is the bug
|
|
27
|
-
// again, one release later.
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
/**
|
|
30
|
-
* The value on a branch-state ENTRY, or the default — for the four guard classes, which are handed
|
|
31
|
-
* their own typed config and never see the whole file.
|
|
32
|
-
*
|
|
33
|
-
* The four used to spell this inline as `this.config.hangTimeoutMinutes ?? DEFAULT_HANG_TIMEOUT_MINUTES`,
|
|
34
|
-
* which is a fourth copy of the resolution and exactly the shape that let the four DECLARATIONS drift
|
|
35
|
-
* apart in the first place. One reader, one fallback.
|
|
36
|
-
*/
|
|
37
|
-
// webpieces-disable no-function-outside-class -- module-scope config accessor, matching the shape of the runner helpers it was extracted from
|
|
38
|
-
function hangTimeoutOf(config) {
|
|
39
|
-
const configured = config.hangTimeoutMinutes;
|
|
40
|
-
return typeof configured === 'number' ? configured : repo_workflow_core_1.DEFAULT_HANG_TIMEOUT_MINUTES;
|
|
41
|
-
}
|
|
42
|
-
/** The configured value for a caller that has ALREADY loaded the whole config. */
|
|
43
|
-
// webpieces-disable no-function-outside-class -- module-scope config accessor, matching the shape of the runner helpers it was extracted from
|
|
44
|
-
function branchStateHangTimeout(config) {
|
|
45
|
-
const entry = config[rules_config_1.BRANCH_STATE_GUARD_KEY];
|
|
46
|
-
return entry === undefined ? repo_workflow_core_1.DEFAULT_HANG_TIMEOUT_MINUTES : hangTimeoutOf(entry);
|
|
47
|
-
}
|
|
48
|
-
// Memoized per PROCESS, and a hook process handles exactly one tool call — so the adapter's two call
|
|
49
|
-
// sites cost at most one extra config parse between them, never one each.
|
|
50
|
-
let cachedHangTimeout = null;
|
|
51
|
-
/**
|
|
52
|
-
* The configured value for a caller that has NOT loaded the config — the hook adapter's two pre-rule
|
|
53
|
-
* refresh triggers (the webpieces.config.json edit bypass, and the Read fast path).
|
|
54
|
-
*
|
|
55
|
-
* Fails back to the default on an unloadable config: warming a cache must never throw on the tool path.
|
|
56
|
-
*/
|
|
57
|
-
// webpieces-disable no-function-outside-class -- module-scope config accessor, matching the shape of the runner helpers it was extracted from
|
|
58
|
-
function branchStateHangTimeoutFor(cwd) {
|
|
59
|
-
if (cachedHangTimeout !== null)
|
|
60
|
-
return cachedHangTimeout;
|
|
61
|
-
let value = repo_workflow_core_1.DEFAULT_HANG_TIMEOUT_MINUTES;
|
|
62
|
-
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a cache-warming knob must never throw on the tool path
|
|
63
|
-
try {
|
|
64
|
-
value = branchStateHangTimeout((0, rules_config_1.loadAndValidate)(cwd).rulesConfig);
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
const error = (0, to_error_1.toError)(err);
|
|
68
|
-
void error;
|
|
69
|
-
}
|
|
70
|
-
cachedHangTimeout = value;
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
/** Test-only: clears the per-process memo above. */
|
|
74
|
-
// webpieces-disable no-function-outside-class -- module-scope test hook beside the memo it clears
|
|
75
|
-
function resetHangTimeoutCacheForTest() {
|
|
76
|
-
cachedHangTimeout = null;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Fire-and-forget the detached refresher when the branch-state policy is loaded and active, so the
|
|
80
|
-
* cache stays fresh as the AI works. The guard rules themselves also trigger it; this covers the Bash
|
|
81
|
-
* path so the cache is warm on every command.
|
|
82
|
-
*
|
|
83
|
-
* Keyed on `feature-branch-guard` — the rule NAME, not the config key. Any of the four branch-state
|
|
84
|
-
* classes would do (they share one entry, so they are on or off together); this one is asked because it
|
|
85
|
-
* is the class whose cache freshness matters on the very next Write.
|
|
86
|
-
*/
|
|
87
|
-
// webpieces-disable no-function-outside-class -- module-scope refresh trigger, matching the shape of the runner helpers it was extracted from
|
|
88
|
-
function maybeRefreshMainSync(rules, workspaceRoot, hangTimeoutMinutes) {
|
|
89
|
-
const guard = rules.find((r) => r.name === 'feature-branch-guard');
|
|
90
|
-
if (guard && guard.shouldRun()) {
|
|
91
|
-
(0, main_sync_refresh_1.triggerMainSyncRefresh)(workspaceRoot, hangTimeoutMinutes);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
//# sourceMappingURL=main-sync-timeout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main-sync-timeout.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/main-sync-timeout.ts"],"names":[],"mappings":";;AAkCA,sCAGC;AAID,wDAGC;AAaD,8DAYC;AAID,oEAEC;AAYD,oDAKC;AA5FD,0DAAgI;AAChI,sEAA6E;AAE7E,yCAAqC;AACrC,2DAA6D;AAG7D,8EAA8E;AAC9E,sEAAsE;AACtE,EAAE;AACF,wGAAwG;AACxG,uGAAuG;AACvG,EAAE;AACF,mGAAmG;AACnG,4FAA4F;AAC5F,sGAAsG;AACtG,uGAAuG;AACvG,4FAA4F;AAC5F,EAAE;AACF,sGAAsG;AACtG,sGAAsG;AACtG,oGAAoG;AACpG,4BAA4B;AAC5B,8EAA8E;AAE9E;;;;;;;GAOG;AACH,8IAA8I;AAC9I,SAAgB,aAAa,CAAC,MAA8B;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,kBAAkB,CAAC;IAC7C,OAAO,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,iDAA4B,CAAC;AACtF,CAAC;AAED,kFAAkF;AAClF,8IAA8I;AAC9I,SAAgB,sBAAsB,CAAC,MAA4B;IAC/D,MAAM,KAAK,GAAG,MAAM,CAAC,qCAAsB,CAAC,CAAC;IAC7C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,iDAA4B,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACrF,CAAC;AAED,qGAAqG;AACrG,0EAA0E;AAC1E,IAAI,iBAAiB,GAAkB,IAAI,CAAC;AAE5C;;;;;GAKG;AACH,8IAA8I;AAC9I,SAAgB,yBAAyB,CAAC,GAAW;IACjD,IAAI,iBAAiB,KAAK,IAAI;QAAE,OAAO,iBAAiB,CAAC;IACzD,IAAI,KAAK,GAAG,iDAA4B,CAAC;IACzC,wHAAwH;IACxH,IAAI,CAAC;QACD,KAAK,GAAG,sBAAsB,CAAC,IAAA,8BAAe,EAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;IACrE,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,KAAK,KAAK,CAAC;IACf,CAAC;IACD,iBAAiB,GAAG,KAAK,CAAC;IAC1B,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,oDAAoD;AACpD,kGAAkG;AAClG,SAAgB,4BAA4B;IACxC,iBAAiB,GAAG,IAAI,CAAC;AAC7B,CAAC;AAED;;;;;;;;GAQG;AACH,8IAA8I;AAC9I,SAAgB,oBAAoB,CAAC,KAAsB,EAAE,aAAqB,EAAE,kBAA0B;IAC1G,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAO,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,sBAAsB,CAAC,CAAC;IAClF,IAAI,KAAK,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QAC7B,IAAA,0CAAsB,EAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;IAC9D,CAAC;AACL,CAAC","sourcesContent":["import { loadAndValidate, WebpiecesRulesConfig, BranchStateGuardConfig, BRANCH_STATE_GUARD_KEY } from '@webpieces/rules-config';\nimport { DEFAULT_HANG_TIMEOUT_MINUTES } from '@webpieces/repo-workflow-core';\n\nimport { toError } from './to-error';\nimport { triggerMainSyncRefresh } from './main-sync-refresh';\nimport type { Rule } from './types';\n\n// ---------------------------------------------------------------------------\n// THE ONE `hangTimeoutMinutes`, and every caller that has to read it.\n//\n// There is ONE detached refresher writing ONE cache (.webpieces/main-sync-status.json), so there is one\n// knob: `hookGuards.branch-state-guard.hangTimeoutMinutes`, which tunes the stale-lock reclaim window.\n//\n// It used to be declared FOUR times — once per branch-state guard class — and read four times, and\n// three of those four values were structurally unable to take effect. Two things conspired:\n// `triggerMainSyncRefresh` latches at most one spawn per hook process, and two callers ran BEFORE any\n// guard's own call while passing the hardcoded default. So on the Bash path and the Read path (the two\n// hottest) the default always won the latch and the configured value never reached a spawn.\n//\n// Collapsing four declarations into one only fixes that if EVERY caller reads the one. This module is\n// where they do, which is also why it is a module rather than three helpers in runner.ts: the callers\n// live in two files (the runner and the hook adapter) and a knob honoured in one of them is the bug\n// again, one release later.\n// ---------------------------------------------------------------------------\n\n/**\n * The value on a branch-state ENTRY, or the default — for the four guard classes, which are handed\n * their own typed config and never see the whole file.\n *\n * The four used to spell this inline as `this.config.hangTimeoutMinutes ?? DEFAULT_HANG_TIMEOUT_MINUTES`,\n * which is a fourth copy of the resolution and exactly the shape that let the four DECLARATIONS drift\n * apart in the first place. One reader, one fallback.\n */\n// webpieces-disable no-function-outside-class -- module-scope config accessor, matching the shape of the runner helpers it was extracted from\nexport function hangTimeoutOf(config: BranchStateGuardConfig): number {\n const configured = config.hangTimeoutMinutes;\n return typeof configured === 'number' ? configured : DEFAULT_HANG_TIMEOUT_MINUTES;\n}\n\n/** The configured value for a caller that has ALREADY loaded the whole config. */\n// webpieces-disable no-function-outside-class -- module-scope config accessor, matching the shape of the runner helpers it was extracted from\nexport function branchStateHangTimeout(config: WebpiecesRulesConfig): number {\n const entry = config[BRANCH_STATE_GUARD_KEY];\n return entry === undefined ? DEFAULT_HANG_TIMEOUT_MINUTES : hangTimeoutOf(entry);\n}\n\n// Memoized per PROCESS, and a hook process handles exactly one tool call — so the adapter's two call\n// sites cost at most one extra config parse between them, never one each.\nlet cachedHangTimeout: number | null = null;\n\n/**\n * The configured value for a caller that has NOT loaded the config — the hook adapter's two pre-rule\n * refresh triggers (the webpieces.config.json edit bypass, and the Read fast path).\n *\n * Fails back to the default on an unloadable config: warming a cache must never throw on the tool path.\n */\n// webpieces-disable no-function-outside-class -- module-scope config accessor, matching the shape of the runner helpers it was extracted from\nexport function branchStateHangTimeoutFor(cwd: string): number {\n if (cachedHangTimeout !== null) return cachedHangTimeout;\n let value = DEFAULT_HANG_TIMEOUT_MINUTES;\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions -- a cache-warming knob must never throw on the tool path\n try {\n value = branchStateHangTimeout(loadAndValidate(cwd).rulesConfig);\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n cachedHangTimeout = value;\n return value;\n}\n\n/** Test-only: clears the per-process memo above. */\n// webpieces-disable no-function-outside-class -- module-scope test hook beside the memo it clears\nexport function resetHangTimeoutCacheForTest(): void {\n cachedHangTimeout = null;\n}\n\n/**\n * Fire-and-forget the detached refresher when the branch-state policy is loaded and active, so the\n * cache stays fresh as the AI works. The guard rules themselves also trigger it; this covers the Bash\n * path so the cache is warm on every command.\n *\n * Keyed on `feature-branch-guard` — the rule NAME, not the config key. Any of the four branch-state\n * classes would do (they share one entry, so they are on or off together); this one is asked because it\n * is the class whose cache freshness matters on the very next Write.\n */\n// webpieces-disable no-function-outside-class -- module-scope refresh trigger, matching the shape of the runner helpers it was extracted from\nexport function maybeRefreshMainSync(rules: readonly Rule[], workspaceRoot: string, hangTimeoutMinutes: number): void {\n const guard = rules.find((r: Rule): boolean => r.name === 'feature-branch-guard');\n if (guard && guard.shouldRun()) {\n triggerMainSyncRefresh(workspaceRoot, hangTimeoutMinutes);\n }\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** What a row with no cure — every ALLOW row, and every layer this module does not own — logs. */
|
|
2
|
-
export declare const NO_CURE = "-";
|
|
3
|
-
/**
|
|
4
|
-
* The literal cure for a layer+row, for the log line. `-` when the row allows, or when the layer is
|
|
5
|
-
* not one this module owns.
|
|
6
|
-
*
|
|
7
|
-
* Markdown backticks are stripped: the doc is read by a human in a renderer, the log is read through
|
|
8
|
-
* `grep`, and a cure you cannot grep for without escaping the fence characters is a cure the trail
|
|
9
|
-
* cannot be searched by. The words are otherwise untouched, so the log and the doc stay comparable
|
|
10
|
-
* literal-for-literal, which is the point of deriving one from the other.
|
|
11
|
-
*/
|
|
12
|
-
export declare function cureForMatrix(layer: string, row: string): string;
|
package/src/core/matrix-cures.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NO_CURE = void 0;
|
|
4
|
-
exports.cureForMatrix = cureForMatrix;
|
|
5
|
-
const l1_rows_1 = require("./l1-rows");
|
|
6
|
-
const l2_rows_1 = require("./l2-rows");
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// THE CURE, as a log field — the other half of `row=`.
|
|
9
|
-
//
|
|
10
|
-
// `row=` already joined a decision-log line to a row in the generated matrix. What it could not tell
|
|
11
|
-
// you is what the agent was actually TOLD to do, and that is the half you need to audit the table:
|
|
12
|
-
// a row whose cure keeps appearing in the trail next to a session that then did something else is a
|
|
13
|
-
// row whose use cases need updating. Reading the doc tells you what the cure IS; reading the log used
|
|
14
|
-
// to tell you only that some row fired.
|
|
15
|
-
//
|
|
16
|
-
// THE ONE DESIGN DECISION HERE: the cure is LOOKED UP from the row, never passed in by the caller.
|
|
17
|
-
//
|
|
18
|
-
// A `cure` field on GuardDecision would have been the obvious move and is the wrong one. It would let
|
|
19
|
-
// the logged cure and the printed cure drift — two spellings of one thing, which is the shim shape
|
|
20
|
-
// this repo rejects — and it would have to be threaded through every construction site, so the cheap
|
|
21
|
-
// path would be to pass '' and the field would rot. Deriving it from `decision.matrix` means the
|
|
22
|
-
// logged cure is BY CONSTRUCTION the same literal the generated doc prints for that row, and no call
|
|
23
|
-
// site changes at all.
|
|
24
|
-
//
|
|
25
|
-
// Both layers are covered because both stamp a MatrixRef: L1 dispatches from L1_ROWS, L2 joins by
|
|
26
|
-
// reason. L0's cures are a different shape (L0Cure carries mention + discriminator + guidance, and
|
|
27
|
-
// the sh shim prints them itself), so L0 rows resolve to '-' here rather than being half-rendered.
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
/** What a row with no cure — every ALLOW row, and every layer this module does not own — logs. */
|
|
30
|
-
exports.NO_CURE = '-';
|
|
31
|
-
/**
|
|
32
|
-
* The literal cure for a layer+row, for the log line. `-` when the row allows, or when the layer is
|
|
33
|
-
* not one this module owns.
|
|
34
|
-
*
|
|
35
|
-
* Markdown backticks are stripped: the doc is read by a human in a renderer, the log is read through
|
|
36
|
-
* `grep`, and a cure you cannot grep for without escaping the fence characters is a cure the trail
|
|
37
|
-
* cannot be searched by. The words are otherwise untouched, so the log and the doc stay comparable
|
|
38
|
-
* literal-for-literal, which is the point of deriving one from the other.
|
|
39
|
-
*/
|
|
40
|
-
// webpieces-disable no-function-outside-class -- the pure lookup this module exists to be, over the two row arrays it imports
|
|
41
|
-
function cureForMatrix(layer, row) {
|
|
42
|
-
if (layer === 'L2')
|
|
43
|
-
return cureOf(l2_rows_1.L2_ROWS.find((r) => String(r.num) === row)?.cure);
|
|
44
|
-
if (layer === 'L1')
|
|
45
|
-
return cureOf(l1_rows_1.L1_ROWS.find((r) => String(r.num) === row)?.cure?.denyMention);
|
|
46
|
-
return exports.NO_CURE;
|
|
47
|
-
}
|
|
48
|
-
// An allow row's cure cell is the em-dash the doc prints; in a log field that is noise, so it becomes
|
|
49
|
-
// the same `-` an unknown row gets. The distinction a reader needs is carried by `verdict`, not here.
|
|
50
|
-
// webpieces-disable no-function-outside-class -- private normalizer for cureForMatrix above, beside it in this module
|
|
51
|
-
function cureOf(cure) {
|
|
52
|
-
if (cure === undefined || cure === '' || cure === '—')
|
|
53
|
-
return exports.NO_CURE;
|
|
54
|
-
return cure.replace(/`/g, '');
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=matrix-cures.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"matrix-cures.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/matrix-cures.ts"],"names":[],"mappings":";;;AAuCA,sCAIC;AA3CD,uCAA2C;AAC3C,uCAA2C;AAE3C,8EAA8E;AAC9E,uDAAuD;AACvD,EAAE;AACF,qGAAqG;AACrG,mGAAmG;AACnG,oGAAoG;AACpG,sGAAsG;AACtG,wCAAwC;AACxC,EAAE;AACF,mGAAmG;AACnG,EAAE;AACF,sGAAsG;AACtG,mGAAmG;AACnG,qGAAqG;AACrG,iGAAiG;AACjG,qGAAqG;AACrG,uBAAuB;AACvB,EAAE;AACF,kGAAkG;AAClG,mGAAmG;AACnG,mGAAmG;AACnG,8EAA8E;AAE9E,kGAAkG;AACrF,QAAA,OAAO,GAAG,GAAG,CAAC;AAE3B;;;;;;;;GAQG;AACH,8HAA8H;AAC9H,SAAgB,aAAa,CAAC,KAAa,EAAE,GAAW;IACpD,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAQ,EAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IACpG,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAQ,EAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACjH,OAAO,eAAO,CAAC;AACnB,CAAC;AAED,sGAAsG;AACtG,sGAAsG;AACtG,sHAAsH;AACtH,SAAS,MAAM,CAAC,IAAwB;IACpC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,GAAG;QAAE,OAAO,eAAO,CAAC;IACtE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { L1_ROWS, L1Row } from './l1-rows';\nimport { L2_ROWS, L2Row } from './l2-rows';\n\n// ---------------------------------------------------------------------------\n// THE CURE, as a log field — the other half of `row=`.\n//\n// `row=` already joined a decision-log line to a row in the generated matrix. What it could not tell\n// you is what the agent was actually TOLD to do, and that is the half you need to audit the table:\n// a row whose cure keeps appearing in the trail next to a session that then did something else is a\n// row whose use cases need updating. Reading the doc tells you what the cure IS; reading the log used\n// to tell you only that some row fired.\n//\n// THE ONE DESIGN DECISION HERE: the cure is LOOKED UP from the row, never passed in by the caller.\n//\n// A `cure` field on GuardDecision would have been the obvious move and is the wrong one. It would let\n// the logged cure and the printed cure drift — two spellings of one thing, which is the shim shape\n// this repo rejects — and it would have to be threaded through every construction site, so the cheap\n// path would be to pass '' and the field would rot. Deriving it from `decision.matrix` means the\n// logged cure is BY CONSTRUCTION the same literal the generated doc prints for that row, and no call\n// site changes at all.\n//\n// Both layers are covered because both stamp a MatrixRef: L1 dispatches from L1_ROWS, L2 joins by\n// reason. L0's cures are a different shape (L0Cure carries mention + discriminator + guidance, and\n// the sh shim prints them itself), so L0 rows resolve to '-' here rather than being half-rendered.\n// ---------------------------------------------------------------------------\n\n/** What a row with no cure — every ALLOW row, and every layer this module does not own — logs. */\nexport const NO_CURE = '-';\n\n/**\n * The literal cure for a layer+row, for the log line. `-` when the row allows, or when the layer is\n * not one this module owns.\n *\n * Markdown backticks are stripped: the doc is read by a human in a renderer, the log is read through\n * `grep`, and a cure you cannot grep for without escaping the fence characters is a cure the trail\n * cannot be searched by. The words are otherwise untouched, so the log and the doc stay comparable\n * literal-for-literal, which is the point of deriving one from the other.\n */\n// webpieces-disable no-function-outside-class -- the pure lookup this module exists to be, over the two row arrays it imports\nexport function cureForMatrix(layer: string, row: string): string {\n if (layer === 'L2') return cureOf(L2_ROWS.find((r: L2Row): boolean => String(r.num) === row)?.cure);\n if (layer === 'L1') return cureOf(L1_ROWS.find((r: L1Row): boolean => String(r.num) === row)?.cure?.denyMention);\n return NO_CURE;\n}\n\n// An allow row's cure cell is the em-dash the doc prints; in a log field that is noise, so it becomes\n// the same `-` an unknown row gets. The distinction a reader needs is carried by `verdict`, not here.\n// webpieces-disable no-function-outside-class -- private normalizer for cureForMatrix above, beside it in this module\nfunction cureOf(cure: string | undefined): string {\n if (cure === undefined || cure === '' || cure === '—') return NO_CURE;\n return cure.replace(/`/g, '');\n}\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { EffectiveTree } from './effective-tree';
|
|
2
|
-
import { BlockedResult } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* L1: the directory this command would run in DOES NOT EXIST.
|
|
5
|
-
*
|
|
6
|
-
* THE INCIDENT (reproduced from a transcript, 0.4.603). A subagent was launched with its cwd inside
|
|
7
|
-
* `<root>/.claude/worktrees/agent-a5931637c5bff6d6d`. Mid-session another agent's cleanup REAPED that
|
|
8
|
-
* worktree. The shell's cwd still named a path that was now gone.
|
|
9
|
-
*
|
|
10
|
-
* `classify()` asked git for the toplevel, got `null` — and `null` meant two completely different
|
|
11
|
-
* things: "this is not a git directory" and "this directory does not exist". Conflating them classified
|
|
12
|
-
* the dead path as the PRIMARY clone, so force-to-root fired and printed:
|
|
13
|
-
*
|
|
14
|
-
* ❌ Run git/gh commands from the repo root, not a subdirectory.
|
|
15
|
-
* Command runs in: <root>/.claude/worktrees/agent-a5931637c5bff6d6d
|
|
16
|
-
* Judged against: <root>
|
|
17
|
-
* cd '<root>' && cd <root>/.claude/worktrees/agent-… && git fetch …
|
|
18
|
-
*
|
|
19
|
-
* Three things wrong at once: the diagnosis (it is not a subdirectory, it is GONE), the tone (it reads
|
|
20
|
-
* as a scolding for a mistake nobody made), and the remedy (it ends inside the deleted directory, so it
|
|
21
|
-
* cannot satisfy the check — the retry re-fires with the prefix doubled, then tripled). Three rounds
|
|
22
|
-
* were burned before `git worktree list` made the real state visible.
|
|
23
|
-
*
|
|
24
|
-
* So the fix is a DISTINCT tree kind with its own message. Naming the state is most of the cure: an
|
|
25
|
-
* agent that is told the directory is gone stops trying to `cd` into it. The remedy deliberately routes
|
|
26
|
-
* through the governed root and drops the command's own leading `cd`, so it can never point back at the
|
|
27
|
-
* dead path — the same convergence property `remedyAtRoot` gives force-to-root.
|
|
28
|
-
*
|
|
29
|
-
* The lost-work line is not padding. A reaped worktree takes uncommitted changes with it, and an agent
|
|
30
|
-
* that silently retries at the root will otherwise report success on work that no longer exists.
|
|
31
|
-
*/
|
|
32
|
-
export declare class MissingDirectoryGuard {
|
|
33
|
-
private readonly resolver;
|
|
34
|
-
/** The deny report, or null to allow. */
|
|
35
|
-
block(command: string, tree: EffectiveTree): string | null;
|
|
36
|
-
private report;
|
|
37
|
-
}
|
|
38
|
-
export declare function missingDirectoryBlock(command: string, tree: EffectiveTree): BlockedResult | null;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MissingDirectoryGuard = void 0;
|
|
4
|
-
exports.missingDirectoryBlock = missingDirectoryBlock;
|
|
5
|
-
const effective_tree_1 = require("./effective-tree");
|
|
6
|
-
const types_1 = require("./types");
|
|
7
|
-
/**
|
|
8
|
-
* L1: the directory this command would run in DOES NOT EXIST.
|
|
9
|
-
*
|
|
10
|
-
* THE INCIDENT (reproduced from a transcript, 0.4.603). A subagent was launched with its cwd inside
|
|
11
|
-
* `<root>/.claude/worktrees/agent-a5931637c5bff6d6d`. Mid-session another agent's cleanup REAPED that
|
|
12
|
-
* worktree. The shell's cwd still named a path that was now gone.
|
|
13
|
-
*
|
|
14
|
-
* `classify()` asked git for the toplevel, got `null` — and `null` meant two completely different
|
|
15
|
-
* things: "this is not a git directory" and "this directory does not exist". Conflating them classified
|
|
16
|
-
* the dead path as the PRIMARY clone, so force-to-root fired and printed:
|
|
17
|
-
*
|
|
18
|
-
* ❌ Run git/gh commands from the repo root, not a subdirectory.
|
|
19
|
-
* Command runs in: <root>/.claude/worktrees/agent-a5931637c5bff6d6d
|
|
20
|
-
* Judged against: <root>
|
|
21
|
-
* cd '<root>' && cd <root>/.claude/worktrees/agent-… && git fetch …
|
|
22
|
-
*
|
|
23
|
-
* Three things wrong at once: the diagnosis (it is not a subdirectory, it is GONE), the tone (it reads
|
|
24
|
-
* as a scolding for a mistake nobody made), and the remedy (it ends inside the deleted directory, so it
|
|
25
|
-
* cannot satisfy the check — the retry re-fires with the prefix doubled, then tripled). Three rounds
|
|
26
|
-
* were burned before `git worktree list` made the real state visible.
|
|
27
|
-
*
|
|
28
|
-
* So the fix is a DISTINCT tree kind with its own message. Naming the state is most of the cure: an
|
|
29
|
-
* agent that is told the directory is gone stops trying to `cd` into it. The remedy deliberately routes
|
|
30
|
-
* through the governed root and drops the command's own leading `cd`, so it can never point back at the
|
|
31
|
-
* dead path — the same convergence property `remedyAtRoot` gives force-to-root.
|
|
32
|
-
*
|
|
33
|
-
* The lost-work line is not padding. A reaped worktree takes uncommitted changes with it, and an agent
|
|
34
|
-
* that silently retries at the root will otherwise report success on work that no longer exists.
|
|
35
|
-
*/
|
|
36
|
-
class MissingDirectoryGuard {
|
|
37
|
-
resolver = new effective_tree_1.EffectiveTreeResolver();
|
|
38
|
-
/** The deny report, or null to allow. */
|
|
39
|
-
block(command, tree) {
|
|
40
|
-
if (tree.kind !== 'missing')
|
|
41
|
-
return null;
|
|
42
|
-
return this.report(command, tree);
|
|
43
|
-
}
|
|
44
|
-
// Short, on the L0 message diet: name the state, say what it costs, give ONE runnable line.
|
|
45
|
-
report(command, tree) {
|
|
46
|
-
return [
|
|
47
|
-
`❌ The directory this command would run in no longer exists:`,
|
|
48
|
-
` ${tree.effectiveCwd}`,
|
|
49
|
-
' Most often it was a linked worktree that has since been reaped (`git worktree list` no',
|
|
50
|
-
' longer shows it). Nothing can run there, and any UNCOMMITTED work that was in it is gone.',
|
|
51
|
-
'',
|
|
52
|
-
` Continue from ${tree.governedRoot} — this line does NOT route back through the dead path:`,
|
|
53
|
-
` ${this.resolver.remedyAtRoot(tree.governedRoot, command)}`,
|
|
54
|
-
].join('\n');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.MissingDirectoryGuard = MissingDirectoryGuard;
|
|
58
|
-
// L1 row 7's dispatch entry. It lives HERE rather than beside its two siblings in runner.ts because
|
|
59
|
-
// the guard owns its own report and runner.ts is at its file-size cap — the runner needs only the row
|
|
60
|
-
// lookup and this one call.
|
|
61
|
-
// webpieces-disable no-function-outside-class -- the one-line runner entry point for the class above, beside it
|
|
62
|
-
function missingDirectoryBlock(command, tree) {
|
|
63
|
-
const report = new MissingDirectoryGuard().block(command, tree);
|
|
64
|
-
return report === null ? null : new types_1.BlockedResult(report);
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=missing-directory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"missing-directory.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/missing-directory.ts"],"names":[],"mappings":";;;AA2DA,sDAGC;AA9DD,qDAAwE;AACxE,mCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,qBAAqB;IACb,QAAQ,GAAG,IAAI,sCAAqB,EAAE,CAAC;IAExD,yCAAyC;IACzC,KAAK,CAAC,OAAe,EAAE,IAAmB;QACtC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,4FAA4F;IACpF,MAAM,CAAC,OAAe,EAAE,IAAmB;QAC/C,OAAO;YACH,6DAA6D;YAC7D,QAAQ,IAAI,CAAC,YAAY,EAAE;YAC3B,2FAA2F;YAC3F,8FAA8F;YAC9F,EAAE;YACF,oBAAoB,IAAI,CAAC,YAAY,yDAAyD;YAC9F,QAAQ,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE;SACnE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;CACJ;AArBD,sDAqBC;AAED,oGAAoG;AACpG,sGAAsG;AACtG,4BAA4B;AAC5B,gHAAgH;AAChH,SAAgB,qBAAqB,CAAC,OAAe,EAAE,IAAmB;IACtE,MAAM,MAAM,GAAG,IAAI,qBAAqB,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAChE,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,qBAAa,CAAC,MAAM,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import { EffectiveTree, EffectiveTreeResolver } from './effective-tree';\nimport { BlockedResult } from './types';\n\n/**\n * L1: the directory this command would run in DOES NOT EXIST.\n *\n * THE INCIDENT (reproduced from a transcript, 0.4.603). A subagent was launched with its cwd inside\n * `<root>/.claude/worktrees/agent-a5931637c5bff6d6d`. Mid-session another agent's cleanup REAPED that\n * worktree. The shell's cwd still named a path that was now gone.\n *\n * `classify()` asked git for the toplevel, got `null` — and `null` meant two completely different\n * things: \"this is not a git directory\" and \"this directory does not exist\". Conflating them classified\n * the dead path as the PRIMARY clone, so force-to-root fired and printed:\n *\n * ❌ Run git/gh commands from the repo root, not a subdirectory.\n * Command runs in: <root>/.claude/worktrees/agent-a5931637c5bff6d6d\n * Judged against: <root>\n * cd '<root>' && cd <root>/.claude/worktrees/agent-… && git fetch …\n *\n * Three things wrong at once: the diagnosis (it is not a subdirectory, it is GONE), the tone (it reads\n * as a scolding for a mistake nobody made), and the remedy (it ends inside the deleted directory, so it\n * cannot satisfy the check — the retry re-fires with the prefix doubled, then tripled). Three rounds\n * were burned before `git worktree list` made the real state visible.\n *\n * So the fix is a DISTINCT tree kind with its own message. Naming the state is most of the cure: an\n * agent that is told the directory is gone stops trying to `cd` into it. The remedy deliberately routes\n * through the governed root and drops the command's own leading `cd`, so it can never point back at the\n * dead path — the same convergence property `remedyAtRoot` gives force-to-root.\n *\n * The lost-work line is not padding. A reaped worktree takes uncommitted changes with it, and an agent\n * that silently retries at the root will otherwise report success on work that no longer exists.\n */\nexport class MissingDirectoryGuard {\n private readonly resolver = new EffectiveTreeResolver();\n\n /** The deny report, or null to allow. */\n block(command: string, tree: EffectiveTree): string | null {\n if (tree.kind !== 'missing') return null;\n return this.report(command, tree);\n }\n\n // Short, on the L0 message diet: name the state, say what it costs, give ONE runnable line.\n private report(command: string, tree: EffectiveTree): string {\n return [\n `❌ The directory this command would run in no longer exists:`,\n ` ${tree.effectiveCwd}`,\n ' Most often it was a linked worktree that has since been reaped (`git worktree list` no',\n ' longer shows it). Nothing can run there, and any UNCOMMITTED work that was in it is gone.',\n '',\n ` Continue from ${tree.governedRoot} — this line does NOT route back through the dead path:`,\n ` ${this.resolver.remedyAtRoot(tree.governedRoot, command)}`,\n ].join('\\n');\n }\n}\n\n// L1 row 7's dispatch entry. It lives HERE rather than beside its two siblings in runner.ts because\n// the guard owns its own report and runner.ts is at its file-size cap — the runner needs only the row\n// lookup and this one call.\n// webpieces-disable no-function-outside-class -- the one-line runner entry point for the class above, beside it\nexport function missingDirectoryBlock(command: string, tree: EffectiveTree): BlockedResult | null {\n const report = new MissingDirectoryGuard().block(command, tree);\n return report === null ? null : new BlockedResult(report);\n}\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { CommandScanner } from './command-scan';
|
|
2
|
-
/**
|
|
3
|
-
* Is this shell command pure INSPECTION — can it be trusted to change nothing?
|
|
4
|
-
*
|
|
5
|
-
* WHY this exists: when webpieces.config.json cannot be loaded (unparseable, or invalid against the
|
|
6
|
-
* installed validator) every bash command is denied, because with no config there are no guards and
|
|
7
|
-
* fail-closed is the only safe answer. That is right for work — and catastrophic for recovery, because
|
|
8
|
-
* the denial also took out `cat`, `grep` and `sed -n` against webpieces.config.json itself. The guard
|
|
9
|
-
* blocked the exact tools needed to see and fix the problem it was reporting, which is a dead end an
|
|
10
|
-
* agent cannot escape from inside the session. (Reproduced live: mid-merge, the config legitimately
|
|
11
|
-
* held `<<<<<<< HEAD` markers and every attempt to look at it was refused.)
|
|
12
|
-
*
|
|
13
|
-
* The rest of the system already models the escape hatch correctly — reading AND editing
|
|
14
|
-
* webpieces.config.json is always allowed (hook-core's config bypass, the stale-shim recovery
|
|
15
|
-
* carve-out, ContentReadScan's escape-hatch paths). This closes the one place that did not honour it.
|
|
16
|
-
*
|
|
17
|
-
* The bar is deliberately paranoid, because this is a bypass of ALL guards:
|
|
18
|
-
* - every invoked segment's command word must be an allowlisted inspector;
|
|
19
|
-
* - `git`/`gh` are excluded outright, even their read-only subcommands — the guards exist to police
|
|
20
|
-
* git, and "read-only git" is not a line worth drawing while flying blind;
|
|
21
|
-
* - any output redirect to a file (`> x`, `>> x`) makes the command a writer;
|
|
22
|
-
* - the in-place/mutating flags of otherwise-read-only tools (`sed -i`, `find -delete`) are refused.
|
|
23
|
-
* Anything not provably inert stays blocked.
|
|
24
|
-
*/
|
|
25
|
-
export declare class ReadOnlyInspectionScan {
|
|
26
|
-
private readonly scanner;
|
|
27
|
-
private readonly shell;
|
|
28
|
-
constructor(scanner?: CommandScanner);
|
|
29
|
-
/** True only when EVERY segment of the command is provably inert. Empty command → false. */
|
|
30
|
-
isReadOnlyInspection(command: string): boolean;
|
|
31
|
-
private segmentIsInert;
|
|
32
|
-
private redirectsToFile;
|
|
33
|
-
private hasMutatingFlag;
|
|
34
|
-
}
|