@cad0p/pi-steering 0.1.0
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/CHANGELOG.md +36 -0
- package/LICENSE +29 -0
- package/README.md +920 -0
- package/dist/__test-helpers__.d.ts +95 -0
- package/dist/__test-helpers__.d.ts.map +1 -0
- package/dist/__test-helpers__.js +174 -0
- package/dist/__test-helpers__.js.map +1 -0
- package/dist/bin/pi-steering.d.ts +9 -0
- package/dist/bin/pi-steering.d.ts.map +1 -0
- package/dist/bin/pi-steering.js +506 -0
- package/dist/bin/pi-steering.js.map +1 -0
- package/dist/compat.d.ts +50 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +180 -0
- package/dist/compat.js.map +1 -0
- package/dist/defaults.d.ts +61 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +106 -0
- package/dist/defaults.js.map +1 -0
- package/dist/define-config.d.ts +235 -0
- package/dist/define-config.d.ts.map +1 -0
- package/dist/define-config.js +118 -0
- package/dist/define-config.js.map +1 -0
- package/dist/define-predicate.d.ts +49 -0
- package/dist/define-predicate.d.ts.map +1 -0
- package/dist/define-predicate.js +35 -0
- package/dist/define-predicate.js.map +1 -0
- package/dist/evaluator-internals/context.d.ts +186 -0
- package/dist/evaluator-internals/context.d.ts.map +1 -0
- package/dist/evaluator-internals/context.js +219 -0
- package/dist/evaluator-internals/context.js.map +1 -0
- package/dist/evaluator-internals/override.d.ts +19 -0
- package/dist/evaluator-internals/override.d.ts.map +1 -0
- package/dist/evaluator-internals/override.js +79 -0
- package/dist/evaluator-internals/override.js.map +1 -0
- package/dist/evaluator-internals/predicates.d.ts +152 -0
- package/dist/evaluator-internals/predicates.d.ts.map +1 -0
- package/dist/evaluator-internals/predicates.js +849 -0
- package/dist/evaluator-internals/predicates.js.map +1 -0
- package/dist/evaluator-internals/speculative-synthesis.d.ts +102 -0
- package/dist/evaluator-internals/speculative-synthesis.d.ts.map +1 -0
- package/dist/evaluator-internals/speculative-synthesis.js +101 -0
- package/dist/evaluator-internals/speculative-synthesis.js.map +1 -0
- package/dist/evaluator.d.ts +101 -0
- package/dist/evaluator.d.ts.map +1 -0
- package/dist/evaluator.js +714 -0
- package/dist/evaluator.js.map +1 -0
- package/dist/helpers/walker-unknown-cwd-reason.d.ts +68 -0
- package/dist/helpers/walker-unknown-cwd-reason.d.ts.map +1 -0
- package/dist/helpers/walker-unknown-cwd-reason.js +73 -0
- package/dist/helpers/walker-unknown-cwd-reason.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/drop-unused-observers.d.ts +43 -0
- package/dist/internal/drop-unused-observers.d.ts.map +1 -0
- package/dist/internal/drop-unused-observers.js +50 -0
- package/dist/internal/drop-unused-observers.js.map +1 -0
- package/dist/internal/finalize-plugin-state.d.ts +22 -0
- package/dist/internal/finalize-plugin-state.d.ts.map +1 -0
- package/dist/internal/finalize-plugin-state.js +14 -0
- package/dist/internal/finalize-plugin-state.js.map +1 -0
- package/dist/internal/merge-observers.d.ts +30 -0
- package/dist/internal/merge-observers.d.ts.map +1 -0
- package/dist/internal/merge-observers.js +27 -0
- package/dist/internal/merge-observers.js.map +1 -0
- package/dist/internal/pattern-utils.d.ts +33 -0
- package/dist/internal/pattern-utils.d.ts.map +1 -0
- package/dist/internal/pattern-utils.js +20 -0
- package/dist/internal/pattern-utils.js.map +1 -0
- package/dist/internal/ref-text.d.ts +11 -0
- package/dist/internal/ref-text.d.ts.map +1 -0
- package/dist/internal/ref-text.js +15 -0
- package/dist/internal/ref-text.js.map +1 -0
- package/dist/internal/session-runtime.d.ts +44 -0
- package/dist/internal/session-runtime.d.ts.map +1 -0
- package/dist/internal/session-runtime.js +143 -0
- package/dist/internal/session-runtime.js.map +1 -0
- package/dist/internal/watch-matcher.d.ts +56 -0
- package/dist/internal/watch-matcher.d.ts.map +1 -0
- package/dist/internal/watch-matcher.js +179 -0
- package/dist/internal/watch-matcher.js.map +1 -0
- package/dist/loader.d.ts +97 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +527 -0
- package/dist/loader.js.map +1 -0
- package/dist/observer-dispatcher.d.ts +69 -0
- package/dist/observer-dispatcher.d.ts.map +1 -0
- package/dist/observer-dispatcher.js +184 -0
- package/dist/observer-dispatcher.js.map +1 -0
- package/dist/plugin-merger.d.ts +175 -0
- package/dist/plugin-merger.d.ts.map +1 -0
- package/dist/plugin-merger.js +450 -0
- package/dist/plugin-merger.js.map +1 -0
- package/dist/plugins/git/branch-tracker.d.ts +85 -0
- package/dist/plugins/git/branch-tracker.d.ts.map +1 -0
- package/dist/plugins/git/branch-tracker.js +181 -0
- package/dist/plugins/git/branch-tracker.js.map +1 -0
- package/dist/plugins/git/cwd-extensions.d.ts +10 -0
- package/dist/plugins/git/cwd-extensions.d.ts.map +1 -0
- package/dist/plugins/git/cwd-extensions.js +155 -0
- package/dist/plugins/git/cwd-extensions.js.map +1 -0
- package/dist/plugins/git/git-ops.d.ts +89 -0
- package/dist/plugins/git/git-ops.d.ts.map +1 -0
- package/dist/plugins/git/git-ops.js +107 -0
- package/dist/plugins/git/git-ops.js.map +1 -0
- package/dist/plugins/git/index.d.ts +225 -0
- package/dist/plugins/git/index.d.ts.map +1 -0
- package/dist/plugins/git/index.js +52 -0
- package/dist/plugins/git/index.js.map +1 -0
- package/dist/plugins/git/predicates.d.ts +312 -0
- package/dist/plugins/git/predicates.d.ts.map +1 -0
- package/dist/plugins/git/predicates.js +580 -0
- package/dist/plugins/git/predicates.js.map +1 -0
- package/dist/plugins/git/rules.d.ts +209 -0
- package/dist/plugins/git/rules.d.ts.map +1 -0
- package/dist/plugins/git/rules.js +267 -0
- package/dist/plugins/git/rules.js.map +1 -0
- package/dist/schema.d.ts +1799 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +4 -0
- package/dist/schema.js.map +1 -0
- package/dist/testing/index.d.ts +621 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +747 -0
- package/dist/testing/index.js.map +1 -0
- package/examples/README.md +83 -0
- package/examples/combined-git-discipline/README.md +52 -0
- package/examples/combined-git-discipline/node_modules/.bin/pi-steering +43 -0
- package/examples/combined-git-discipline/package.json +18 -0
- package/examples/combined-git-discipline/steering.json +27 -0
- package/examples/combined-git-discipline/steering.test.ts +42 -0
- package/examples/combined-git-discipline/steering.ts +64 -0
- package/examples/combined-git-discipline/tsconfig.json +7 -0
- package/examples/draft-prs-only/README.md +42 -0
- package/examples/draft-prs-only/node_modules/.bin/pi-steering +43 -0
- package/examples/draft-prs-only/package.json +18 -0
- package/examples/draft-prs-only/steering.json +12 -0
- package/examples/draft-prs-only/steering.test.ts +48 -0
- package/examples/draft-prs-only/steering.ts +36 -0
- package/examples/draft-prs-only/tsconfig.json +7 -0
- package/examples/dynamic-reason-runtime-cwd/README.md +148 -0
- package/examples/dynamic-reason-runtime-cwd/node_modules/.bin/pi-steering +43 -0
- package/examples/dynamic-reason-runtime-cwd/package.json +18 -0
- package/examples/dynamic-reason-runtime-cwd/steering.test.ts +130 -0
- package/examples/dynamic-reason-runtime-cwd/steering.ts +82 -0
- package/examples/dynamic-reason-runtime-cwd/tsconfig.json +7 -0
- package/examples/force-push-strict/README.md +75 -0
- package/examples/force-push-strict/node_modules/.bin/pi-steering +43 -0
- package/examples/force-push-strict/package.json +18 -0
- package/examples/force-push-strict/steering.json +12 -0
- package/examples/force-push-strict/steering.test.ts +51 -0
- package/examples/force-push-strict/steering.ts +54 -0
- package/examples/force-push-strict/tsconfig.json +7 -0
- package/examples/no-amend/README.md +52 -0
- package/examples/no-amend/node_modules/.bin/pi-steering +43 -0
- package/examples/no-amend/package.json +18 -0
- package/examples/no-amend/steering.cwd-scoped.json +12 -0
- package/examples/no-amend/steering.json +11 -0
- package/examples/no-amend/steering.test.ts +49 -0
- package/examples/no-amend/steering.ts +38 -0
- package/examples/no-amend/tsconfig.json +7 -0
- package/examples/work-item-plugin/README.md +103 -0
- package/examples/work-item-plugin/node_modules/.bin/pi-steering +43 -0
- package/examples/work-item-plugin/package.json +19 -0
- package/examples/work-item-plugin/src/index.test.ts +168 -0
- package/examples/work-item-plugin/src/index.ts +122 -0
- package/examples/work-item-plugin/src/observers/npm-test-tracker.test.ts +95 -0
- package/examples/work-item-plugin/src/observers/npm-test-tracker.ts +88 -0
- package/examples/work-item-plugin/src/observers/retest-required-tracker.test.ts +81 -0
- package/examples/work-item-plugin/src/observers/retest-required-tracker.ts +81 -0
- package/examples/work-item-plugin/src/predicates/work-item-format.test.ts +157 -0
- package/examples/work-item-plugin/src/predicates/work-item-format.ts +99 -0
- package/examples/work-item-plugin/src/rules/commit-description-check.test.ts +107 -0
- package/examples/work-item-plugin/src/rules/commit-description-check.ts +83 -0
- package/examples/work-item-plugin/src/rules/commit-requires-work-item.test.ts +79 -0
- package/examples/work-item-plugin/src/rules/commit-requires-work-item.ts +56 -0
- package/examples/work-item-plugin/src/rules/push-requires-tests.test.ts +245 -0
- package/examples/work-item-plugin/src/rules/push-requires-tests.ts +62 -0
- package/examples/work-item-plugin/tsconfig.json +8 -0
- package/package.json +88 -0
- package/skills/steering-authoring/SKILL.md +102 -0
- package/src/INVARIANTS.md +116 -0
- package/src/__test-helpers__.ts +243 -0
- package/src/bin/pi-steering.test.ts +920 -0
- package/src/bin/pi-steering.ts +584 -0
- package/src/compat.test.ts +431 -0
- package/src/compat.ts +282 -0
- package/src/defaults.test.ts +585 -0
- package/src/defaults.ts +148 -0
- package/src/define-config.test.ts +888 -0
- package/src/define-config.ts +375 -0
- package/src/define-predicate.test.ts +70 -0
- package/src/define-predicate.ts +57 -0
- package/src/evaluator-internals/context.ts +290 -0
- package/src/evaluator-internals/override.test.ts +99 -0
- package/src/evaluator-internals/override.ts +83 -0
- package/src/evaluator-internals/predicates.ts +1037 -0
- package/src/evaluator-internals/speculative-synthesis.test.ts +411 -0
- package/src/evaluator-internals/speculative-synthesis.ts +199 -0
- package/src/evaluator.test.ts +6296 -0
- package/src/evaluator.ts +1106 -0
- package/src/factory-time-load.test.ts +630 -0
- package/src/helpers/walker-unknown-cwd-reason.test.ts +73 -0
- package/src/helpers/walker-unknown-cwd-reason.ts +83 -0
- package/src/index.test.ts +836 -0
- package/src/index.ts +229 -0
- package/src/internal/drop-unused-observers.test.ts +141 -0
- package/src/internal/drop-unused-observers.ts +81 -0
- package/src/internal/finalize-plugin-state.ts +43 -0
- package/src/internal/merge-observers.ts +51 -0
- package/src/internal/pattern-utils.test.ts +52 -0
- package/src/internal/pattern-utils.ts +38 -0
- package/src/internal/ref-text.test.ts +54 -0
- package/src/internal/ref-text.ts +17 -0
- package/src/internal/session-runtime.test.ts +629 -0
- package/src/internal/session-runtime.ts +201 -0
- package/src/internal/watch-matcher.test.ts +326 -0
- package/src/internal/watch-matcher.ts +200 -0
- package/src/jsdoc-propagation.test.ts +277 -0
- package/src/loader.test.ts +1098 -0
- package/src/loader.ts +581 -0
- package/src/not-block-onunknown.test.ts +554 -0
- package/src/observer-dispatcher.test.ts +939 -0
- package/src/observer-dispatcher.ts +290 -0
- package/src/per-predicate-typing.test.ts +361 -0
- package/src/plugin-merger.test.ts +790 -0
- package/src/plugin-merger.ts +598 -0
- package/src/plugins/git/README.md +485 -0
- package/src/plugins/git/branch-tracker.test.ts +281 -0
- package/src/plugins/git/branch-tracker.ts +187 -0
- package/src/plugins/git/cwd-extensions.test.ts +230 -0
- package/src/plugins/git/cwd-extensions.ts +160 -0
- package/src/plugins/git/git-ops.test.ts +397 -0
- package/src/plugins/git/git-ops.ts +173 -0
- package/src/plugins/git/index.ts +253 -0
- package/src/plugins/git/integration.test.ts +705 -0
- package/src/plugins/git/predicates.test.ts +1401 -0
- package/src/plugins/git/predicates.ts +693 -0
- package/src/plugins/git/rules.test.ts +1001 -0
- package/src/plugins/git/rules.ts +307 -0
- package/src/schema.test.ts +259 -0
- package/src/schema.ts +1963 -0
- package/src/testing/index.test.ts +1696 -0
-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;GAIG;GACD,kBAAkB;AACpB;;;;GAIG;GACD,uBAAuB;AACzB;;;;;;GAMG;GACD,wBAAwB;AAC1B;;;;;;;;;;GAUG;GACD,cAAc,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;OASG;IACH,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAE1B,mEAAmE;IACnE,IAAI,EAAE,sBAAsB,CAAC;IAE7B,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,uBAAuB"}
|
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Testing primitives for rule and plugin authors.
|
|
3
|
+
*
|
|
4
|
+
* Subpath export: `@cad0p/pi-steering/testing`. Also re-exported
|
|
5
|
+
* at the package root for discoverability.
|
|
6
|
+
*
|
|
7
|
+
* Phase 5a ships four low-level primitives that wrap the engine's
|
|
8
|
+
* internals without forcing authors to stand up a pi runtime stub:
|
|
9
|
+
*
|
|
10
|
+
* - {@link loadHarness} — build an evaluator + dispatcher
|
|
11
|
+
* pair from a static
|
|
12
|
+
* {@link SteeringConfig}. No walk-up
|
|
13
|
+
* loading — tests pass explicit
|
|
14
|
+
* config.
|
|
15
|
+
* - {@link mockContext} — build a {@link PredicateContext}
|
|
16
|
+
* for unit-testing predicate
|
|
17
|
+
* handlers in isolation.
|
|
18
|
+
* - {@link mockObserverContext} — same for {@link ObserverContext}.
|
|
19
|
+
* - {@link getAppendedEntries} — read back `appendEntry` writes
|
|
20
|
+
* captured by either mock context.
|
|
21
|
+
*
|
|
22
|
+
* The convenience wrappers (`testPredicate`, `expectBlocks`,
|
|
23
|
+
* `runMatrix`, …) that build on these live in a Phase 5b follow-up.
|
|
24
|
+
*
|
|
25
|
+
* Design notes:
|
|
26
|
+
*
|
|
27
|
+
* - `exec` is deliberately stub-required. The defaults reject with a
|
|
28
|
+
* clear error so a test forgetting to stub fails loudly instead of
|
|
29
|
+
* silently evaluating predicates against an always-empty exec
|
|
30
|
+
* result.
|
|
31
|
+
* - `appendEntry` captures are tracked in a module-level WeakMap
|
|
32
|
+
* keyed by the context object, so {@link getAppendedEntries}
|
|
33
|
+
* accesses cleanly without leaking state across tests and without
|
|
34
|
+
* requiring users to pass capture buffers around.
|
|
35
|
+
* - `findEntries` draws from an entries array passed in at context
|
|
36
|
+
* build time; it does NOT pick up entries written via the
|
|
37
|
+
* context's own `appendEntry`. That mirrors the production
|
|
38
|
+
* evaluator's per-call snapshot semantics — appends are visible
|
|
39
|
+
* on the NEXT evaluation, not the current one.
|
|
40
|
+
*/
|
|
41
|
+
import type { ExtensionContext, ExecResult as PiExecResult, ToolCallEvent, ToolCallEventResult } from "@earendil-works/pi-coding-agent";
|
|
42
|
+
import { type EvaluatorHost, type EvaluatorRuntime } from "../evaluator.ts";
|
|
43
|
+
import type { SyntheticEntry } from "../evaluator-internals/speculative-synthesis.ts";
|
|
44
|
+
import { type ObserverDispatcher } from "../observer-dispatcher.ts";
|
|
45
|
+
import type { ResolvedPluginState } from "../plugin-merger.ts";
|
|
46
|
+
import type { ExecOpts, ExecResult, Observer, ObserverContext, PredicateContext, PredicateHandler, PredicateToolInput, PredicateVerdict, ToolResultEvent as SchemaToolResultEvent, SteeringConfig, SteeringDiagnostic, WhenWalkerState } from "../schema.ts";
|
|
47
|
+
/**
|
|
48
|
+
* Build-once, invoke-many handle a test uses to drive the engine
|
|
49
|
+
* against a scenario. `evaluate` and `dispatch` have identical
|
|
50
|
+
* signatures to {@link EvaluatorRuntime.evaluate} and
|
|
51
|
+
* {@link ObserverDispatcher.dispatch} so production call sites can be
|
|
52
|
+
* ported verbatim.
|
|
53
|
+
*/
|
|
54
|
+
export interface Harness {
|
|
55
|
+
/** See {@link EvaluatorRuntime.evaluate}. */
|
|
56
|
+
evaluate: EvaluatorRuntime["evaluate"];
|
|
57
|
+
/** See {@link ObserverDispatcher.dispatch}. */
|
|
58
|
+
dispatch: ObserverDispatcher["dispatch"];
|
|
59
|
+
/**
|
|
60
|
+
* The effective config the harness was built from (after default
|
|
61
|
+
* injection and `disable` filtering).
|
|
62
|
+
*
|
|
63
|
+
* No-op short-circuit caveat: when `harness.diagnostics` has an
|
|
64
|
+
* error-class entry, treat `harness.config` as the post-merge,
|
|
65
|
+
* post-disabledRules-filter snapshot pi-steering would have
|
|
66
|
+
* handed to `buildEvaluator` if the diagnostics had been clean —
|
|
67
|
+
* provided as a debugging artifact, NOT an executable config
|
|
68
|
+
* production would accept (production would have thrown).
|
|
69
|
+
* Inspect `harness.diagnostics` first to learn which surface
|
|
70
|
+
* flagged a problem, then fix the source config and re-load
|
|
71
|
+
* before reading `config` for any "production would have run on
|
|
72
|
+
* this shape" interpretation.
|
|
73
|
+
*/
|
|
74
|
+
readonly config: SteeringConfig;
|
|
75
|
+
/**
|
|
76
|
+
* The plugin merger's resolved state, for introspection /
|
|
77
|
+
* assertions.
|
|
78
|
+
*
|
|
79
|
+
* No-op short-circuit caveat: when an error-class diagnostic fires
|
|
80
|
+
* and the harness returns the no-op evaluator/dispatcher pair,
|
|
81
|
+
* `resolved.diagnostics` carries the FULL diagnostic list (merge-
|
|
82
|
+
* side + user-config-name + resolve-side) to mirror
|
|
83
|
+
* `harness.diagnostics`. In the regular path, `resolved.diagnostics`
|
|
84
|
+
* carries only the resolve-side stream — see
|
|
85
|
+
* {@link SteeringDiagnosticKind} for the per-kind
|
|
86
|
+
* loader-vs-merger split. Consumers should prefer
|
|
87
|
+
* `harness.diagnostics` for the canonical full list.
|
|
88
|
+
*/
|
|
89
|
+
readonly resolved: ResolvedPluginState;
|
|
90
|
+
/**
|
|
91
|
+
* Every {@link SteeringDiagnostic} produced while building the
|
|
92
|
+
* harness — merge-side (within-layer collisions, cross-config
|
|
93
|
+
* collisions when {@link LoadHarnessOptions.includeDefaults} is
|
|
94
|
+
* `true`) and plugin-merger-side (predicate / observer / rule /
|
|
95
|
+
* extension-orphan / reserved-name / invalid-name diagnostics,
|
|
96
|
+
* plus user-config rule and observer name validation).
|
|
97
|
+
*
|
|
98
|
+
* Unlike production, `loadHarness` does NOT throw on error-class
|
|
99
|
+
* diagnostics. Plugin-author tests assert directly on this array
|
|
100
|
+
* (e.g. `harness.diagnostics.some(d => d.kind === "reserved-tracker-name")`)
|
|
101
|
+
* so the failure surface is observable in test output rather than
|
|
102
|
+
* a thrown error that hides which other diagnostics fired. Both
|
|
103
|
+
* plugin-shipped and user-config malformed names route through the
|
|
104
|
+
* same `kind: "invalid-name"` diagnostic stream — plugin-author
|
|
105
|
+
* tests can use a uniform matrix of malformed-name cases without
|
|
106
|
+
* worrying about which surface raised the issue.
|
|
107
|
+
*
|
|
108
|
+
* Production-strictness divergence: `loadHarness` does NOT honor
|
|
109
|
+
* the merged config's `failOnWarnings` flag. Production's
|
|
110
|
+
* `buildSessionRuntime` throws when `failOnWarnings !== false`
|
|
111
|
+
* (default `true`) AND any warning-class diagnostic is present;
|
|
112
|
+
* the harness ignores `failOnWarnings` and returns a real
|
|
113
|
+
* evaluator/dispatcher running on the post-collision merged
|
|
114
|
+
* state. Tests intending to use the harness as a "production
|
|
115
|
+
* prediction" should check this array against the strict-mode
|
|
116
|
+
* rule themselves, e.g.
|
|
117
|
+
* `harness.diagnostics.some(d => d.type === "error" || (config.failOnWarnings !== false && d.type === "warning"))`
|
|
118
|
+
* before treating the harness's verdict as production-faithful.
|
|
119
|
+
*/
|
|
120
|
+
readonly diagnostics: readonly SteeringDiagnostic[];
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Options for {@link loadHarness}.
|
|
124
|
+
*/
|
|
125
|
+
export interface LoadHarnessOptions {
|
|
126
|
+
/** The config under test. */
|
|
127
|
+
readonly config: SteeringConfig;
|
|
128
|
+
/**
|
|
129
|
+
* Prepend {@link DEFAULT_PLUGINS} to `config.plugins` and
|
|
130
|
+
* {@link DEFAULT_RULES} to `config.rules` at the innermost
|
|
131
|
+
* position. Mirrors the production flag via
|
|
132
|
+
* `!config.disableDefaults`, but kept explicit here so tests can
|
|
133
|
+
* exercise default rules without editing the config under test.
|
|
134
|
+
*
|
|
135
|
+
* Default: `false`.
|
|
136
|
+
*/
|
|
137
|
+
readonly includeDefaults?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Host to drive `exec` / `appendEntry` off. Defaults to an
|
|
140
|
+
* in-memory stub whose `exec` rejects with a clear error (tests
|
|
141
|
+
* needing exec must stub it explicitly) and whose `appendEntry`
|
|
142
|
+
* is a silent sink.
|
|
143
|
+
*/
|
|
144
|
+
readonly host?: EvaluatorHost;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Build an evaluator + observer dispatcher pair from a static
|
|
148
|
+
* {@link SteeringConfig}. Tests drive rules through the same pipeline
|
|
149
|
+
* production uses, without needing a pi runtime stub or walk-up
|
|
150
|
+
* loading.
|
|
151
|
+
*/
|
|
152
|
+
export declare function loadHarness(options: LoadHarnessOptions): Harness;
|
|
153
|
+
/**
|
|
154
|
+
* Shape of an entry fed into {@link mockContext} / {@link
|
|
155
|
+
* mockObserverContext} to back `findEntries`. Mirrors the subset of
|
|
156
|
+
* pi's `CustomEntry` the evaluator + dispatcher actually read.
|
|
157
|
+
*/
|
|
158
|
+
export interface MockEntry {
|
|
159
|
+
readonly type: "custom";
|
|
160
|
+
readonly customType: string;
|
|
161
|
+
readonly data: unknown;
|
|
162
|
+
readonly timestamp: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Options for {@link priorEntry}.
|
|
166
|
+
*/
|
|
167
|
+
export interface PriorEntryOptions {
|
|
168
|
+
/**
|
|
169
|
+
* Agent-loop index to stamp on the payload. The engine's live
|
|
170
|
+
* `appendEntry` wrapper stamps this automatically on every write;
|
|
171
|
+
* fixture entries must reproduce the same shape so `when.happened:
|
|
172
|
+
* { in: "agent_loop" }` scope filtering works identically whether
|
|
173
|
+
* the entry was written at runtime or seeded into the mock.
|
|
174
|
+
*
|
|
175
|
+
* Defaults to `0`. Set to the value of {@link MockContextOptions.agentLoopIndex}
|
|
176
|
+
* to place the entry in the current agent loop; set to a lower
|
|
177
|
+
* value (or 0 with `agentLoopIndex: 1+` on the context) to place
|
|
178
|
+
* it in a prior agent loop.
|
|
179
|
+
*/
|
|
180
|
+
readonly agentLoopIndex?: number;
|
|
181
|
+
/**
|
|
182
|
+
* ISO-8601 timestamp string. Defaults to `"2026-01-01T00:00:00.000Z"`.
|
|
183
|
+
* Use distinct, monotonically-increasing timestamps when seeding
|
|
184
|
+
* multiple entries the `since` invalidation sentinel needs to
|
|
185
|
+
* order.
|
|
186
|
+
*/
|
|
187
|
+
readonly timestamp?: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Build a {@link MockEntry} for {@link MockContextOptions.entries}
|
|
191
|
+
* (and the observer-context equivalent) with the reserved
|
|
192
|
+
* `_agentLoopIndex` tag stamped on the payload exactly as the live
|
|
193
|
+
* engine's `appendEntry` wrapper would.
|
|
194
|
+
*
|
|
195
|
+
* The reserved-key name is kept as an internal detail of the engine
|
|
196
|
+
* so plugin / fixture authors don't have to remember the underscore
|
|
197
|
+
* prefix. A typo on the `agentLoopIndex` field of {@link PriorEntryOptions}
|
|
198
|
+
* is a TypeScript compile error; the equivalent typo on a hand-rolled
|
|
199
|
+
* `data: { agentLoopIndex: 5 }` literal is silent — the entry passes
|
|
200
|
+
* through `findEntries` but then fails to match the current
|
|
201
|
+
* agent-loop scope, and the rule under test appears to misbehave.
|
|
202
|
+
*
|
|
203
|
+
* Payload shaping mirrors the live `createAppendEntry`:
|
|
204
|
+
* - Plain-object `data`: merged as `{ ...data, _agentLoopIndex }`.
|
|
205
|
+
* - Anything else (arrays, Date, Map, Set, Error, primitives,
|
|
206
|
+
* null, undefined): wrapped as `{ value: data, _agentLoopIndex }`.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* const ctx = mockContext({
|
|
210
|
+
* agentLoopIndex: 5,
|
|
211
|
+
* entries: [
|
|
212
|
+
* priorEntry("ws-sync-done", {}, { agentLoopIndex: 5 }),
|
|
213
|
+
* ],
|
|
214
|
+
* });
|
|
215
|
+
* // `when.happened: { event: "ws-sync-done", in: "agent_loop" }`
|
|
216
|
+
* // now sees the entry as "happened in the current loop".
|
|
217
|
+
*/
|
|
218
|
+
export declare function priorEntry(customType: string, data?: unknown, opts?: PriorEntryOptions): MockEntry;
|
|
219
|
+
/**
|
|
220
|
+
* Re-exported for plugin authors constructing `toolCallEvents`
|
|
221
|
+
* fixtures on {@link MockContextOptions}. Structurally `{ data,
|
|
222
|
+
* timestamp, speculative: true }` — the same shape the walker-level
|
|
223
|
+
* speculative-entry synthesis pass produces in production. Plugin
|
|
224
|
+
* predicates that filter out speculative entries check
|
|
225
|
+
* `entry.speculative === true`.
|
|
226
|
+
*/
|
|
227
|
+
export type { SyntheticEntry } from "../evaluator-internals/speculative-synthesis.ts";
|
|
228
|
+
/**
|
|
229
|
+
* Options for {@link mockContext}.
|
|
230
|
+
*/
|
|
231
|
+
export interface MockContextOptions {
|
|
232
|
+
/** Defaults to `"/tmp/test"`. */
|
|
233
|
+
readonly cwd?: string;
|
|
234
|
+
/** Engine agent-loop counter. Defaults to `0`. */
|
|
235
|
+
readonly agentLoopIndex?: number;
|
|
236
|
+
/**
|
|
237
|
+
* Which tool this predicate is evaluating under. Defaults to
|
|
238
|
+
* `"bash"`. Drives the default shape of {@link input} when the
|
|
239
|
+
* caller doesn't supply one.
|
|
240
|
+
*/
|
|
241
|
+
readonly tool?: "bash" | "write" | "edit";
|
|
242
|
+
/**
|
|
243
|
+
* Tool input. Omitted: derived from {@link tool} as the empty
|
|
244
|
+
* shape for that tool (bash: `{ command: "" }`, write:
|
|
245
|
+
* `{ path: "", content: "" }`, edit: `{ path: "", edits: [] }`).
|
|
246
|
+
*/
|
|
247
|
+
readonly input?: PredicateToolInput;
|
|
248
|
+
/**
|
|
249
|
+
* Walker-state snapshot the predicate sees via
|
|
250
|
+
* {@link PredicateContext.walkerState}.
|
|
251
|
+
*
|
|
252
|
+
* Defaults to `{ cwd: options.cwd, env: new Map() }` so the
|
|
253
|
+
* built-in `when.cwd` predicate and any plugin reading
|
|
254
|
+
* `walkerState.env` work without wiring up a full walker. Callers
|
|
255
|
+
* who want a specific env map or branch tracker state pass it in
|
|
256
|
+
* via this option.
|
|
257
|
+
*
|
|
258
|
+
* The typed shape is {@link WhenWalkerState} with every field
|
|
259
|
+
* optional (partial) so tests that only care about one dimension
|
|
260
|
+
* don't have to fill in the others. The engine's production path
|
|
261
|
+
* always populates `cwd` + `env`; the mock's default matches.
|
|
262
|
+
*
|
|
263
|
+
* Partial override: fields you pass merge over the defaults, so
|
|
264
|
+
* `mockContext({ walkerState: { cwd: "/x" } })` keeps the default
|
|
265
|
+
* empty env Map (same shape as production). Pass `env` explicitly
|
|
266
|
+
* only when you need a seeded map.
|
|
267
|
+
*/
|
|
268
|
+
readonly walkerState?: Partial<WhenWalkerState> & Record<string, unknown>;
|
|
269
|
+
/**
|
|
270
|
+
* Stub for `ctx.exec`. Defaults to rejecting with a clear error
|
|
271
|
+
* message — tests that call out to exec must stub explicitly
|
|
272
|
+
* (silent `undefined` would make predicate logic hard to reason
|
|
273
|
+
* about).
|
|
274
|
+
*/
|
|
275
|
+
readonly exec?: (cmd: string, args: readonly string[], opts?: ExecOpts) => ExecResult | Promise<ExecResult>;
|
|
276
|
+
/**
|
|
277
|
+
* Prior session entries `findEntries` reads from. Filtered by
|
|
278
|
+
* customType; timestamps parsed from the ISO string to epoch-ms,
|
|
279
|
+
* matching the production shape.
|
|
280
|
+
*
|
|
281
|
+
* For rules that use `when.happened: { in: "agent_loop" }` (or
|
|
282
|
+
* `in: "session"` with the same-loop filter), construct entries
|
|
283
|
+
* via {@link priorEntry} so the engine's reserved
|
|
284
|
+
* `_agentLoopIndex` tag is stamped correctly — hand-rolled
|
|
285
|
+
* literals with a typo (`agentLoopIndex` instead of the underscore
|
|
286
|
+
* form) silently fail to match the current agent-loop scope and
|
|
287
|
+
* the rule appears to misbehave.
|
|
288
|
+
*/
|
|
289
|
+
readonly entries?: ReadonlyArray<MockEntry>;
|
|
290
|
+
/**
|
|
291
|
+
* Per-ref speculative events the built-in `when.happened` predicate
|
|
292
|
+
* reads from `ctx.walkerState.events` (see
|
|
293
|
+
* {@link PredicateContext.walkerState}'s reserved `events` key).
|
|
294
|
+
* Keys are the `customType` event literals; values are the
|
|
295
|
+
* synthetic entries for that type. When provided, overwrites any
|
|
296
|
+
* `events` entry on the caller's {@link walkerState}.
|
|
297
|
+
*
|
|
298
|
+
* Use this to drive `when.happened` with `in: "tool_call"` (or any plugin
|
|
299
|
+
* predicate that introspects `walkerState.events`) in isolation
|
|
300
|
+
* without wiring up `loadHarness` + a full bash event. The shape
|
|
301
|
+
* matches what the walker-level synthesis pass produces in
|
|
302
|
+
* production — `{ data, timestamp, speculative: true }` per entry.
|
|
303
|
+
*/
|
|
304
|
+
readonly toolCallEvents?: Readonly<Record<string, readonly SyntheticEntry[]>>;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Build a {@link PredicateContext} for unit-testing predicates in
|
|
308
|
+
* isolation. See {@link MockContextOptions} for defaults. The returned
|
|
309
|
+
* context's `appendEntry` captures into a buffer accessible via
|
|
310
|
+
* {@link getAppendedEntries}.
|
|
311
|
+
*/
|
|
312
|
+
export declare function mockContext(options?: MockContextOptions): PredicateContext;
|
|
313
|
+
/**
|
|
314
|
+
* Options for {@link mockObserverContext}. Observers don't see
|
|
315
|
+
* `tool`, `input`, or `walkerState` — those are predicate-side
|
|
316
|
+
* concepts — so those fields are omitted here.
|
|
317
|
+
*/
|
|
318
|
+
export type MockObserverContextOptions = Omit<MockContextOptions, "tool" | "input" | "walkerState" | "toolCallEvents">;
|
|
319
|
+
/**
|
|
320
|
+
* Build an {@link ObserverContext} for unit-testing observer
|
|
321
|
+
* `onResult` handlers. Same capture + `findEntries` pattern as
|
|
322
|
+
* {@link mockContext}.
|
|
323
|
+
*
|
|
324
|
+
* Note: production `ObserverContext` does NOT expose `exec` — but the
|
|
325
|
+
* mock does (as an `exec`-like stub on a different property name is
|
|
326
|
+
* more confusing than forbidding it outright). Observer authors that
|
|
327
|
+
* reach for `exec` are probably using the wrong hook; rules / plugins
|
|
328
|
+
* carrying that logic belong in a predicate. The mock still accepts
|
|
329
|
+
* the stub so tests composing an observer + predicate through a shared
|
|
330
|
+
* options object don't have to strip the field.
|
|
331
|
+
*
|
|
332
|
+
* We DO NOT attach `exec` to the returned ObserverContext — the
|
|
333
|
+
* schema doesn't expose it. The stub is accepted but silently unused
|
|
334
|
+
* at this phase; the follow-up `testObserver` wrapper (Phase 5b) will
|
|
335
|
+
* surface a warning when the stub is set but can never fire.
|
|
336
|
+
*/
|
|
337
|
+
export declare function mockObserverContext(options?: MockObserverContextOptions): ObserverContext;
|
|
338
|
+
/**
|
|
339
|
+
* Shape of a session-entry produced by {@link createRecordingHost}'s
|
|
340
|
+
* `appendEntry`, readable by an {@link ExtensionContext} built from
|
|
341
|
+
* {@link mockExtensionContext}. Mirrors the subset of pi's
|
|
342
|
+
* `CustomEntry` the engine reads — `id` and `parentId` exist on real
|
|
343
|
+
* pi entries, so we populate them too to keep type-shape drift from
|
|
344
|
+
* masking silent divergence.
|
|
345
|
+
*/
|
|
346
|
+
export interface RecordedSessionEntry {
|
|
347
|
+
readonly type: "custom";
|
|
348
|
+
readonly customType: string;
|
|
349
|
+
readonly data: unknown;
|
|
350
|
+
readonly timestamp: string;
|
|
351
|
+
readonly id: string;
|
|
352
|
+
readonly parentId: string | null;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Exec-call record captured by {@link createRecordingHost}. One entry
|
|
356
|
+
* per invocation, in registration order. `args` is defensively copied
|
|
357
|
+
|
|
358
|
+
* so later mutation of the caller's argv array doesn't corrupt the
|
|
359
|
+
* record.
|
|
360
|
+
*/
|
|
361
|
+
export interface RecordedExecCall {
|
|
362
|
+
readonly cmd: string;
|
|
363
|
+
readonly args: readonly string[];
|
|
364
|
+
readonly cwd: string;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Options for {@link createRecordingHost}.
|
|
368
|
+
*/
|
|
369
|
+
export interface CreateRecordingHostOptions {
|
|
370
|
+
/**
|
|
371
|
+
* Stub for `host.exec`. Receives the normalized `cwd` (either the
|
|
372
|
+
* caller's `opts.cwd` or `"/"`). Defaults to resolving with an
|
|
373
|
+
* empty successful result — override when tests need to assert
|
|
374
|
+
* behavior against a specific stdout / exit code.
|
|
375
|
+
*/
|
|
376
|
+
readonly exec?: (cmd: string, args: readonly string[], cwd: string) => Promise<PiExecResult>;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Recording {@link EvaluatorHost}. Every `exec` and `appendEntry`
|
|
380
|
+
* call is captured into readable accumulators; `entries` mirrors the
|
|
381
|
+
* `appendEntry` writes in the shape pi's `sessionManager.getEntries()`
|
|
382
|
+
* returns, so feeding `host.entries` into {@link mockExtensionContext}
|
|
383
|
+
* makes the engine's writes visible to its subsequent reads in the
|
|
384
|
+
* same test.
|
|
385
|
+
*
|
|
386
|
+
* Note: `entries` and `execCalls` / `appendedEntries` are returned as
|
|
387
|
+
* mutable arrays so asserts can use `.some`, `.find`, etc. directly
|
|
388
|
+
* without a copy. They are owned by the host; don't splice or reassign
|
|
389
|
+
* them out from under it.
|
|
390
|
+
*/
|
|
391
|
+
export interface RecordingHost extends EvaluatorHost {
|
|
392
|
+
/**
|
|
393
|
+
* Session-entry log backing {@link mockExtensionContext}. Mutated
|
|
394
|
+
* in-place on every `appendEntry` call. Pass this array to
|
|
395
|
+
* `mockExtensionContext(cwd, host.entries)` so the host and the
|
|
396
|
+
* ctx share the same store.
|
|
397
|
+
*/
|
|
398
|
+
readonly entries: RecordedSessionEntry[];
|
|
399
|
+
/** Every `exec` invocation, in call order. */
|
|
400
|
+
readonly execCalls: RecordedExecCall[];
|
|
401
|
+
/**
|
|
402
|
+
* Every `appendEntry(type, data)` invocation, in call order. The
|
|
403
|
+
* `data` field is stored verbatim — NOT the auto-tagged shape the
|
|
404
|
+
* engine produces (that's reflected in {@link entries} instead).
|
|
405
|
+
* This buffer is the raw host-level log; use it for assertions that
|
|
406
|
+
* care about exactly which calls the engine made.
|
|
407
|
+
*/
|
|
408
|
+
readonly appendedEntries: Array<{
|
|
409
|
+
type: string;
|
|
410
|
+
data: unknown;
|
|
411
|
+
}>;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Build a {@link RecordingHost}. Every `exec` call is recorded, and
|
|
415
|
+
* every `appendEntry` call appends both to {@link RecordingHost.
|
|
416
|
+
* appendedEntries} (raw host-level log) and to {@link RecordingHost.
|
|
417
|
+
* entries} (session-entry shape used by {@link mockExtensionContext}).
|
|
418
|
+
*
|
|
419
|
+
* Timestamps on the session-entry log are monotonically-incrementing
|
|
420
|
+
* ISO strings starting at `2026-01-01T00:00:00Z` (+ 1s per entry) so
|
|
421
|
+
* chronological-order asserts stay stable across test runs without a
|
|
422
|
+
* live clock dependency. Override with a wrapping host if your test
|
|
423
|
+
* needs real timestamps.
|
|
424
|
+
*
|
|
425
|
+
* The default `exec` stub resolves with an empty successful result —
|
|
426
|
+
* safer than rejecting by default because most tests don't exercise
|
|
427
|
+
* exec at all and a loud reject would swamp the signal. Opt in to
|
|
428
|
+
* rejection via `options.exec` when a test must assert "exec was NOT
|
|
429
|
+
* called".
|
|
430
|
+
*/
|
|
431
|
+
export declare function createRecordingHost(options?: CreateRecordingHostOptions): RecordingHost;
|
|
432
|
+
/**
|
|
433
|
+
* Build a minimal {@link ExtensionContext} stub backed by a
|
|
434
|
+
* {@link RecordedSessionEntry} array. Used with {@link loadHarness}'s
|
|
435
|
+
* `harness.evaluate` / `harness.dispatch` when a test needs the engine
|
|
436
|
+
* to see entries a {@link RecordingHost} previously recorded.
|
|
437
|
+
*
|
|
438
|
+
* Only `cwd` and `sessionManager.getEntries()` are populated — the
|
|
439
|
+
* two fields the engine actually reads. Everything else on
|
|
440
|
+
* `ExtensionContext` throws on access (via an `unknown` cast) so an
|
|
441
|
+
* accidental reliance on unsupported surface surfaces as a clear
|
|
442
|
+
* `TypeError` rather than silently passing.
|
|
443
|
+
*
|
|
444
|
+
* Pass `host.entries` from {@link createRecordingHost} to share the
|
|
445
|
+
* backing store between the engine's writes and its subsequent reads.
|
|
446
|
+
*
|
|
447
|
+
* Choosing between this and {@link loadHarness} alone:
|
|
448
|
+
*
|
|
449
|
+
* - Use {@link loadHarness} + {@link expectBlocks}/{@link expectAllows}
|
|
450
|
+
* when the test only asserts block vs allow on a single event.
|
|
451
|
+
* - Use {@link createRecordingHost} + `mockExtensionContext` when the
|
|
452
|
+
* test drives a multi-call sequence, asserts on session-entry
|
|
453
|
+
* shape, or inspects exec calls.
|
|
454
|
+
*/
|
|
455
|
+
export declare function mockExtensionContext(cwd: string, entries?: ReadonlyArray<RecordedSessionEntry>): ExtensionContext;
|
|
456
|
+
/**
|
|
457
|
+
* Read the `appendEntry` capture buffer for a mock context.
|
|
458
|
+
*
|
|
459
|
+
* Returns an empty array when:
|
|
460
|
+
* - nothing has been appended yet, OR
|
|
461
|
+
* - the context wasn't built by {@link mockContext} /
|
|
462
|
+
* {@link mockObserverContext} (safe lookup — no throw).
|
|
463
|
+
*
|
|
464
|
+
* The returned array is a snapshot (copy) so callers can iterate
|
|
465
|
+
* without worrying about concurrent appends racing the assertion.
|
|
466
|
+
*/
|
|
467
|
+
export declare function getAppendedEntries(ctx: PredicateContext | ObserverContext): ReadonlyArray<{
|
|
468
|
+
customType: string;
|
|
469
|
+
data?: unknown;
|
|
470
|
+
}>;
|
|
471
|
+
/**
|
|
472
|
+
* Convenience shape for a bash tool-call event. Accepted by
|
|
473
|
+
* {@link expectBlocks}, {@link expectAllows}, {@link expectRuleFires},
|
|
474
|
+
* and {@link runMatrix} in place of a full {@link ToolCallEvent}.
|
|
475
|
+
*/
|
|
476
|
+
export interface BashShorthand {
|
|
477
|
+
readonly command: string;
|
|
478
|
+
readonly cwd?: string;
|
|
479
|
+
}
|
|
480
|
+
/** Convenience shape for a write tool-call event. */
|
|
481
|
+
export interface WriteShorthand {
|
|
482
|
+
readonly write: {
|
|
483
|
+
readonly path: string;
|
|
484
|
+
readonly content: string;
|
|
485
|
+
};
|
|
486
|
+
readonly cwd?: string;
|
|
487
|
+
}
|
|
488
|
+
/** Convenience shape for an edit tool-call event. */
|
|
489
|
+
export interface EditShorthand {
|
|
490
|
+
readonly edit: {
|
|
491
|
+
readonly path: string;
|
|
492
|
+
readonly edits: ReadonlyArray<{
|
|
493
|
+
readonly oldText: string;
|
|
494
|
+
readonly newText: string;
|
|
495
|
+
}>;
|
|
496
|
+
};
|
|
497
|
+
readonly cwd?: string;
|
|
498
|
+
}
|
|
499
|
+
/** Union of the bash/write/edit shorthands. */
|
|
500
|
+
export type ToolCallShorthand = BashShorthand | WriteShorthand | EditShorthand;
|
|
501
|
+
/**
|
|
502
|
+
* Convenience shape for a tool-result event, accepted by
|
|
503
|
+
* {@link testObserver}. Mirrors the minimal {@link SchemaToolResultEvent}
|
|
504
|
+
* fields observers actually read.
|
|
505
|
+
*/
|
|
506
|
+
export interface ToolResultShorthand {
|
|
507
|
+
readonly toolName: string;
|
|
508
|
+
readonly input?: unknown;
|
|
509
|
+
readonly output?: unknown;
|
|
510
|
+
readonly exitCode?: number;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Drive a single {@link PredicateHandler} against a {@link mockContext}.
|
|
514
|
+
* Returns the boolean verdict.
|
|
515
|
+
*
|
|
516
|
+
* Usage:
|
|
517
|
+
* ```ts
|
|
518
|
+
* const fires = await testPredicate(branch, /^main$/, {
|
|
519
|
+
* walkerState: { branch: "main" },
|
|
520
|
+
* });
|
|
521
|
+
* ```
|
|
522
|
+
*
|
|
523
|
+
* Chain-aware predicates (e.g. the built-in `happened` with its
|
|
524
|
+
* `&&`-chain speculative allow) read per-ref synthetic events from
|
|
525
|
+
* `ctx.walkerState.events`. Populate `toolCallEvents` (or set
|
|
526
|
+
* `walkerState` directly) in {@link MockContextOptions} to simulate
|
|
527
|
+
* that surface in isolation without wiring up `loadHarness` + a
|
|
528
|
+
* full bash event.
|
|
529
|
+
*/
|
|
530
|
+
export declare function testPredicate<A = unknown>(predicate: PredicateHandler<A>, args: A, options?: MockContextOptions): Promise<PredicateVerdict>;
|
|
531
|
+
/**
|
|
532
|
+
* Fire an {@link Observer} at an event, returning the captured
|
|
533
|
+
* `appendEntry` writes plus whether the observer's `watch` filter
|
|
534
|
+
* accepted the event. Use the `entries` field to assert what the
|
|
535
|
+
* observer recorded; use `watchMatched` to assert the filter gated
|
|
536
|
+
* firing correctly.
|
|
537
|
+
*
|
|
538
|
+
* If the observer's `watch` did NOT match, `onResult` is NOT called
|
|
539
|
+
* (mirrors production dispatch).
|
|
540
|
+
*
|
|
541
|
+
* If `options.exec` is supplied, emits a `console.warn` — observers
|
|
542
|
+
* don't see `exec`, so the stub can never fire. Exists on the options
|
|
543
|
+
* shape only because {@link MockObserverContextOptions} is derived
|
|
544
|
+
* from {@link MockContextOptions} for ergonomic test composition.
|
|
545
|
+
*/
|
|
546
|
+
export declare function testObserver(observer: Observer, event: SchemaToolResultEvent | ToolResultShorthand, options?: MockObserverContextOptions): Promise<{
|
|
547
|
+
entries: ReadonlyArray<{
|
|
548
|
+
customType: string;
|
|
549
|
+
data?: unknown;
|
|
550
|
+
}>;
|
|
551
|
+
watchMatched: boolean;
|
|
552
|
+
}>;
|
|
553
|
+
/** Options for {@link expectBlocks}. */
|
|
554
|
+
export interface ExpectBlocksOptions {
|
|
555
|
+
/**
|
|
556
|
+
* Expected rule name — matched against the `[steering:<name>@<source>]`
|
|
557
|
+
* prefix (source-tagged format per ADR §11). The source suffix is
|
|
558
|
+
* ignored for matching; pass the bare rule name.
|
|
559
|
+
*/
|
|
560
|
+
readonly rule?: string;
|
|
561
|
+
/** Expected reason — exact string match (string) or pattern match (RegExp). */
|
|
562
|
+
readonly reason?: string | RegExp;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Assert that the harness blocks the given event. Returns the block
|
|
566
|
+
* payload for further inspection. Throws on allow.
|
|
567
|
+
*
|
|
568
|
+
* Optional `expected.rule` / `expected.reason` narrow the assertion:
|
|
569
|
+
* - `rule: "no-force-push"` — the fired rule's name must match.
|
|
570
|
+
* - `reason: /force-push/` — the reason string must match (exact
|
|
571
|
+
* string or regex).
|
|
572
|
+
*/
|
|
573
|
+
export declare function expectBlocks(harness: Harness, event: ToolCallEvent | ToolCallShorthand, expected?: ExpectBlocksOptions): Promise<ToolCallEventResult>;
|
|
574
|
+
/**
|
|
575
|
+
* Assert that the harness allows the given event (no rule fires).
|
|
576
|
+
* Throws with a rich message on block.
|
|
577
|
+
*/
|
|
578
|
+
export declare function expectAllows(harness: Harness, event: ToolCallEvent | ToolCallShorthand): Promise<void>;
|
|
579
|
+
/**
|
|
580
|
+
* Assert that a specific rule fires on the given event. Thin alias
|
|
581
|
+
* over {@link expectBlocks}; kept as a distinct helper for tests whose
|
|
582
|
+
* intent is "which rule fired" rather than "the tool was blocked".
|
|
583
|
+
*/
|
|
584
|
+
export declare function expectRuleFires(harness: Harness, event: ToolCallEvent | ToolCallShorthand, ruleName: string): Promise<void>;
|
|
585
|
+
/** One row of a {@link runMatrix} input. */
|
|
586
|
+
export interface MatrixCase {
|
|
587
|
+
readonly name: string;
|
|
588
|
+
readonly event: ToolCallEvent | ToolCallShorthand;
|
|
589
|
+
readonly expect: "block" | "allow" | {
|
|
590
|
+
readonly block: true;
|
|
591
|
+
readonly rule?: string;
|
|
592
|
+
};
|
|
593
|
+
readonly cwd?: string;
|
|
594
|
+
}
|
|
595
|
+
/** Per-case outcome. */
|
|
596
|
+
export interface MatrixCaseResult {
|
|
597
|
+
readonly case: MatrixCase;
|
|
598
|
+
readonly passed: boolean;
|
|
599
|
+
readonly actual: "block" | "allow";
|
|
600
|
+
readonly reason?: string;
|
|
601
|
+
readonly errorMessage?: string;
|
|
602
|
+
}
|
|
603
|
+
/** Aggregate outcome of {@link runMatrix}. */
|
|
604
|
+
export interface MatrixResult {
|
|
605
|
+
readonly total: number;
|
|
606
|
+
readonly passed: number;
|
|
607
|
+
readonly failed: number;
|
|
608
|
+
readonly cases: ReadonlyArray<MatrixCaseResult>;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Batch-evaluate a list of cases against a harness. Never throws —
|
|
612
|
+
* failures surface in `result.cases`. Pair with {@link formatMatrix}
|
|
613
|
+
* to render a human-readable report.
|
|
614
|
+
*/
|
|
615
|
+
export declare function runMatrix(harness: Harness, cases: readonly MatrixCase[]): Promise<MatrixResult>;
|
|
616
|
+
/**
|
|
617
|
+
* Pretty-print a {@link MatrixResult}. ASCII-friendly for CI log
|
|
618
|
+
* aggregators; structure mirrors the adversarial-matrix report style.
|
|
619
|
+
*/
|
|
620
|
+
export declare function formatMatrix(result: MatrixResult): string;
|
|
621
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,UAAU,IAAI,YAAY,EAC1B,aAAa,EACb,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AAGtF,OAAO,EAGL,KAAK,kBAAkB,EAC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