wicked-crew-api-types 0.30.0 → 0.31.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.
Files changed (2) hide show
  1. package/index.d.ts +151 -1
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -802,7 +802,51 @@ export interface DataUsedEvent {
802
802
  files: string[];
803
803
  }
804
804
 
805
- /** §3 B1 — the gate's decision depth, emitted alongside `gateDecided`. */
805
+ /**
806
+ * The layer that denied a unit — a stable token (wicked-core `UnitDenial.source`):
807
+ * - `governance` — the unit's own gate; `input_governance` — the tool-call hook / boundary;
808
+ * - `pinned_validator` — the deterministic re-verify; `agent_validator` — the LLM judge;
809
+ * `evaluator` — the evaluator≠creator second pass;
810
+ * - `worker_failure` — the CLI process failed; `substance` — no reviewable substance;
811
+ * `deliverables` — declared deliverables missing; `elicitation` — ACP elicitation ended;
812
+ * - `worktree_guard` — a def-driven, agent-executed `executes_code: false` phase changed the
813
+ * worktree it was reviewing (wicked-core F-036, see {@link EvaluatorMutatedWorktreeEvent}) — or
814
+ * the guard could not re-verify it (no baseline persisted at dispatch, comparison unverifiable),
815
+ * which denies fail-closed WITHOUT that event; `reason` names the cause;
816
+ * - `repo_checks` — the repository's own checks failed in the worktree (wicked-core F-039, see
817
+ * {@link RepoChecksEvaluatedEvent}).
818
+ * Open-ended (`string & {}`) so a newer engine's source parses in an older studio.
819
+ */
820
+ export type UnitDenialSource =
821
+ | 'governance'
822
+ | 'input_governance'
823
+ | 'pinned_validator'
824
+ | 'agent_validator'
825
+ | 'evaluator'
826
+ | 'worker_failure'
827
+ | 'substance'
828
+ | 'deliverables'
829
+ | 'elicitation'
830
+ | 'worktree_guard'
831
+ | 'repo_checks'
832
+ | (string & {});
833
+
834
+ /** The MACHINE-READABLE twin of `gateEvaluated.denialReason` (wicked-core `UnitDenial`, camelCase on
835
+ * the wire): which layer denied, the prose reason, and — when the layer recorded them — the
836
+ * conformance claim id, the firing rule ids, the refused tool and the unit-phase token. `null`
837
+ * fields are the engine's `Option::None`, never absent. */
838
+ export interface UnitDenial {
839
+ source: UnitDenialSource;
840
+ reason: string;
841
+ claimId: string | null;
842
+ ruleIds: string[];
843
+ deniedTool: string | null;
844
+ phase: string | null;
845
+ }
846
+
847
+ /** §3 B1 — the gate's decision depth, emitted alongside `gateDecided`. `denial` is the structured
848
+ * twin of `denialReason`: `null` when the gate approved, else the winning layer (deny-dominates) —
849
+ * `worktree_guard` and `repo_checks` are the two wicked-core F-036/F-039 layers. */
806
850
  export interface GateEvaluatedEvent {
807
851
  type: 'gateEvaluated';
808
852
  session: string;
@@ -813,7 +857,10 @@ export interface GateEvaluatedEvent {
813
857
  agentVerdict: string | null;
814
858
  agentReasoning: string | null;
815
859
  evaluatorPass: boolean | null;
860
+ /** Policy ids the evaluator≠creator pass applied (empty = vacuous default-allow, FINDING-025). */
861
+ evaluatorPolicies: string[];
816
862
  denialReason: string | null;
863
+ denial: UnitDenial | null;
817
864
  combined: boolean;
818
865
  }
819
866
 
@@ -979,6 +1026,109 @@ export interface GovernanceUnenforcedEvent {
979
1026
  reason: string;
980
1027
  }
981
1028
 
1029
+ /** One path an `executes_code: false` phase changed, with git's one-letter status
1030
+ * (`A`dded, `M`odified, `D`eleted, `T`ype-changed). */
1031
+ export interface WorktreeChangedPath {
1032
+ status: string;
1033
+ path: string;
1034
+ }
1035
+
1036
+ /** wicked-core F-036 — an `executes_code: false` phase (an evaluator, a recon rung, a review) CHANGED
1037
+ * the worktree it was working in. Scope: the guard governs a DEF-DRIVEN, AGENT-executed
1038
+ * `executes_code: false` phase (`WorkUnit.worktree_guarded`, derived at plan time); Tool phases —
1039
+ * crew's `deliver-pr` included — and prose-planned runs are not guarded. The engine snapshots the
1040
+ * tree at dispatch and takes the FINAL snapshot after everything the phase owned has run (seat
1041
+ * quiesced — its process group killed, a persistent session closed — judge rendered, repo checks
1042
+ * done), for EVERY seat and carrier regardless of governance adapter. `changed` is EVERY path that
1043
+ * differs, and every one DENIES the unit (its `gateEvaluated.denial.source` is `worktree_guard`):
1044
+ * there are NO exemptions — not documentation, not a declared `required_deliverables` entry, not
1045
+ * tool state (a phase whose deliverable must live in the tree is a code phase; the engine's own
1046
+ * `tmp/` scratch is excluded from the snapshot by construction). `headMoved`: the run branch was
1047
+ * committed/amended/reset. The event is emitted exactly when a MUTATION denies the unit (`changed`
1048
+ * non-empty and/or `headMoved`), so an operator always sees what an evaluator wrote. A
1049
+ * `worktree_guard` denial can also come from the guard's fail-closed paths — no baseline persisted
1050
+ * at dispatch, or the comparison unverifiable — and those carry NO `evaluatorMutatedWorktree`
1051
+ * event: the gate's `denial.reason` names the cause. Evaluator ≠ creator is no longer a promise the
1052
+ * seat keeps; it is a check.
1053
+ *
1054
+ * `type` alias on purpose, not `interface`: only anonymous object types satisfy `CoreEvent`'s index
1055
+ * signature, which is what lets the frame flow through CoreEvent-typed broadcast seams. */
1056
+ export type EvaluatorMutatedWorktreeEvent = {
1057
+ type: 'evaluatorMutatedWorktree';
1058
+ session: string;
1059
+ ord: number;
1060
+ attempt: number;
1061
+ /** The seat that ran the unit (`assigned_cli`; `''` when unassigned). */
1062
+ cli: string;
1063
+ /** The workflow phase id (`verify`, `adversarial-review`, …). */
1064
+ phase: string;
1065
+ beforeTree: string;
1066
+ afterTree: string;
1067
+ headMoved: boolean;
1068
+ changed: WorktreeChangedPath[];
1069
+ };
1070
+
1071
+ /** One repository check the engine ran in the run's worktree (wicked-core F-039). */
1072
+ export interface RepoCheckRun {
1073
+ /** `install` | `typecheck` | `lint` | `test` | `cargo-test`. */
1074
+ name: string;
1075
+ argv: string[];
1076
+ /** Provenance an operator can verify: `package.json scripts.test`, `Cargo.toml`, … */
1077
+ source: string;
1078
+ /** The process exit code; `null` when it produced none (timed out / could not spawn). */
1079
+ exitCode: number | null;
1080
+ timedOut: boolean;
1081
+ /** The OS error when the command could not be started (binary not on PATH, …); `null` otherwise
1082
+ * — the key is always present on the wire. */
1083
+ spawnError: string | null;
1084
+ durationMs: number;
1085
+ /** The last 4 KiB of each stream — the evidence, verbatim. */
1086
+ stdoutTail: string;
1087
+ stderrTail: string;
1088
+ }
1089
+
1090
+ /** wicked-core F-039 — the engine ran the repository's OWN checks in the worktree for the def's
1091
+ * code-verifying unit (`verified_evidence` with an `executes_code` creator upstream: `bug/verify`,
1092
+ * `feature/test`, `migration/verify`) and folded them into the gate as a deterministic floor. Fires
1093
+ * once per fold, just before `gateEvaluated` (whose `hasDeterministicFloor`/`criterion` include this
1094
+ * floor). `checks` is what actually ran, in order (`package.json` `typecheck`/`lint`/`test` via the
1095
+ * lockfile's package manager, an `install` first when `node_modules/` is absent; `Cargo.toml` →
1096
+ * `cargo test`); `skipped` names detected checks not run because an earlier one failed. `passed:
1097
+ * false` ⇒ the unit is denied (`denial.source` is `repo_checks`).
1098
+ *
1099
+ * The checks are repo-controlled code and run ONLY inside an OS write boundary (macOS
1100
+ * `sandbox-exec` / Linux `bwrap`: writes confined to the worktree, the curated secret directories
1101
+ * unreadable, network open for installs) with an isolated `HOME`, `npm_config_cache`, `CARGO_HOME`,
1102
+ * `CARGO_TARGET_DIR` and `XDG_*` under `<worktree>/tmp/wicked-checks/`, and with a MINIMAL
1103
+ * environment — the daemon's env is cleared and only `PATH`, locale (`LANG`/`LC_*`), `TERM`,
1104
+ * `USER`/`LOGNAME`, `RUSTUP_HOME`, the Windows shell essentials and those isolation overrides
1105
+ * (`CI=1` included) reach a check: no token, API key or `WICKED_*` variable does; installs are always
1106
+ * `--ignore-scripts` (`--no-package-lock` when the repo ships no lockfile). When NO boundary can be
1107
+ * armed (no sandbox tool on the host — Windows) the checks do NOT run and the floor FAILS
1108
+ * (`passed: false`, `checks: []`, the reason on the unit record) — repo-controlled scripts never
1109
+ * run unsandboxed. Detection is fail-closed the same way: a `package.json` that cannot be read or
1110
+ * parsed, or a symlinked manifest/lockfile/`node_modules` (every probe `lstat`s, opens `O_NOFOLLOW`
1111
+ * and `fstat`s the opened descriptor before reading — links are never followed), FAILS the floor.
1112
+ * Only a repo with NO DETECTABLE check is the disclosed vacuous pass (`checks: []`, `passed:
1113
+ * true`): no manifest at all, or a readable `package.json` with no string `typecheck`/`lint`/`test`
1114
+ * script and no `Cargo.toml`. A manifest that cannot be read or trusted still FAILS.
1115
+ * "Done" for a verify phase is now the exit code the engine observed, not the seat's account of
1116
+ * having run the suite. `type` alias on purpose — see {@link EvaluatorMutatedWorktreeEvent}. */
1117
+ export type RepoChecksEvaluatedEvent = {
1118
+ type: 'repoChecksEvaluated';
1119
+ session: string;
1120
+ ord: number;
1121
+ attempt: number;
1122
+ passed: boolean;
1123
+ criterion: string;
1124
+ checks: RepoCheckRun[];
1125
+ skipped: string[];
1126
+ };
1127
+
1128
+ /** The gate-evidence events (wicked-core F-036/F-039) as a discriminated union for consumers that
1129
+ * narrow on `type`; they also flow through the permissive {@link CoreEvent}. */
1130
+ export type GateEvidenceEvent = EvaluatorMutatedWorktreeEvent | RepoChecksEvaluatedEvent;
1131
+
982
1132
  // ── P2 decisions-full observability events (wicked-core EVT-001/012/013) ────
983
1133
 
984
1134
  /** P2 — a structured workflow def was selected; fires once per session, after SessionStarted and before
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wicked-crew-api-types",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "The wire contract of the wicked-crew daemon's /api/v1 REST surface and /ws CoreEvent frames \u2014 types only, zero runtime",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",