wicked-crew 0.18.21 → 0.18.23
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/dist/api/audit-view.d.ts.map +1 -1
- package/dist/api/audit-view.js +1 -0
- package/dist/api/audit-view.js.map +1 -1
- package/dist/api/audit.d.ts +28 -1
- package/dist/api/audit.d.ts.map +1 -1
- package/dist/api/audit.js +90 -9
- package/dist/api/audit.js.map +1 -1
- package/dist/api/auth.d.ts +7 -0
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +53 -10
- package/dist/api/auth.js.map +1 -1
- package/dist/api/capture.d.ts +11 -2
- package/dist/api/capture.d.ts.map +1 -1
- package/dist/api/capture.js +7 -2
- package/dist/api/capture.js.map +1 -1
- package/dist/api/chat-context.d.ts +6 -1
- package/dist/api/chat-context.d.ts.map +1 -1
- package/dist/api/chat-context.js +45 -11
- package/dist/api/chat-context.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +24 -7
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +98 -18
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-scope.d.ts +6 -2
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +13 -7
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/cluster-status.d.ts +17 -0
- package/dist/api/cluster-status.d.ts.map +1 -1
- package/dist/api/cluster-status.js +70 -3
- package/dist/api/cluster-status.js.map +1 -1
- package/dist/api/compose-facts.d.ts +35 -0
- package/dist/api/compose-facts.d.ts.map +1 -0
- package/dist/api/compose-facts.js +46 -0
- package/dist/api/compose-facts.js.map +1 -0
- package/dist/api/cut-read.d.ts +62 -0
- package/dist/api/cut-read.d.ts.map +1 -0
- package/dist/api/cut-read.js +101 -0
- package/dist/api/cut-read.js.map +1 -0
- package/dist/api/desk-snoozes.d.ts +77 -0
- package/dist/api/desk-snoozes.d.ts.map +1 -0
- package/dist/api/desk-snoozes.js +220 -0
- package/dist/api/desk-snoozes.js.map +1 -0
- package/dist/api/diagnostics.d.ts +4 -0
- package/dist/api/diagnostics.d.ts.map +1 -1
- package/dist/api/diagnostics.js +15 -7
- package/dist/api/diagnostics.js.map +1 -1
- package/dist/api/disk-stores.d.ts +66 -0
- package/dist/api/disk-stores.d.ts.map +1 -0
- package/dist/api/disk-stores.js +206 -0
- package/dist/api/disk-stores.js.map +1 -0
- package/dist/api/domain-model.d.ts +56 -0
- package/dist/api/domain-model.d.ts.map +1 -0
- package/dist/api/domain-model.js +281 -0
- package/dist/api/domain-model.js.map +1 -0
- package/dist/api/domain-scope.d.ts +52 -0
- package/dist/api/domain-scope.d.ts.map +1 -0
- package/dist/api/domain-scope.js +156 -0
- package/dist/api/domain-scope.js.map +1 -0
- package/dist/api/eval-rule-store.d.ts +32 -0
- package/dist/api/eval-rule-store.d.ts.map +1 -0
- package/dist/api/eval-rule-store.js +77 -0
- package/dist/api/eval-rule-store.js.map +1 -0
- package/dist/api/gate-cache.d.ts +8 -0
- package/dist/api/gate-cache.d.ts.map +1 -1
- package/dist/api/gate-cache.js +8 -1
- package/dist/api/gate-cache.js.map +1 -1
- package/dist/api/mcp.d.ts +19 -0
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +166 -3
- package/dist/api/mcp.js.map +1 -1
- package/dist/api/needs.d.ts +3 -0
- package/dist/api/needs.d.ts.map +1 -1
- package/dist/api/needs.js +7 -3
- package/dist/api/needs.js.map +1 -1
- package/dist/api/post-hoc-deliver.d.ts +7 -0
- package/dist/api/post-hoc-deliver.d.ts.map +1 -1
- package/dist/api/post-hoc-deliver.js +16 -5
- package/dist/api/post-hoc-deliver.js.map +1 -1
- package/dist/api/product-publish.d.ts +242 -0
- package/dist/api/product-publish.d.ts.map +1 -0
- package/dist/api/product-publish.js +902 -0
- package/dist/api/product-publish.js.map +1 -0
- package/dist/api/product.d.ts +5 -6
- package/dist/api/product.d.ts.map +1 -1
- package/dist/api/product.js +4 -4
- package/dist/api/product.js.map +1 -1
- package/dist/api/proposal-cut.d.ts +95 -0
- package/dist/api/proposal-cut.d.ts.map +1 -0
- package/dist/api/proposal-cut.js +231 -0
- package/dist/api/proposal-cut.js.map +1 -0
- package/dist/api/requirements.d.ts +6 -4
- package/dist/api/requirements.d.ts.map +1 -1
- package/dist/api/requirements.js +6 -3
- package/dist/api/requirements.js.map +1 -1
- package/dist/api/routes.d.ts +21 -0
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +578 -94
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-liveness.d.ts.map +1 -1
- package/dist/api/run-liveness.js +3 -1
- package/dist/api/run-liveness.js.map +1 -1
- package/dist/api/run-timing-index.d.ts +10 -0
- package/dist/api/run-timing-index.d.ts.map +1 -1
- package/dist/api/run-timing-index.js +29 -9
- package/dist/api/run-timing-index.js.map +1 -1
- package/dist/api/seat-container-login.d.ts +11 -17
- package/dist/api/seat-container-login.d.ts.map +1 -1
- package/dist/api/seat-container-login.js +36 -69
- package/dist/api/seat-container-login.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +1 -0
- package/dist/api/server.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +5 -2
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +18 -6
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/testing.d.ts.map +1 -1
- package/dist/api/testing.js +11 -8
- package/dist/api/testing.js.map +1 -1
- package/dist/api/ui-text.d.ts.map +1 -1
- package/dist/api/ui-text.js +3 -1
- package/dist/api/ui-text.js.map +1 -1
- package/dist/apps/actions/write-path.d.ts +6 -2
- package/dist/apps/actions/write-path.d.ts.map +1 -1
- package/dist/apps/actions/write-path.js +7 -3
- package/dist/apps/actions/write-path.js.map +1 -1
- package/dist/apps/store.d.ts +11 -0
- package/dist/apps/store.d.ts.map +1 -1
- package/dist/apps/store.js +47 -0
- package/dist/apps/store.js.map +1 -1
- package/dist/apps-server/server/lib/bundle/server.mjs +19 -5
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +38 -52
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp.d.ts +14 -0
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +27 -10
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/start-stand-ins.d.ts +13 -0
- package/dist/cli/start-stand-ins.d.ts.map +1 -0
- package/dist/cli/start-stand-ins.js +30 -0
- package/dist/cli/start-stand-ins.js.map +1 -0
- package/dist/core/adapter.d.ts +57 -6
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +208 -30
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/ado-env.d.ts +17 -0
- package/dist/core/ado-env.d.ts.map +1 -0
- package/dist/core/ado-env.js +34 -0
- package/dist/core/ado-env.js.map +1 -0
- package/dist/core/deliver-text.d.ts +17 -0
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +76 -1
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts +6 -0
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +12 -4
- package/dist/core/deliver.js.map +1 -1
- package/dist/core/exec.d.ts +1 -10
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +4 -17
- package/dist/core/exec.js.map +1 -1
- package/dist/core/governance-store.d.ts +3 -1
- package/dist/core/governance-store.d.ts.map +1 -1
- package/dist/core/governance-store.js +7 -2
- package/dist/core/governance-store.js.map +1 -1
- package/dist/core/launch-posture.d.ts +3 -0
- package/dist/core/launch-posture.d.ts.map +1 -1
- package/dist/core/launch-posture.js +4 -0
- package/dist/core/launch-posture.js.map +1 -1
- package/dist/core/repo-clone.d.ts.map +1 -1
- package/dist/core/repo-clone.js +2 -1
- package/dist/core/repo-clone.js.map +1 -1
- package/dist/core/run-log-facts.d.ts +56 -0
- package/dist/core/run-log-facts.d.ts.map +1 -0
- package/dist/core/run-log-facts.js +230 -0
- package/dist/core/run-log-facts.js.map +1 -0
- package/dist/core/shutdown.d.ts +27 -0
- package/dist/core/shutdown.d.ts.map +1 -1
- package/dist/core/shutdown.js +72 -0
- package/dist/core/shutdown.js.map +1 -1
- package/dist/core/stand-in.d.ts +62 -0
- package/dist/core/stand-in.d.ts.map +1 -0
- package/dist/core/stand-in.js +153 -0
- package/dist/core/stand-in.js.map +1 -0
- package/dist/core/types.d.ts +22 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/editors/pack-extras.d.ts +162 -0
- package/dist/editors/pack-extras.d.ts.map +1 -0
- package/dist/editors/pack-extras.js +596 -0
- package/dist/editors/pack-extras.js.map +1 -0
- package/dist/editors/pack-install.d.ts +15 -7
- package/dist/editors/pack-install.d.ts.map +1 -1
- package/dist/editors/pack-install.js +140 -19
- package/dist/editors/pack-install.js.map +1 -1
- package/dist/editors/registry.d.ts +42 -3
- package/dist/editors/registry.d.ts.map +1 -1
- package/dist/editors/registry.js +114 -11
- package/dist/editors/registry.js.map +1 -1
- package/dist/editors/routes.d.ts +10 -5
- package/dist/editors/routes.d.ts.map +1 -1
- package/dist/editors/routes.js +45 -11
- package/dist/editors/routes.js.map +1 -1
- package/dist/interactive/bridge-pool.d.ts +5 -2
- package/dist/interactive/bridge-pool.d.ts.map +1 -1
- package/dist/interactive/bridge-pool.js +4 -1
- package/dist/interactive/bridge-pool.js.map +1 -1
- package/dist/interactive/landing-guard.d.ts.map +1 -1
- package/dist/interactive/landing-guard.js +79 -5
- package/dist/interactive/landing-guard.js.map +1 -1
- package/dist/knowledge/adapters/toolbox/memory.d.ts.map +1 -1
- package/dist/knowledge/adapters/toolbox/memory.js +3 -2
- package/dist/knowledge/adapters/toolbox/memory.js.map +1 -1
- package/dist/knowledge/trackers/set.d.ts +28 -0
- package/dist/knowledge/trackers/set.d.ts.map +1 -1
- package/dist/knowledge/trackers/set.js +26 -0
- package/dist/knowledge/trackers/set.js.map +1 -1
- package/dist/mcp/policies.d.ts +44 -0
- package/dist/mcp/policies.d.ts.map +1 -1
- package/dist/mcp/policies.js +153 -1
- package/dist/mcp/policies.js.map +1 -1
- package/dist/mcp/registry-store.d.ts +10 -0
- package/dist/mcp/registry-store.d.ts.map +1 -1
- package/dist/mcp/registry-store.js.map +1 -1
- package/dist/mcp/registry.d.ts +43 -3
- package/dist/mcp/registry.d.ts.map +1 -1
- package/dist/mcp/registry.js +224 -16
- package/dist/mcp/registry.js.map +1 -1
- package/dist/mcp/trigger-names.d.ts +32 -0
- package/dist/mcp/trigger-names.d.ts.map +1 -0
- package/dist/mcp/trigger-names.js +529 -0
- package/dist/mcp/trigger-names.js.map +1 -0
- package/dist/persona/routes.d.ts +1 -1
- package/dist/persona/store.d.ts +1 -1
- package/dist/schedules/routes.d.ts.map +1 -1
- package/dist/schedules/routes.js +6 -0
- package/dist/schedules/routes.js.map +1 -1
- package/dist/skills/store.d.ts +11 -1
- package/dist/skills/store.d.ts.map +1 -1
- package/dist/skills/store.js +37 -3
- package/dist/skills/store.js.map +1 -1
- package/dist/sources/routes.d.ts +2 -2
- package/dist/sources/routes.d.ts.map +1 -1
- package/dist/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/assets/{KnowledgeGraph-yP4WsnST.js → KnowledgeGraph-BrHcKpFT.js} +1 -1
- package/dist/studio/assets/index-BCVvMebl.css +32 -0
- package/dist/studio/assets/{index-DW53FKuT.js → index-BqB2Ydq-.js} +337 -311
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +1 -1
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +1 -1
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +1 -1
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +953 -107
- package/dist/team/routes.d.ts +4 -1
- package/dist/team/routes.d.ts.map +1 -1
- package/dist/team/routes.js +1 -1
- package/dist/team/routes.js.map +1 -1
- package/dist/voice/tts.d.ts +6 -0
- package/dist/voice/tts.d.ts.map +1 -1
- package/dist/voice/tts.js +16 -1
- package/dist/voice/tts.js.map +1 -1
- package/endpoint-manifest.json +100 -6
- package/package.json +4 -4
- package/voice-locks/darwin-arm64-cp310.txt +12 -0
- package/voice-locks/darwin-arm64-cp311.txt +8 -0
- package/voice-locks/darwin-arm64-cp312.txt +8 -0
- package/voice-locks/darwin-arm64-cp313.txt +8 -0
- package/voice-locks/darwin-arm64-cp314.txt +8 -0
- package/voice-locks/darwin-arm64-cp39.txt +12 -0
- package/voice-locks/darwin-x64-cp310.txt +12 -0
- package/voice-locks/darwin-x64-cp311.txt +12 -0
- package/voice-locks/darwin-x64-cp312.txt +12 -0
- package/voice-locks/darwin-x64-cp313.txt +12 -0
- package/voice-locks/darwin-x64-cp39.txt +12 -0
- package/voice-locks/linux-arm64-cp310.txt +12 -0
- package/voice-locks/linux-arm64-cp311.txt +8 -0
- package/voice-locks/linux-arm64-cp312.txt +8 -0
- package/voice-locks/linux-arm64-cp313.txt +8 -0
- package/voice-locks/linux-arm64-cp314.txt +8 -0
- package/voice-locks/linux-arm64-cp39.txt +12 -0
- package/voice-locks/linux-x64-cp310.txt +12 -0
- package/voice-locks/linux-x64-cp311.txt +8 -0
- package/voice-locks/linux-x64-cp312.txt +8 -0
- package/voice-locks/linux-x64-cp313.txt +8 -0
- package/voice-locks/linux-x64-cp314.txt +8 -0
- package/voice-locks/linux-x64-cp39.txt +12 -0
- package/dist/studio/assets/index-DNaLjJ7M.css +0 -32
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { RecordedEvent } from './types.js';
|
|
2
|
+
/** The engine's terminal frames (the same set `RunTimingIndex` dates a run from). */
|
|
3
|
+
export declare const TERMINAL_EVENTS: ReadonlySet<string>;
|
|
4
|
+
/** What one read of a run's log answers. `launched`: string | null (free text) when the log holds a `sessionStarted`,
|
|
5
|
+
* `undefined` when it holds none. `endedAt`: the first terminal frame's capture `ts` (millis), or null. */
|
|
6
|
+
export interface LogFacts {
|
|
7
|
+
launched: string | null | undefined;
|
|
8
|
+
endedAt: number | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function factsFromEvents(events: readonly RecordedEvent[]): LogFacts;
|
|
11
|
+
/** The per-run binding: a short hash of the run's `problem` (immutable on a run; no crew code rewrites it). */
|
|
12
|
+
export declare function runFingerprint(problem: unknown): string;
|
|
13
|
+
/** A kept fact set: a key is present only when its fact is (positive facts only). */
|
|
14
|
+
export interface KeptFacts {
|
|
15
|
+
fp: string;
|
|
16
|
+
launched?: string | null;
|
|
17
|
+
endedAt?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `<db>.run-facts.jsonl` (a `core.db`-prefix sidecar: classified in the state-home registry, fenced from workers).
|
|
21
|
+
* Opened lazily on first use, when the engine has the store open. One process writes it; two daemons on one store
|
|
22
|
+
* (not fenced) append whole lines derived from the same logs, so an interleave only duplicates (last line wins).
|
|
23
|
+
*/
|
|
24
|
+
export declare class RunFactsFile {
|
|
25
|
+
readonly path: string;
|
|
26
|
+
private readonly dbPath;
|
|
27
|
+
private kept;
|
|
28
|
+
/** Lines waiting for the next flush (one append per batch, not one write per run). */
|
|
29
|
+
private pending;
|
|
30
|
+
/** The append in flight (one at a time; each writes every line pending when it starts). */
|
|
31
|
+
private writing;
|
|
32
|
+
private timer;
|
|
33
|
+
/** Set when the file could not be written: memory only for this process. */
|
|
34
|
+
private off;
|
|
35
|
+
/** The file's header names the store now at `dbPath` (read or written by this process). */
|
|
36
|
+
private bound;
|
|
37
|
+
/** The file ends inside a line (a torn write): the next append starts a new line first. */
|
|
38
|
+
private torn;
|
|
39
|
+
constructor(path: string, dbPath: string);
|
|
40
|
+
/** The kept facts for `runId`, when they were derived from the run with this fingerprint. */
|
|
41
|
+
get(runId: string, fp: string): KeptFacts | undefined;
|
|
42
|
+
/** Keep a run's positive facts (no-op when there is none or they are already kept). */
|
|
43
|
+
put(runId: string, fp: string, facts: LogFacts): void;
|
|
44
|
+
/** Write everything pending now and wait for it (tests; `close`). Never throws: a failed write turns the file off
|
|
45
|
+
* for this process (memory only) and costs one re-read per run on the next start. */
|
|
46
|
+
flush(): Promise<void>;
|
|
47
|
+
/** At most one append per FLUSH_DELAY_MS: lines kept meanwhile wait for the next window. */
|
|
48
|
+
private arm;
|
|
49
|
+
/** One append of every pending line; one in flight at a time (a caller meanwhile waits for it). */
|
|
50
|
+
private writeOnce;
|
|
51
|
+
/** Start the file over for this store (its header first). */
|
|
52
|
+
private bind;
|
|
53
|
+
private load;
|
|
54
|
+
private compact;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=run-log-facts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-log-facts.d.ts","sourceRoot":"","sources":["../../src/core/run-log-facts.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,qFAAqF;AACrF,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,MAAM,CAAkE,CAAC;AAEnH;4GAC4G;AAC5G,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,QAAQ,CAS1E;AAED,+GAA+G;AAC/G,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAEvD;AAED,qFAAqF;AACrF,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA0BD;;;;GAIG;AACH,qBAAa,YAAY;IAcX,QAAQ,CAAC,IAAI,EAAE,MAAM;IAAE,OAAO,CAAC,QAAQ,CAAC,MAAM;IAb1D,OAAO,CAAC,IAAI,CAAuC;IACnD,sFAAsF;IACtF,OAAO,CAAC,OAAO,CAAgB;IAC/B,2FAA2F;IAC3F,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,KAAK,CAA8C;IAC3D,4EAA4E;IAC5E,OAAO,CAAC,GAAG,CAAS;IACpB,2FAA2F;IAC3F,OAAO,CAAC,KAAK,CAAS;IACtB,2FAA2F;IAC3F,OAAO,CAAC,IAAI,CAAS;gBAEA,IAAI,EAAE,MAAM,EAAmB,MAAM,EAAE,MAAM;IAElE,6FAA6F;IAC7F,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAKrD,uFAAuF;IACvF,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAcrD;0FACsF;IAChF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,4FAA4F;IAC5F,OAAO,CAAC,GAAG;IASX,mGAAmG;IACnG,OAAO,CAAC,SAAS;IAyBjB,6DAA6D;IAC7D,OAAO,CAAC,IAAI;IAUZ,OAAO,CAAC,IAAI;IA2DZ,OAAO,CAAC,OAAO;CAYhB"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// crew#1880 (DES-1880): the facts a run's event log answers that never change once written, kept beside the store so
|
|
2
|
+
// a daemon start does not read every run's log again. At 4k runs the first run list after a start read ~8,000 logs
|
|
3
|
+
// (each terminal run twice: its launch name for `run_identity`, its terminal frame for `ended_at`) and took 7-80 s.
|
|
4
|
+
//
|
|
5
|
+
// Kept: only POSITIVE facts, each the FIRST of its frame kind (a later frame, e.g. after a resume, never changes it):
|
|
6
|
+
// the first `sessionStarted.workflowId` and the first terminal frame's `ts`. A negative (no launch frame, no terminal
|
|
7
|
+
// frame) is never kept, so a run whose log later gains the frame is read again on the next start, as before.
|
|
8
|
+
// Bound to the store by a header (the db file's dev, inode and birth time: a new file discards everything) and each
|
|
9
|
+
// line to its run by a hash of the run's `problem` (a run id can be caller-chosen and reused by another store).
|
|
10
|
+
// Residual (crew#1891): a different store copied over the live file in place, reusing an id with the same problem.
|
|
11
|
+
import { appendFile } from 'node:fs/promises';
|
|
12
|
+
import { readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
/** The engine's terminal frames (the same set `RunTimingIndex` dates a run from). */
|
|
15
|
+
export const TERMINAL_EVENTS = new Set(['sessionCompleted', 'sessionFailed', 'runCancelled']);
|
|
16
|
+
export function factsFromEvents(events) {
|
|
17
|
+
const started = events.find((e) => e.type === 'sessionStarted');
|
|
18
|
+
// The engine spells it `workflowId` on the frame (core-ts `CoreEventJson`).
|
|
19
|
+
const raw = started?.['workflowId'];
|
|
20
|
+
const terminal = events.find((e) => TERMINAL_EVENTS.has(e.type) && typeof e.ts === 'number' && e.ts > 0);
|
|
21
|
+
return {
|
|
22
|
+
launched: started === undefined ? undefined : typeof raw === 'string' ? raw : null,
|
|
23
|
+
endedAt: terminal !== undefined ? terminal.ts : null,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** The per-run binding: a short hash of the run's `problem` (immutable on a run; no crew code rewrites it). */
|
|
27
|
+
export function runFingerprint(problem) {
|
|
28
|
+
return createHash('sha256').update(typeof problem === 'string' ? problem : '').digest('hex').slice(0, 16);
|
|
29
|
+
}
|
|
30
|
+
function storeIdentity(dbPath) {
|
|
31
|
+
try {
|
|
32
|
+
const s = statSync(dbPath);
|
|
33
|
+
return { dev: s.dev, ino: s.ino, birth: Math.round(s.birthtimeMs) };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** How long kept lines wait to be written together. */
|
|
40
|
+
const FLUSH_DELAY_MS = 500;
|
|
41
|
+
/** Lines beyond twice the distinct runs that a file may hold before it is compacted at the next start. */
|
|
42
|
+
const COMPACT_SLACK = 64;
|
|
43
|
+
const sameStore = (a, b) => {
|
|
44
|
+
const o = b;
|
|
45
|
+
return o != null && o.dev === a.dev && o.ino === a.ino && o.birth === a.birth;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* `<db>.run-facts.jsonl` (a `core.db`-prefix sidecar: classified in the state-home registry, fenced from workers).
|
|
49
|
+
* Opened lazily on first use, when the engine has the store open. One process writes it; two daemons on one store
|
|
50
|
+
* (not fenced) append whole lines derived from the same logs, so an interleave only duplicates (last line wins).
|
|
51
|
+
*/
|
|
52
|
+
export class RunFactsFile {
|
|
53
|
+
path;
|
|
54
|
+
dbPath;
|
|
55
|
+
kept = null;
|
|
56
|
+
/** Lines waiting for the next flush (one append per batch, not one write per run). */
|
|
57
|
+
pending = [];
|
|
58
|
+
/** The append in flight (one at a time; each writes every line pending when it starts). */
|
|
59
|
+
writing = null;
|
|
60
|
+
timer = null;
|
|
61
|
+
/** Set when the file could not be written: memory only for this process. */
|
|
62
|
+
off = false;
|
|
63
|
+
/** The file's header names the store now at `dbPath` (read or written by this process). */
|
|
64
|
+
bound = false;
|
|
65
|
+
/** The file ends inside a line (a torn write): the next append starts a new line first. */
|
|
66
|
+
torn = false;
|
|
67
|
+
constructor(path, dbPath) {
|
|
68
|
+
this.path = path;
|
|
69
|
+
this.dbPath = dbPath;
|
|
70
|
+
}
|
|
71
|
+
/** The kept facts for `runId`, when they were derived from the run with this fingerprint. */
|
|
72
|
+
get(runId, fp) {
|
|
73
|
+
const k = this.load().get(runId);
|
|
74
|
+
return k !== undefined && k.fp === fp ? k : undefined;
|
|
75
|
+
}
|
|
76
|
+
/** Keep a run's positive facts (no-op when there is none or they are already kept). */
|
|
77
|
+
put(runId, fp, facts) {
|
|
78
|
+
const kept = { fp };
|
|
79
|
+
if (facts.launched !== undefined)
|
|
80
|
+
kept.launched = facts.launched;
|
|
81
|
+
if (facts.endedAt !== null)
|
|
82
|
+
kept.endedAt = facts.endedAt;
|
|
83
|
+
if (kept.launched === undefined && kept.endedAt === undefined)
|
|
84
|
+
return;
|
|
85
|
+
const prior = this.load().get(runId);
|
|
86
|
+
if (prior !== undefined && prior.fp === fp && prior.launched === kept.launched && prior.endedAt === kept.endedAt)
|
|
87
|
+
return;
|
|
88
|
+
this.load().set(runId, kept);
|
|
89
|
+
if (this.off)
|
|
90
|
+
return;
|
|
91
|
+
this.pending.push(JSON.stringify({ v: 1, run: runId, ...kept }) + '\n');
|
|
92
|
+
// Batched by time, not by turn: a first list derives runs as their reads land, spread over seconds.
|
|
93
|
+
this.arm();
|
|
94
|
+
}
|
|
95
|
+
/** Write everything pending now and wait for it (tests; `close`). Never throws: a failed write turns the file off
|
|
96
|
+
* for this process (memory only) and costs one re-read per run on the next start. */
|
|
97
|
+
async flush() {
|
|
98
|
+
while (this.writing !== null || (this.pending.length > 0 && !this.off && this.bound))
|
|
99
|
+
await this.writeOnce();
|
|
100
|
+
}
|
|
101
|
+
/** At most one append per FLUSH_DELAY_MS: lines kept meanwhile wait for the next window. */
|
|
102
|
+
arm() {
|
|
103
|
+
if (this.timer !== null || this.writing !== null)
|
|
104
|
+
return;
|
|
105
|
+
this.timer = setTimeout(() => {
|
|
106
|
+
this.timer = null;
|
|
107
|
+
void this.writeOnce();
|
|
108
|
+
}, FLUSH_DELAY_MS);
|
|
109
|
+
this.timer.unref?.();
|
|
110
|
+
}
|
|
111
|
+
/** One append of every pending line; one in flight at a time (a caller meanwhile waits for it). */
|
|
112
|
+
writeOnce() {
|
|
113
|
+
if (this.timer !== null) {
|
|
114
|
+
clearTimeout(this.timer);
|
|
115
|
+
this.timer = null;
|
|
116
|
+
}
|
|
117
|
+
if (this.writing !== null)
|
|
118
|
+
return this.writing;
|
|
119
|
+
if (this.pending.length === 0 || this.off || !this.bound)
|
|
120
|
+
return Promise.resolve();
|
|
121
|
+
const lines = (this.torn ? '\n' : '') + this.pending.join('');
|
|
122
|
+
this.pending = [];
|
|
123
|
+
this.torn = false;
|
|
124
|
+
const run = appendFile(this.path, lines).then(() => undefined, () => {
|
|
125
|
+
this.off = true;
|
|
126
|
+
this.pending = [];
|
|
127
|
+
});
|
|
128
|
+
this.writing = run;
|
|
129
|
+
void run.then(() => {
|
|
130
|
+
this.writing = null;
|
|
131
|
+
if (this.pending.length > 0 && !this.off)
|
|
132
|
+
this.arm();
|
|
133
|
+
});
|
|
134
|
+
return run;
|
|
135
|
+
}
|
|
136
|
+
/** Start the file over for this store (its header first). */
|
|
137
|
+
bind(store) {
|
|
138
|
+
try {
|
|
139
|
+
writeFileSync(this.path, JSON.stringify({ v: 1, store }) + '\n');
|
|
140
|
+
this.bound = true;
|
|
141
|
+
this.torn = false;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
this.off = true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
load() {
|
|
148
|
+
if (this.kept !== null)
|
|
149
|
+
return this.kept;
|
|
150
|
+
this.kept = new Map();
|
|
151
|
+
const store = storeIdentity(this.dbPath);
|
|
152
|
+
// No store file to bind to: memory only for this process. (A daemon's first fold has the engine's store open, so
|
|
153
|
+
// the file exists by the time a fact is asked for; only a fake engine meets this.)
|
|
154
|
+
if (store === null) {
|
|
155
|
+
this.off = true;
|
|
156
|
+
return this.kept;
|
|
157
|
+
}
|
|
158
|
+
let text = '';
|
|
159
|
+
try {
|
|
160
|
+
text = readFileSync(this.path, 'utf8');
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
text = '';
|
|
164
|
+
}
|
|
165
|
+
const lines = text.split('\n');
|
|
166
|
+
let header;
|
|
167
|
+
try {
|
|
168
|
+
header = JSON.parse(lines[0] ?? '');
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
header = undefined;
|
|
172
|
+
}
|
|
173
|
+
const h = header;
|
|
174
|
+
if (h?.v !== 1 || !sameStore(store, h.store)) {
|
|
175
|
+
// A missing, unreadable or foreign file (a new store at this path): start it over.
|
|
176
|
+
this.bind(store);
|
|
177
|
+
return this.kept;
|
|
178
|
+
}
|
|
179
|
+
this.bound = true;
|
|
180
|
+
let rows = 0;
|
|
181
|
+
for (const line of lines.slice(1)) {
|
|
182
|
+
if (line === '')
|
|
183
|
+
continue;
|
|
184
|
+
rows++;
|
|
185
|
+
let row;
|
|
186
|
+
try {
|
|
187
|
+
row = JSON.parse(line);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
continue; // a torn or malformed line: that run is derived again
|
|
191
|
+
}
|
|
192
|
+
if (row === null || typeof row !== 'object')
|
|
193
|
+
continue;
|
|
194
|
+
const r = row;
|
|
195
|
+
const run = r['run'];
|
|
196
|
+
const fp = r['fp'];
|
|
197
|
+
if (r['v'] !== 1 || typeof run !== 'string' || typeof fp !== 'string')
|
|
198
|
+
continue;
|
|
199
|
+
const kept = { fp };
|
|
200
|
+
const launched = r['launched'];
|
|
201
|
+
if (typeof launched === 'string' || launched === null)
|
|
202
|
+
kept.launched = launched;
|
|
203
|
+
const endedAt = r['endedAt'];
|
|
204
|
+
if (typeof endedAt === 'number' && endedAt > 0)
|
|
205
|
+
kept.endedAt = endedAt;
|
|
206
|
+
this.kept.set(run, kept);
|
|
207
|
+
}
|
|
208
|
+
this.torn = text.length > 0 && !text.endsWith('\n');
|
|
209
|
+
// Compaction: a run is re-appended only when its facts change (a reused id), so lines track distinct runs; a file
|
|
210
|
+
// that has grown past twice them is rewritten once, here, from what was just read.
|
|
211
|
+
if (rows > 2 * this.kept.size + COMPACT_SLACK)
|
|
212
|
+
this.compact(store, this.kept);
|
|
213
|
+
return this.kept;
|
|
214
|
+
}
|
|
215
|
+
compact(store, all) {
|
|
216
|
+
const out = [JSON.stringify({ v: 1, store })];
|
|
217
|
+
for (const [run, kept] of all)
|
|
218
|
+
out.push(JSON.stringify({ v: 1, run, ...kept }));
|
|
219
|
+
try {
|
|
220
|
+
writeFileSync(this.path, out.join('\n') + '\n');
|
|
221
|
+
this.torn = false;
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// A rewrite that failed part-way may have left a partial row: memory only for this process (the next start
|
|
225
|
+
// reads what is there, skipping a torn row).
|
|
226
|
+
this.off = true;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=run-log-facts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-log-facts.js","sourceRoot":"","sources":["../../src/core/run-log-facts.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,mHAAmH;AACnH,oHAAoH;AACpH,EAAE;AACF,sHAAsH;AACtH,sHAAsH;AACtH,6GAA6G;AAC7G,oHAAoH;AACpH,gHAAgH;AAChH,mHAAmH;AACnH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,qFAAqF;AACrF,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;AASnH,MAAM,UAAU,eAAe,CAAC,MAAgC;IAC9D,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,gBAAgB,CAAwC,CAAC;IACvG,4EAA4E;IAC5E,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC,YAAY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M,CAAC;YACP,2GAA2G;YAC3G,6CAA6C;YAC7C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC;CACF"}
|
package/dist/core/shutdown.d.ts
CHANGED
|
@@ -13,4 +13,31 @@ export declare const SHUTDOWN_DEADLINE_MS = 5000;
|
|
|
13
13
|
* A step that throws never blocks the exit. `exit` is called exactly once.
|
|
14
14
|
*/
|
|
15
15
|
export declare function shutdownWithDeadline(steps: () => Promise<void>, exit: (code: number) => void, deadlineMs?: number, warn?: (message: string) => void): void;
|
|
16
|
+
/** The engine's static stop for install-time editor conformance (wicked-core#1830, `Core.shutdownEditorConformance`):
|
|
17
|
+
* absent on an addon that predates it. */
|
|
18
|
+
export interface ConformanceStopper {
|
|
19
|
+
shutdownEditorConformance?: () => string;
|
|
20
|
+
}
|
|
21
|
+
export interface DaemonShutdownDeps {
|
|
22
|
+
/** Where the signal and exit handlers are registered (`process.on`). */
|
|
23
|
+
on: (event: 'SIGTERM' | 'SIGINT' | 'exit', fn: () => void) => void;
|
|
24
|
+
core: ConformanceStopper;
|
|
25
|
+
/** Reap the bridge children (`bridgeReaper.shutdown`). */
|
|
26
|
+
reap: () => Promise<void>;
|
|
27
|
+
/** The synchronous reap an `exit` handler can still do (`bridgeReaper.sweepSync`). */
|
|
28
|
+
sweepSync: () => void;
|
|
29
|
+
/** Close the engine subscription. */
|
|
30
|
+
close: () => void;
|
|
31
|
+
exit: (code: number) => void;
|
|
32
|
+
/** Called on each signal before anything else (the signal log, the exit reason). */
|
|
33
|
+
onSignal?: (signal: 'SIGTERM' | 'SIGINT') => void;
|
|
34
|
+
deadlineMs?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The daemon's SIGTERM / SIGINT / exit handlers (`serve`). A signal stops the conformance harness first (the
|
|
38
|
+
* longest-lived child; quick when nothing is in flight), then runs the graceful steps once under
|
|
39
|
+
* {@link shutdownWithDeadline}: the bridge children are reaped and the engine subscription closed. A plain exit stops the
|
|
40
|
+
* harness too, beside the synchronous bridge sweep; the stop runs at most once per process.
|
|
41
|
+
*/
|
|
42
|
+
export declare function installDaemonShutdown(deps: DaemonShutdownDeps): void;
|
|
16
43
|
//# sourceMappingURL=shutdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../src/core/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC1B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC5B,UAAU,GAAE,MAA6B,EACzC,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAA6B,GACvD,IAAI,CAqBN"}
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../src/core/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC1B,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAC5B,UAAU,GAAE,MAA6B,EACzC,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAA6B,GACvD,IAAI,CAqBN;AAED;2CAC2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,yBAAyB,CAAC,EAAE,MAAM,MAAM,CAAC;CAC1C;AAED,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,EAAE,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACnE,IAAI,EAAE,kBAAkB,CAAC;IACzB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,sFAAsF;IACtF,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,qCAAqC;IACrC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,oFAAoF;IACpF,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,KAAK,IAAI,CAAC;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAeD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CA+CpE"}
|
package/dist/core/shutdown.js
CHANGED
|
@@ -36,4 +36,76 @@ export function shutdownWithDeadline(steps, exit, deadlineMs = SHUTDOWN_DEADLINE
|
|
|
36
36
|
done();
|
|
37
37
|
})();
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* (crew#1835) Stop the engine's install-time conformance runs. The harness runs in its own process group, so nothing else
|
|
41
|
+
* the daemon does on its way out reaches it: without this its jailed browser runs on to its deadline (up to 900 s). The
|
|
42
|
+
* call is synchronous and waits at most 5 s; a later install call is refused. Best-effort: it never blocks the exit.
|
|
43
|
+
*/
|
|
44
|
+
function stopConformance(core) {
|
|
45
|
+
try {
|
|
46
|
+
core.shutdownEditorConformance?.();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
/* best-effort: a failed stop never blocks the exit */
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The daemon's SIGTERM / SIGINT / exit handlers (`serve`). A signal stops the conformance harness first (the
|
|
54
|
+
* longest-lived child; quick when nothing is in flight), then runs the graceful steps once under
|
|
55
|
+
* {@link shutdownWithDeadline}: the bridge children are reaped and the engine subscription closed. A plain exit stops the
|
|
56
|
+
* harness too, beside the synchronous bridge sweep; the stop runs at most once per process.
|
|
57
|
+
*/
|
|
58
|
+
export function installDaemonShutdown(deps) {
|
|
59
|
+
let shuttingDown = false;
|
|
60
|
+
// Once per process (review r1): the graceful path's stop is followed by `process.exit`, whose 'exit' handler must not
|
|
61
|
+
// wait on the engine a second time.
|
|
62
|
+
let conformanceStopped = false;
|
|
63
|
+
const stopOnce = () => {
|
|
64
|
+
if (conformanceStopped)
|
|
65
|
+
return;
|
|
66
|
+
conformanceStopped = true;
|
|
67
|
+
stopConformance(deps.core);
|
|
68
|
+
};
|
|
69
|
+
const shutdown = () => {
|
|
70
|
+
if (shuttingDown)
|
|
71
|
+
return;
|
|
72
|
+
shuttingDown = true;
|
|
73
|
+
// Before the deadline is armed (review r1): the stop is synchronous native work no JS timer can bound, so it must not
|
|
74
|
+
// eat the reap's budget (its ~2 s grace before SIGKILL) or the subscription close.
|
|
75
|
+
stopOnce();
|
|
76
|
+
shutdownWithDeadline(async () => {
|
|
77
|
+
// Reap bridge children BEFORE this process goes away — the last actor that can still find them. Best-effort.
|
|
78
|
+
try {
|
|
79
|
+
await deps.reap();
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
/* reaping is best-effort */
|
|
83
|
+
}
|
|
84
|
+
// Close the single subscription so the pump thread + tsfn release and the process can exit on its own.
|
|
85
|
+
try {
|
|
86
|
+
deps.close();
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
/* already closed */
|
|
90
|
+
}
|
|
91
|
+
}, deps.exit, deps.deadlineMs);
|
|
92
|
+
};
|
|
93
|
+
for (const signal of ['SIGTERM', 'SIGINT']) {
|
|
94
|
+
deps.on(signal, () => {
|
|
95
|
+
try {
|
|
96
|
+
deps.onSignal?.(signal);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
/* the signal log is best-effort: a failed write (stderr gone) never skips the shutdown */
|
|
100
|
+
}
|
|
101
|
+
shutdown();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Normal exit (`process.exit` anywhere, main() falling off): an 'exit' handler cannot await, so this is the synchronous
|
|
105
|
+
// sweep. After the graceful path above it is a no-op re-scan; on a plain exit it is the only reaping that happens.
|
|
106
|
+
deps.on('exit', () => {
|
|
107
|
+
stopOnce();
|
|
108
|
+
deps.sweepSync();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
39
111
|
//# sourceMappingURL=shutdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../src/core/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,6FAA6F;AAC7F,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAA0B,EAC1B,IAA4B,EAC5B,aAAqB,oBAAoB,EACzC,OAAkC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAExD,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,MAAM;YAAE,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,CAAC,CAAC,CAAC,CAAC;IACV,CAAC,CAAC;IACF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;QAC5B,IAAI,CAAC,+CAA+C,UAAU,iCAAiC,CAAC,CAAC;QACjG,IAAI,EAAE,CAAC;IACT,CAAC,EAAE,UAAU,CAAC,CAAC;IACf,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;IAChB,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,IAAI,CAAC;YACH,MAAM,KAAK,EAAE,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,sDAAsD;QACxD,CAAC;QACD,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,EAAE,CAAC;AAC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CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE STAND-IN CHOICE at launch (DES-STANDIN-001 §4, crew stage K2a; wicked-core#1843).
|
|
3
|
+
*
|
|
4
|
+
* A job needs checks by helpers that did not build the work (a reviewer, a judge, a QE reviewer, a council).
|
|
5
|
+
* When too few helpers are signed in, the engine can seat a STAND-IN: a fresh session of a signed-in helper
|
|
6
|
+
* that sees the work but none of the builder's reasoning, labelled everywhere and never counted as an
|
|
7
|
+
* independent review. It does so only on a launch that carries `standInAware`, and only with a person's
|
|
8
|
+
* consent. This module is the pure half: who consented (`consentFor`), and the refusal bodies a launch
|
|
9
|
+
* answers when the engine's preflight (`Core.independencePreflight`, §3.9) finds the roster short.
|
|
10
|
+
*
|
|
11
|
+
* Consent is a person's. `by` and `at` are the server's, never a request body's: a human's `standIns: true`
|
|
12
|
+
* on the launch (scope `job`), or the `standInReview: 'always'` setting a person saved (scope `always`).
|
|
13
|
+
*/
|
|
14
|
+
import type { IndependencePreflight, NoUsableHelperRefusal, StandInChoiceRefusal, StandInConsent } from 'wicked-crew-api-types';
|
|
15
|
+
/** The `standInReview` setting's values (`SystemSettings.standInReview`); absent reads as `'ask'`. */
|
|
16
|
+
export declare const STAND_IN_REVIEW_VALUES: readonly ["ask", "always"];
|
|
17
|
+
export type StandInReview = (typeof STAND_IN_REVIEW_VALUES)[number];
|
|
18
|
+
export declare function isStandInReview(v: unknown): v is StandInReview;
|
|
19
|
+
/** The gate answer that grants stand-ins at a `stand_in_needed` gate (`GateDecision.action`). */
|
|
20
|
+
export declare const USE_STAND_INS_ACTION: "use_stand_ins";
|
|
21
|
+
/** The gate class (`gate_kind`) a run holds on for want of a stand-in consent. */
|
|
22
|
+
export declare const STAND_IN_NEEDED_GATE: "stand_in_needed";
|
|
23
|
+
export declare const STAND_IN_SCOPES: readonly ["job", "always"];
|
|
24
|
+
export type StandInScope = (typeof STAND_IN_SCOPES)[number];
|
|
25
|
+
/** `by` on a launch under the `always` setting when the setting carries no author (wicked-core#1930 F6): it was saved
|
|
26
|
+
* before crew recorded one, turned on by hand, or its record is out of shape. */
|
|
27
|
+
export declare const STAND_IN_SETTING_UNRECORDED = "the standInReview setting (author not recorded)";
|
|
28
|
+
/** The consent the `always` setting stores (`SystemSettings.standInConsent`): the person who saved it, and when. */
|
|
29
|
+
export declare function settingConsent(who: string, now?: number): StandInConsent;
|
|
30
|
+
/** Whether a stored `standInConsent` has the shape `settingConsent` writes (a hand edit may not). */
|
|
31
|
+
export declare function isSettingConsent(v: unknown): v is StandInConsent;
|
|
32
|
+
/**
|
|
33
|
+
* The consent a launch carries, or `null` (DES §4 `consentFor`). `humanFlag` is the launch body's
|
|
34
|
+
* `standIns: true`, already checked to come from a person (a worker's bearer gets 403 before this).
|
|
35
|
+
* `who` is the server's name for the launcher (`<id> (<kind>)`). Under the `always` setting the consent is the
|
|
36
|
+
* person's who saved it (`saved`, wicked-core#1930 F6), never the launcher's: a workload token only inherits it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function consentFor(humanFlag: boolean, setting: StandInReview | undefined, who: string, now?: number, saved?: StandInConsent): StandInConsent | null;
|
|
39
|
+
/** The preflight's answer, read defensively: `null` when the engine's JSON is not one (the launch then goes
|
|
40
|
+
* on unaware, as before). */
|
|
41
|
+
export declare function readPreflight(raw: string): IndependencePreflight | null;
|
|
42
|
+
/**
|
|
43
|
+
* What the launch answers for this preflight with no consent: `null` = launch, else the `409` body.
|
|
44
|
+
*
|
|
45
|
+
* (crew#1932) The launch asks only for the roles a stand-in can fill, which are the ones every run of its shape seats
|
|
46
|
+
* (the reviewer, the judge, the QE reviewer and the party-excluded review). The preflight also lists the roles a run
|
|
47
|
+
* needs only if an event calls for them (a council on a dispute, the monitors, the rules checks; `conditional`), sized
|
|
48
|
+
* by defaults rather than by the plan the run will score (three monitors where the plan seats one). The engine fills
|
|
49
|
+
* none of those with a stand-in (its one fill site is the review's distribution, plus the judge's and QE reviewer's
|
|
50
|
+
* holds), so a person's answer changes nothing for them: a short one takes the run's own path (the council falls back,
|
|
51
|
+
* the team pauses, a rules check holds as `rules_unchecked`), as before crew#1888, whatever the launch asked. Such a
|
|
52
|
+
* launch goes on stand-in-aware with no consent, as a launch that is not short does.
|
|
53
|
+
* `oneStep`: a launch with no plan and no workflow, which the engine plans as one unit with no review step. The launch
|
|
54
|
+
* asks nothing; a check its work calls for (the default floor's judge) still holds at the run's `stand_in_needed` gate,
|
|
55
|
+
* since the launch is stand-in-aware.
|
|
56
|
+
*
|
|
57
|
+
* A short role every run needs that no helper can stand in for → `no_usable_helper` (§2.5: a stand-in never makes up
|
|
58
|
+
* for a CLI that cannot run); one a stand-in can fill → `stand_in_choice` (§2.1), its words naming the conditional
|
|
59
|
+
* roles too, though no stand-in fills those today (a wording gap noted on crew#1932).
|
|
60
|
+
*/
|
|
61
|
+
export declare function preflightRefusal(p: IndependencePreflight, oneStep?: boolean): StandInChoiceRefusal | NoUsableHelperRefusal | null;
|
|
62
|
+
//# sourceMappingURL=stand-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stand-in.d.ts","sourceRoot":"","sources":["../../src/core/stand-in.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B,sGAAsG;AACtG,eAAO,MAAM,sBAAsB,4BAA6B,CAAC;AACjE,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAE9D;AAED,iGAAiG;AACjG,eAAO,MAAM,oBAAoB,EAAG,eAAwB,CAAC;AAC7D,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,EAAG,i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