@qodeca/xezar 0.13.0 → 0.14.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/README.md +72 -39
- package/dist/agent-config/account-identity.d.ts +2 -8
- package/dist/agent-config/account-identity.js +54 -10
- package/dist/agent-config/account-identity.js.map +1 -1
- package/dist/agent-config/catalog.d.ts +49 -7
- package/dist/agent-config/catalog.js +107 -0
- package/dist/agent-config/catalog.js.map +1 -1
- package/dist/agent-config/model-settings/pi.d.ts +12 -6
- package/dist/agent-config/model-settings/pi.js +12 -6
- package/dist/agent-config/model-settings/pi.js.map +1 -1
- package/dist/agent-config/seed.js +10 -0
- package/dist/agent-config/seed.js.map +1 -1
- package/dist/contract/github.d.ts +15 -0
- package/dist/contract/index.d.ts +9 -0
- package/dist/contract/index.js +1527 -895
- package/dist/contract/mcp-api-reference.d.ts +174 -0
- package/dist/contract/mcp-audit.d.ts +103 -0
- package/dist/contract/mcp-discovery.d.ts +257 -0
- package/dist/contract/mcp-event-catalog.d.ts +121 -0
- package/dist/contract/mcp-event-catalog.test.d.ts +1 -0
- package/dist/contract/mcp-idempotency.d.ts +200 -0
- package/dist/contract/mcp-journal.d.ts +268 -0
- package/dist/contract/mcp-leader.d.ts +88 -0
- package/dist/contract/mcp-ownership.d.ts +78 -0
- package/dist/contract/mcp-versioning.d.ts +139 -0
- package/dist/contract/runs.d.ts +81 -0
- package/dist/core/agent-profiles.d.ts +15 -4
- package/dist/core/agent-profiles.js +22 -8
- package/dist/core/agent-profiles.js.map +1 -1
- package/dist/core/opencode-server-runner.js +71 -11
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/secret-redaction.d.ts +7 -1
- package/dist/core/secret-redaction.js +44 -10
- package/dist/core/secret-redaction.js.map +1 -1
- package/dist/index.js +138 -27
- package/dist/index.js.map +1 -1
- package/dist/machine-identity.d.ts +66 -0
- package/dist/machine-identity.js +96 -0
- package/dist/machine-identity.js.map +1 -0
- package/dist/mcp/adapters/claude-code.d.ts +41 -0
- package/dist/mcp/adapters/claude-code.js +40 -0
- package/dist/mcp/adapters/claude-code.js.map +1 -0
- package/dist/mcp/adapters/codex.d.ts +140 -0
- package/dist/mcp/adapters/codex.js +323 -0
- package/dist/mcp/adapters/codex.js.map +1 -0
- package/dist/mcp/adapters/opencode.d.ts +148 -0
- package/dist/mcp/adapters/opencode.js +528 -0
- package/dist/mcp/adapters/opencode.js.map +1 -0
- package/dist/mcp/adapters/pi-link.d.ts +102 -0
- package/dist/mcp/adapters/pi-link.js +235 -0
- package/dist/mcp/adapters/pi-link.js.map +1 -0
- package/dist/mcp/adapters/pi.d.ts +188 -0
- package/dist/mcp/adapters/pi.js +418 -0
- package/dist/mcp/adapters/pi.js.map +1 -0
- package/dist/mcp/api-reference.d.ts +26 -0
- package/dist/mcp/api-reference.js +133 -0
- package/dist/mcp/api-reference.js.map +1 -0
- package/dist/mcp/audit-trail.d.ts +162 -0
- package/dist/mcp/audit-trail.js +306 -0
- package/dist/mcp/audit-trail.js.map +1 -0
- package/dist/mcp/bridge.d.ts +81 -0
- package/dist/mcp/bridge.js +407 -0
- package/dist/mcp/bridge.js.map +1 -0
- package/dist/mcp/connection-file.d.ts +49 -0
- package/dist/mcp/connection-file.js +63 -0
- package/dist/mcp/connection-file.js.map +1 -0
- package/dist/mcp/echo-guard.d.ts +94 -0
- package/dist/mcp/echo-guard.js +160 -0
- package/dist/mcp/echo-guard.js.map +1 -0
- package/dist/mcp/event-catalog.d.ts +120 -0
- package/dist/mcp/event-catalog.js +306 -0
- package/dist/mcp/event-catalog.js.map +1 -0
- package/dist/mcp/event-controller.d.ts +230 -0
- package/dist/mcp/event-controller.js +596 -0
- package/dist/mcp/event-controller.js.map +1 -0
- package/dist/mcp/event-journal.d.ts +57 -0
- package/dist/mcp/event-journal.js +423 -0
- package/dist/mcp/event-journal.js.map +1 -0
- package/dist/mcp/index.d.ts +63 -0
- package/dist/mcp/index.js +386 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/ipc.d.ts +202 -0
- package/dist/mcp/ipc.js +206 -0
- package/dist/mcp/ipc.js.map +1 -0
- package/dist/mcp/leader-delivery.d.ts +119 -0
- package/dist/mcp/leader-delivery.js +450 -0
- package/dist/mcp/leader-delivery.js.map +1 -0
- package/dist/mcp/operation-receipts.d.ts +210 -0
- package/dist/mcp/operation-receipts.js +723 -0
- package/dist/mcp/operation-receipts.js.map +1 -0
- package/dist/mcp/project-catalogs.d.ts +23 -0
- package/dist/mcp/project-catalogs.js +25 -0
- package/dist/mcp/project-catalogs.js.map +1 -0
- package/dist/mcp/project-leaders.d.ts +26 -0
- package/dist/mcp/project-leaders.js +17 -0
- package/dist/mcp/project-leaders.js.map +1 -0
- package/dist/mcp/protocol.d.ts +50 -0
- package/dist/mcp/protocol.js +47 -0
- package/dist/mcp/protocol.js.map +1 -0
- package/dist/mcp/reconnect.d.ts +297 -0
- package/dist/mcp/reconnect.js +465 -0
- package/dist/mcp/reconnect.js.map +1 -0
- package/dist/mcp/resource-ownership.d.ts +228 -0
- package/dist/mcp/resource-ownership.js +390 -0
- package/dist/mcp/resource-ownership.js.map +1 -0
- package/dist/mcp/service-adapter.d.ts +16488 -0
- package/dist/mcp/service-adapter.js +148 -0
- package/dist/mcp/service-adapter.js.map +1 -0
- package/dist/mcp/service.d.ts +83 -0
- package/dist/mcp/service.js +233 -0
- package/dist/mcp/service.js.map +1 -0
- package/dist/mcp/session-binding.d.ts +105 -0
- package/dist/mcp/session-binding.js +163 -0
- package/dist/mcp/session-binding.js.map +1 -0
- package/dist/mcp/stale-write.d.ts +145 -0
- package/dist/mcp/stale-write.js +219 -0
- package/dist/mcp/stale-write.js.map +1 -0
- package/dist/mcp/tool.d.ts +48 -0
- package/dist/mcp/tool.js +24 -0
- package/dist/mcp/tool.js.map +1 -0
- package/dist/mcp/tools/discovery.d.ts +40 -0
- package/dist/mcp/tools/discovery.js +232 -0
- package/dist/mcp/tools/discovery.js.map +1 -0
- package/dist/mcp/tools/execution-control.d.ts +171 -0
- package/dist/mcp/tools/execution-control.js +513 -0
- package/dist/mcp/tools/execution-control.js.map +1 -0
- package/dist/mcp/tools/handoff-git.d.ts +26 -0
- package/dist/mcp/tools/handoff-git.js +544 -0
- package/dist/mcp/tools/handoff-git.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +2 -0
- package/dist/mcp/tools/index.js +23 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/leader-events.d.ts +46 -0
- package/dist/mcp/tools/leader-events.js +126 -0
- package/dist/mcp/tools/leader-events.js.map +1 -0
- package/dist/mcp/tools/local-handoff.d.ts +102 -0
- package/dist/mcp/tools/local-handoff.js +306 -0
- package/dist/mcp/tools/local-handoff.js.map +1 -0
- package/dist/mcp/tools/project-config.d.ts +340 -0
- package/dist/mcp/tools/project-config.js +1075 -0
- package/dist/mcp/tools/project-config.js.map +1 -0
- package/dist/mcp/tools/results-evidence.d.ts +112 -0
- package/dist/mcp/tools/results-evidence.js +1045 -0
- package/dist/mcp/tools/results-evidence.js.map +1 -0
- package/dist/mcp/tools/task-create.d.ts +70 -0
- package/dist/mcp/tools/task-create.js +473 -0
- package/dist/mcp/tools/task-create.js.map +1 -0
- package/dist/mcp/tools/task-reads.d.ts +102 -0
- package/dist/mcp/tools/task-reads.js +689 -0
- package/dist/mcp/tools/task-reads.js.map +1 -0
- package/dist/mcp/tools/work-organisation.d.ts +2 -0
- package/dist/mcp/tools/work-organisation.js +502 -0
- package/dist/mcp/tools/work-organisation.js.map +1 -0
- package/dist/paths.d.ts +17 -7
- package/dist/paths.js +18 -8
- package/dist/paths.js.map +1 -1
- package/dist/runs/project-writer.js +76 -11
- package/dist/runs/project-writer.js.map +1 -1
- package/dist/runs/retention.d.ts +25 -2
- package/dist/runs/retention.js +63 -2
- package/dist/runs/retention.js.map +1 -1
- package/dist/server/forge/github.js +44 -0
- package/dist/server/forge/github.js.map +1 -1
- package/dist/server/forge/types.d.ts +16 -0
- package/dist/server/project-context.d.ts +81 -8
- package/dist/server/project-context.js +143 -35
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/server.d.ts +1050 -53
- package/dist/server/server.js +326 -120
- package/dist/server/server.js.map +1 -1
- package/dist/server/validators.d.ts +26 -6
- package/dist/server/validators.js +17 -0
- package/dist/server/validators.js.map +1 -1
- package/dist/skills-remote.js +64 -6
- package/dist/skills-remote.js.map +1 -1
- package/dist/workflows/run.d.ts +277 -12
- package/dist/workflows/run.js +599 -79
- package/dist/workflows/run.js.map +1 -1
- package/dist/workspace/agent-profiles.d.ts +30 -3
- package/dist/workspace/agent-profiles.js +39 -4
- package/dist/workspace/agent-profiles.js.map +1 -1
- package/dist/workspace/config.js +25 -4
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/project-owner.d.ts +210 -0
- package/dist/workspace/project-owner.js +518 -0
- package/dist/workspace/project-owner.js.map +1 -0
- package/package.json +5 -3
- package/scripts/pi-leader-extension.ts +420 -0
- package/scripts/sync-readme.mjs +83 -2
- package/web/dist/assets/{alert-dialog-BVsVcbFy.js → alert-dialog-D6rP6d39.js} +1 -1
- package/web/dist/assets/arrow-down-DMOfFIzW.js +1 -0
- package/web/dist/assets/arrow-left-C4Ec2BUg.js +1 -0
- package/web/dist/assets/{centered-state-Djgly6Ni.js → centered-state-B0ZqrPaa.js} +12 -12
- package/web/dist/assets/chevron-right-mHJ-crvn.js +1 -0
- package/web/dist/assets/{collapsible-DZ4D-DHG.js → collapsible-DchEHgUM.js} +1 -1
- package/web/dist/assets/{commit-list-B-z1JL9G.js → commit-list-BpMim1Rv.js} +1 -1
- package/web/dist/assets/{compare-variants-CdS8r8E2.js → compare-variants-D5ItQbAq.js} +1 -1
- package/web/dist/assets/{diff-BKew9rQX.js → diff-HqqZ_WDR.js} +2 -2
- package/web/dist/assets/{diff-stat-D0mc5V6Z.js → diff-stat-NsU-3ecr.js} +1 -1
- package/web/dist/assets/{diff-view-xpIcuLIC.js → diff-view-B7c11Xux.js} +1 -1
- package/web/dist/assets/{dropdown-menu-CEQziH7X.js → dropdown-menu-CtTpnyod.js} +1 -1
- package/web/dist/assets/{editable-title-BCX3T2BY.js → editable-title-BXtuGQry.js} +1 -1
- package/web/dist/assets/{ellipsis-vertical-ByVdDc4z.js → ellipsis-vertical-MHtGZSH6.js} +1 -1
- package/web/dist/assets/{file-xBSB5hXO.js → file-DKLw5SOb.js} +1 -1
- package/web/dist/assets/{folder-CldgbZ5A.js → folder-Drw6-ufH.js} +1 -1
- package/web/dist/assets/{git-toolbar-BYlnf4qf.js → git-toolbar-BQH8bORV.js} +1 -1
- package/web/dist/assets/github-ynnpKFCJ.js +1 -0
- package/web/dist/assets/{image-preview-Cv5mZr0n.js → image-preview-DLhMN_R9.js} +1 -1
- package/web/dist/assets/index-BEsrNdXt.js +29 -0
- package/web/dist/assets/index-Da8DOBau.css +2 -0
- package/web/dist/assets/{markdown-CgEEE2ND.js → markdown-q365eN6Y.js} +1 -1
- package/web/dist/assets/{new-task-form-1r2bgsdD.js → new-task-form-CW-hNIWQ.js} +1 -1
- package/web/dist/assets/{pill-q-x22_ej.js → pill-B_TFulXa.js} +1 -1
- package/web/dist/assets/{project-router-VDN4jQM8.js → project-router-CLPc-ImZ.js} +1 -1
- package/web/dist/assets/{prompt-templates-BmZtCe-L.js → prompt-templates-CLc4RxyO.js} +1 -1
- package/web/dist/assets/{repo-git-C2On8SlI.js → repo-git-Is7R6-Tj.js} +1 -1
- package/web/dist/assets/{run-diff-vguEMJzh.js → run-diff-DHMvDlVo.js} +2 -2
- package/web/dist/assets/run-header-DvZJbQ8I.js +1 -0
- package/web/dist/assets/{search-x-QmhaAbg5.js → search-x-Ce2MMetu.js} +1 -1
- package/web/dist/assets/{skill-empty-hint-BrzUwByZ.js → skill-empty-hint-C_xCSvzB.js} +1 -1
- package/web/dist/assets/skills-CivqD4si.js +1 -0
- package/web/dist/assets/{sparkles-CP8QDOgX.js → sparkles-BCqPoj5g.js} +1 -1
- package/web/dist/assets/{square-terminal-CGypshSD.js → square-terminal-ikj5g-oK.js} +1 -1
- package/web/dist/assets/{tab-link-D4lFzzI1.js → tab-link-VsEjFV1Y.js} +1 -1
- package/web/dist/assets/{task-changes-6aopqAmV.js → task-changes-CH-E81-_.js} +1 -1
- package/web/dist/assets/{task-commits-u-dwaCyw.js → task-commits-DqfkMFxp.js} +1 -1
- package/web/dist/assets/{task-files-IMOZnIUK.js → task-files-D_nkHZ_a.js} +2 -2
- package/web/dist/assets/task-thread-bxQompxJ.js +9 -0
- package/web/dist/assets/{textarea-CyBCyKIk.js → textarea-xajuW1L_.js} +1 -1
- package/web/dist/assets/{thread-loading-Cuq2jchC.js → thread-loading-C3JQZbIE.js} +1 -1
- package/web/dist/assets/{trash-2-B6Dp3ZNs.js → trash-2-hJrBhpUD.js} +1 -1
- package/web/dist/assets/{triangle-alert-xBya8FUp.js → triangle-alert-D1u82y1a.js} +1 -1
- package/web/dist/assets/{upload-D6MXEB9p.js → upload-Bn6FBZ59.js} +1 -1
- package/web/dist/assets/{use-desktop-fLDKEJoB.js → use-desktop-DOIMfHfY.js} +1 -1
- package/web/dist/assets/{use-submit-shortcut-JTpNzU-u.js → use-submit-shortcut-Dj4DHTdE.js} +1 -1
- package/web/dist/assets/utils-YwBpOoRN.js +64 -0
- package/web/dist/assets/{workflows-BY3KTkFw.js → workflows-CTaAKz2m.js} +3 -3
- package/web/dist/assets/{zoomable-image-GTYwLtkS.js → zoomable-image-C1-6P3tg.js} +1 -1
- package/web/dist/index.html +23 -23
- package/web/dist/assets/arrow-down-CYgAlZtW.js +0 -1
- package/web/dist/assets/arrow-left-BOqE0a3k.js +0 -1
- package/web/dist/assets/chevron-right-Cc9BWnbN.js +0 -1
- package/web/dist/assets/github-CqGK62Lw.js +0 -1
- package/web/dist/assets/index-3nxVmdn5.css +0 -2
- package/web/dist/assets/index-qX7n11FX.js +0 -9
- package/web/dist/assets/refresh-cw-DcNCj2nu.js +0 -1
- package/web/dist/assets/run-header-DM7MiKj9.js +0 -1
- package/web/dist/assets/skills-Bj-uG_Hz.js +0 -1
- package/web/dist/assets/task-thread-CbMPmrWq.js +0 -9
- package/web/dist/assets/utils--z9hRtl3.js +0 -64
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { type OperationAnswer, type OperationResultRef, type ReconcileKind, type ReconcilePredicate } from '../contract/index.js';
|
|
2
|
+
/** The append-only journal: one line per phase transition. The durable record (D-06 § 7.2). */
|
|
3
|
+
export declare const RECEIPT_JOURNAL_FILE = "mcp-operations.ndjson";
|
|
4
|
+
/** The compacted snapshot: a load-time shortcut, never the source of truth (D-06 § 7.2). */
|
|
5
|
+
export declare const RECEIPT_SNAPSHOT_FILE = "mcp-operations.json";
|
|
6
|
+
/**
|
|
7
|
+
* Receipt age floor: 12 resumes × 5 h + the 24 h missed-deadline tolerance = 84 h (D-06 § 8.2) —
|
|
8
|
+
* the longest span over which the engine itself may still resurrect a run one MCP mutation
|
|
9
|
+
* started. Derived from the live constants, so the derivation IS the decision.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RECEIPT_MAX_AGE_MS: number;
|
|
12
|
+
/** Receipt count floor per project: a measured 40.6 ms cold scan against a 300 ms budget (D-06 § 8.3). */
|
|
13
|
+
export declare const RECEIPT_MAX_KEPT = 50000;
|
|
14
|
+
/** Snapshot cadence: a 1 000-line journal scans in 0.7 ms, so compacting sooner does not pay (D-06 § 7.2). */
|
|
15
|
+
export declare const RECEIPT_SNAPSHOT_EVERY_LINES = 1000;
|
|
16
|
+
/**
|
|
17
|
+
* The UUIDv5 namespace MCP-created run ids are derived in (D-06 § 12.1). A constant, never
|
|
18
|
+
* regenerated: changing it would make every recorded prediction point at an id nobody creates.
|
|
19
|
+
*/
|
|
20
|
+
export declare const XEZAR_MCP_NAMESPACE = "a3c1e7d2-5b4f-4e8a-9c61-2f0d8b7e4a15";
|
|
21
|
+
/** What an effect reports. A refusal the service makes after the intent is `rejected`. */
|
|
22
|
+
export type EffectOutcome = {
|
|
23
|
+
outcome: 'ok';
|
|
24
|
+
resultRef: OperationResultRef;
|
|
25
|
+
} | {
|
|
26
|
+
outcome: 'rejected' | 'not-applied';
|
|
27
|
+
errorCode: string;
|
|
28
|
+
};
|
|
29
|
+
/** A reconciler's verdict — the answer to "did this effect happen?", from a READ (D-06 § 9.3). */
|
|
30
|
+
export type ReconcileVerdict = {
|
|
31
|
+
verdict: 'ok';
|
|
32
|
+
resultRef: OperationResultRef;
|
|
33
|
+
} | {
|
|
34
|
+
verdict: 'not-applied';
|
|
35
|
+
} | {
|
|
36
|
+
verdict: 'unverified';
|
|
37
|
+
reason: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Answers one question with an idempotent read, never a write — a reconciler that mutates to find
|
|
41
|
+
* out is the blind repeat this module exists to prevent (D-06 § 9.3 rule 2). `not-applied` needs a
|
|
42
|
+
* POSITIVE answer; silence, a timeout, a network error or a missing tool are `unverified` (rule 3).
|
|
43
|
+
*/
|
|
44
|
+
export type Reconciler = (predicate: ReconcilePredicate, context: {
|
|
45
|
+
action: string;
|
|
46
|
+
startedAt: string;
|
|
47
|
+
}) => ReconcileVerdict | Promise<ReconcileVerdict>;
|
|
48
|
+
export interface OperationRequest {
|
|
49
|
+
/** From the trusted connection binding — NEVER from a tool argument (D-06 § 5.2). */
|
|
50
|
+
projectId: string;
|
|
51
|
+
/** The client-generated operation id, as supplied. */
|
|
52
|
+
operationId: string;
|
|
53
|
+
/** The action id, e.g. `runs.create`. */
|
|
54
|
+
action: string;
|
|
55
|
+
/** The payload AFTER the action's zod schema parsed it — never raw params (D-06 § 5.4). */
|
|
56
|
+
payload: unknown;
|
|
57
|
+
/** Top-level keys the digest ignores. Ships empty; every addition needs a recorded reason. */
|
|
58
|
+
digestExclude?: readonly string[];
|
|
59
|
+
expectedVersion?: string;
|
|
60
|
+
ownerGeneration?: string;
|
|
61
|
+
/** The read that can later settle a dangling intent, fixed BEFORE the effect (D-06 § 9.3). */
|
|
62
|
+
reconcile: ReconcilePredicate;
|
|
63
|
+
/**
|
|
64
|
+
* D-06 § 7.3 step 2 — the version/permission check, run synchronously in the same critical
|
|
65
|
+
* section as the intent write. Return an error code to refuse; the refusal writes one `settled`
|
|
66
|
+
* `rejected` line and no intent, so a retry returns the same rejection.
|
|
67
|
+
*/
|
|
68
|
+
precheck?: () => string | undefined;
|
|
69
|
+
/** D-06 § 7.3 step 4. Throwing is treated as "may have happened" and reconciled, never repeated. */
|
|
70
|
+
effect: () => EffectOutcome | Promise<EffectOutcome>;
|
|
71
|
+
}
|
|
72
|
+
export interface OperationReceiptStoreOptions {
|
|
73
|
+
/** Clock, for tests. */
|
|
74
|
+
now?: () => number;
|
|
75
|
+
/** One reconciler per predicate kind. A kind with no reconciler reads as `unverified`. */
|
|
76
|
+
reconcilers?: Partial<Record<ReconcileKind, Reconciler>>;
|
|
77
|
+
/**
|
|
78
|
+
* The structural floor (D-06 § 8.4): a receipt is never evicted while the resource its
|
|
79
|
+
* `resultRef` names still exists. Absent = no resource is known live.
|
|
80
|
+
*/
|
|
81
|
+
isResultLive?: (ref: OperationResultRef) => boolean;
|
|
82
|
+
/** Bounds, for tests only — production uses the D-06 numbers above. */
|
|
83
|
+
maxAgeMs?: number;
|
|
84
|
+
maxKept?: number;
|
|
85
|
+
snapshotEveryLines?: number;
|
|
86
|
+
}
|
|
87
|
+
/** `<projectId>/<operationId>` (D-06 § 5.2). The id alphabet has no `/`, so the split is unambiguous. */
|
|
88
|
+
export declare function operationKey(projectId: string, operationId: string): string;
|
|
89
|
+
/** RFC 4122 § 4.3 name-based UUID, SHA-1 variant. */
|
|
90
|
+
export declare function uuidV5(name: string, namespace: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* The run id an MCP `runs.create` must create, derived from the operation key before the effect
|
|
93
|
+
* (D-06 § 12.1). A retry predicts the same id; two operations cannot share one. Reconciliation is
|
|
94
|
+
* then a primary-key lookup and no new field is persisted on the run record.
|
|
95
|
+
*/
|
|
96
|
+
export declare function predictRunId(projectId: string, operationId: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* `sha256(canonical(payload))`, lowercase hex (D-06 § 5.4). The payload must already be the
|
|
99
|
+
* action's zod-parsed value. Canonical form: object keys sorted by UTF-16 code unit at every level,
|
|
100
|
+
* arrays in order, no whitespace, `undefined` object keys dropped, and every binary blob replaced
|
|
101
|
+
* by `{ bytes, sha256 }` so the digest covers the BYTES, never a path. Non-finite numbers and
|
|
102
|
+
* values JSON cannot carry are refused rather than silently coerced.
|
|
103
|
+
*/
|
|
104
|
+
export declare function payloadDigest(payload: unknown, digestExclude?: readonly string[]): string;
|
|
105
|
+
/**
|
|
106
|
+
* `run-by-key` (D-06 § 9.3): the store write IS the effect, so a run under the predicted id means
|
|
107
|
+
* `ok` and its absence means `not-applied` — but only while the index can still answer. The run
|
|
108
|
+
* store evicts by COUNT, so a busy project may already have pruned the very run an old intent
|
|
109
|
+
* names; "not there" and "the store can no longer tell" must not share a branch.
|
|
110
|
+
*
|
|
111
|
+
* The index can answer only if the intent is no older than the oldest run each retention pool
|
|
112
|
+
* still holds (archived and live runs are pruned separately, so the newest of the two pool-oldest
|
|
113
|
+
* dates is the conservative bound). An empty index cannot answer at all — it may be a deleted or
|
|
114
|
+
* corrupt `runs.json` — so it is `unverified` too. Both errors fall on the safe side: a spurious
|
|
115
|
+
* "check this" is recoverable, a duplicated task is not.
|
|
116
|
+
*/
|
|
117
|
+
export declare function runByKeyReconciler(store: {
|
|
118
|
+
getRun(id: string): {
|
|
119
|
+
id: string;
|
|
120
|
+
} | undefined;
|
|
121
|
+
listRuns(): Array<{
|
|
122
|
+
createdAt: string;
|
|
123
|
+
archived?: boolean;
|
|
124
|
+
}>;
|
|
125
|
+
}): Reconciler;
|
|
126
|
+
/**
|
|
127
|
+
* The per-project receipt store. One instance per project data directory, owned by the process
|
|
128
|
+
* `ownProjectData` admits as that project's writer — which is why no cross-process lock is needed
|
|
129
|
+
* around the check-then-write (D-06 § 4.5).
|
|
130
|
+
*/
|
|
131
|
+
export declare class OperationReceiptStore {
|
|
132
|
+
readonly dataDir: string;
|
|
133
|
+
private readonly opts;
|
|
134
|
+
private readonly receipts;
|
|
135
|
+
/** Keys whose effect (or reconciliation) is running in THIS process right now. */
|
|
136
|
+
private readonly live;
|
|
137
|
+
private readonly warned;
|
|
138
|
+
private readonly journalPath;
|
|
139
|
+
private readonly snapshotPath;
|
|
140
|
+
private readonly now;
|
|
141
|
+
private readonly maxAgeMs;
|
|
142
|
+
private readonly maxKept;
|
|
143
|
+
private readonly snapshotEveryLines;
|
|
144
|
+
/** Lines appended (or scanned past the snapshot) since the last compaction. */
|
|
145
|
+
private linesSinceCompaction;
|
|
146
|
+
/** Journal lines that failed to parse. While > 0, a key miss reconciles before executing (§ 7.4). */
|
|
147
|
+
private quarantined;
|
|
148
|
+
private damageDetectedAt;
|
|
149
|
+
/** Whether the journal already exists with content; a fresh journal starts with a header line. */
|
|
150
|
+
private journalStarted;
|
|
151
|
+
/** The journal ends in a torn line: the next append must start on a fresh line, or the torn
|
|
152
|
+
* fragment would swallow a good receipt into the quarantine with it. */
|
|
153
|
+
private needsNewline;
|
|
154
|
+
private constructor();
|
|
155
|
+
/**
|
|
156
|
+
* Open (or create on first write) the receipts for one project data directory. Never throws:
|
|
157
|
+
* absent files are an empty store, an unreadable snapshot is ignored, and unreadable journal
|
|
158
|
+
* lines are quarantined one by one — a torn final line costs exactly that one receipt (§ 7.4).
|
|
159
|
+
*/
|
|
160
|
+
static open(dataDir: string, opts?: OperationReceiptStoreOptions): OperationReceiptStore;
|
|
161
|
+
/** Counts for diagnostics and tests. */
|
|
162
|
+
stats(): {
|
|
163
|
+
receipts: number;
|
|
164
|
+
quarantined: number;
|
|
165
|
+
live: number;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Run one mutation under its operation key, answering with exactly one § 6 result.
|
|
169
|
+
*
|
|
170
|
+
* Everything up to the intent append is synchronous, so two calls with one key cannot both pass
|
|
171
|
+
* the lookup: the second sees the first as live and answers `in-progress`.
|
|
172
|
+
*/
|
|
173
|
+
execute(request: OperationRequest): Promise<OperationAnswer>;
|
|
174
|
+
/**
|
|
175
|
+
* Reconcile every dangling intent once, in the background (D-06 § 9.3 rule 1). Callers start it
|
|
176
|
+
* after project open and never await it: a `gh`-less or offline machine keeps working, and until
|
|
177
|
+
* a receipt's reconciliation finishes it truthfully reads `unverified`.
|
|
178
|
+
*/
|
|
179
|
+
reconcilePending(): Promise<void>;
|
|
180
|
+
/** Clean shutdown: compact, so the next open reads a snapshot instead of the whole journal. */
|
|
181
|
+
close(): void;
|
|
182
|
+
private reconcileDangling;
|
|
183
|
+
private runReconciler;
|
|
184
|
+
private settledReceipt;
|
|
185
|
+
private settledAnswer;
|
|
186
|
+
private unverifiedAnswer;
|
|
187
|
+
/** Synchronous append — survives a process crash the instant it returns (D-06 § 3.3). Throws. */
|
|
188
|
+
private append;
|
|
189
|
+
/** Append where a failed write must not change the answer; the in-memory receipt still replays. */
|
|
190
|
+
private appendBestEffort;
|
|
191
|
+
private maybeCompact;
|
|
192
|
+
private load;
|
|
193
|
+
private noteDamage;
|
|
194
|
+
private readSnapshot;
|
|
195
|
+
/**
|
|
196
|
+
* Retention (D-06 § 8). A receipt is evicted only when it is BOTH older than the age floor AND
|
|
197
|
+
* outside the newest `maxKept` for its project. A dangling intent is never evicted — its
|
|
198
|
+
* `unverified` answer must not decay into "never happened" — and neither is a receipt whose
|
|
199
|
+
* result still exists (§ 8.4). Touches these files and nothing else (§ 12.2).
|
|
200
|
+
*/
|
|
201
|
+
private evict;
|
|
202
|
+
/**
|
|
203
|
+
* Evict, then rewrite the journal from the folded set and write an offset-anchored snapshot
|
|
204
|
+
* (D-06 § 7.2, § 8.1). The quarantine count survives the rewrite as a damage marker until the
|
|
205
|
+
* age floor has passed since it was detected — a torn line's operation cannot be retried later
|
|
206
|
+
* than that — and then it is compacted out on its own, with no manual step.
|
|
207
|
+
*/
|
|
208
|
+
private compact;
|
|
209
|
+
private warnOnce;
|
|
210
|
+
}
|