@sentropic/h2a-runtime 0.98.6 → 0.98.7-rc.2
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/agent-launch-args.d.ts.map +1 -1
- package/dist/agent-launch-args.js +5 -5
- package/dist/agent-launch-args.js.map +1 -1
- package/dist/agy-claude.d.ts +2 -0
- package/dist/agy-claude.d.ts.map +1 -0
- package/dist/agy-claude.js +3 -0
- package/dist/agy-claude.js.map +1 -0
- package/dist/agy-headless.d.ts +11 -0
- package/dist/agy-headless.d.ts.map +1 -0
- package/dist/agy-headless.js +104 -0
- package/dist/agy-headless.js.map +1 -0
- package/dist/attach.d.ts +2 -0
- package/dist/attach.d.ts.map +1 -1
- package/dist/attach.js +73 -6
- package/dist/attach.js.map +1 -1
- package/dist/auth-login.d.ts +24 -1
- package/dist/auth-login.d.ts.map +1 -1
- package/dist/auth-login.js +132 -4
- package/dist/auth-login.js.map +1 -1
- package/dist/central-mcp.d.ts +2 -0
- package/dist/central-mcp.d.ts.map +1 -1
- package/dist/central-mcp.js +90 -3
- package/dist/central-mcp.js.map +1 -1
- package/dist/claude-code-cli-isolation.d.ts +53 -0
- package/dist/claude-code-cli-isolation.d.ts.map +1 -0
- package/dist/claude-code-cli-isolation.js +277 -0
- package/dist/claude-code-cli-isolation.js.map +1 -0
- package/dist/claude-code-cli-lifecycle.d.ts +80 -0
- package/dist/claude-code-cli-lifecycle.d.ts.map +1 -0
- package/dist/claude-code-cli-lifecycle.js +402 -0
- package/dist/claude-code-cli-lifecycle.js.map +1 -0
- package/dist/claude-code-cli-runner.d.ts +89 -0
- package/dist/claude-code-cli-runner.d.ts.map +1 -0
- package/dist/claude-code-cli-runner.js +659 -0
- package/dist/claude-code-cli-runner.js.map +1 -0
- package/dist/claude-seat-input.d.ts +47 -0
- package/dist/claude-seat-input.d.ts.map +1 -0
- package/dist/claude-seat-input.js +272 -0
- package/dist/claude-seat-input.js.map +1 -0
- package/dist/claude-seat-mesh-contract.d.ts +88 -0
- package/dist/claude-seat-mesh-contract.d.ts.map +1 -0
- package/dist/claude-seat-mesh-contract.js +13 -0
- package/dist/claude-seat-mesh-contract.js.map +1 -0
- package/dist/cli-help-groups.js +1 -1
- package/dist/cli-help-groups.js.map +1 -1
- package/dist/crash-log.d.ts +112 -0
- package/dist/crash-log.d.ts.map +1 -0
- package/dist/crash-log.js +560 -0
- package/dist/crash-log.js.map +1 -0
- package/dist/delegate.d.ts +10 -0
- package/dist/delegate.d.ts.map +1 -1
- package/dist/delegate.js +29 -0
- package/dist/delegate.js.map +1 -1
- package/dist/gateway-host/claude-seat-client.d.ts +32 -0
- package/dist/gateway-host/claude-seat-client.d.ts.map +1 -0
- package/dist/gateway-host/claude-seat-client.js +38 -0
- package/dist/gateway-host/claude-seat-client.js.map +1 -0
- package/dist/gateway-host/host.d.ts +6 -0
- package/dist/gateway-host/host.d.ts.map +1 -1
- package/dist/gateway-host/host.js +24 -3
- package/dist/gateway-host/host.js.map +1 -1
- package/dist/gateway-host/live-declarations.d.ts +58 -0
- package/dist/gateway-host/live-declarations.d.ts.map +1 -0
- package/dist/gateway-host/live-declarations.js +429 -0
- package/dist/gateway-host/live-declarations.js.map +1 -0
- package/dist/gateway-host/live-github.d.ts +11 -0
- package/dist/gateway-host/live-github.d.ts.map +1 -0
- package/dist/gateway-host/live-github.js +374 -0
- package/dist/gateway-host/live-github.js.map +1 -0
- package/dist/gateway-host/live-object-store.d.ts +35 -0
- package/dist/gateway-host/live-object-store.d.ts.map +1 -0
- package/dist/gateway-host/live-object-store.js +447 -0
- package/dist/gateway-host/live-object-store.js.map +1 -0
- package/dist/gateway-host/live-registration.d.ts +162 -0
- package/dist/gateway-host/live-registration.d.ts.map +1 -0
- package/dist/gateway-host/live-registration.js +455 -0
- package/dist/gateway-host/live-registration.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +290 -23
- package/dist/index.js.map +1 -1
- package/dist/llm-mesh-accounts.d.ts +70 -4
- package/dist/llm-mesh-accounts.d.ts.map +1 -1
- package/dist/llm-mesh-accounts.js +296 -9
- package/dist/llm-mesh-accounts.js.map +1 -1
- package/dist/native-host.d.ts +1 -1
- package/dist/native-host.d.ts.map +1 -1
- package/dist/native-host.js +30 -17
- package/dist/native-host.js.map +1 -1
- package/dist/native-terminal/host.d.ts +6 -1
- package/dist/native-terminal/host.d.ts.map +1 -1
- package/dist/native-terminal/host.js +6 -25
- package/dist/native-terminal/host.js.map +1 -1
- package/dist/native-terminal/journal.d.ts +5 -0
- package/dist/native-terminal/journal.d.ts.map +1 -1
- package/dist/native-terminal/journal.js +28 -16
- package/dist/native-terminal/journal.js.map +1 -1
- package/dist/native-terminal/op.d.ts +13 -0
- package/dist/native-terminal/op.d.ts.map +1 -1
- package/dist/native-terminal/op.js +64 -5
- package/dist/native-terminal/op.js.map +1 -1
- package/dist/proc-identity.d.ts +31 -0
- package/dist/proc-identity.d.ts.map +1 -1
- package/dist/proc-identity.js +54 -0
- package/dist/proc-identity.js.map +1 -1
- package/dist/prompt-delivery.d.ts +3 -0
- package/dist/prompt-delivery.d.ts.map +1 -1
- package/dist/prompt-delivery.js +8 -3
- package/dist/prompt-delivery.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +79 -16
- package/dist/run.js.map +1 -1
- package/dist/terminal-reset.d.ts +104 -0
- package/dist/terminal-reset.d.ts.map +1 -0
- package/dist/terminal-reset.js +229 -0
- package/dist/terminal-reset.js.map +1 -0
- package/dist/tmux.d.ts +26 -4
- package/dist/tmux.d.ts.map +1 -1
- package/dist/tmux.js +60 -25
- package/dist/tmux.js.map +1 -1
- package/dist/vendor/engram-live/contracts.d.ts +825 -0
- package/dist/vendor/engram-live/contracts.js +1734 -0
- package/dist/vendor/engram-live/integration.d.ts +113 -0
- package/dist/vendor/engram-live/integration.js +254 -0
- package/dist/vendor/engram-live/pr-sync.d.ts +144 -0
- package/dist/vendor/engram-live/pr-sync.js +411 -0
- package/dist/vendor/engram-live/registration.d.ts +138 -0
- package/dist/vendor/engram-live/registration.js +358 -0
- package/dist/vendor/engram-live/retention.d.ts +56 -0
- package/dist/vendor/engram-live/retention.js +179 -0
- package/package.json +2 -2
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L6a (H) — durable local store for explicit live workspace declarations.
|
|
3
|
+
*
|
|
4
|
+
* DESIGN (LIVE §2, §12):
|
|
5
|
+
* - The declaration store is LOCAL h2a state under the injected h2a root
|
|
6
|
+
* (<root>/live/declarations.json), outside every observed worktree and
|
|
7
|
+
* its git-dir/common-dir. It is authoritative independently of the live
|
|
8
|
+
* projection: losing the projection never loses registrations, and the
|
|
9
|
+
* store is never a projection-owned surface.
|
|
10
|
+
* - Each record wraps the EXACT neutral WorkspaceDeclarationDto (flat
|
|
11
|
+
* identity triangle declarationId/cloneId/worktreeId, tenant,
|
|
12
|
+
* liveCapability, declarationRevision, flat product binding) plus the
|
|
13
|
+
* full local CloneIdentityDto/WorktreeIdentityDto (host-local realpath,
|
|
14
|
+
* git-dir and paths needed to operate; only the opaque ids cross to
|
|
15
|
+
* sentropic). Every write is validated with the engram validators — the
|
|
16
|
+
* runtime keeps no mirror of the contract, it imports the vendored
|
|
17
|
+
* neutral contracts entry (../vendor/engram-live, see the
|
|
18
|
+
* core live/contracts.ts header).
|
|
19
|
+
* - Writes are atomic (0600, tmp+rename) through a token-owned staging
|
|
20
|
+
* file; a corrupt store fails EXPLICITLY, it never silently
|
|
21
|
+
* restarts empty (that would erase desired live registrations). A
|
|
22
|
+
* pre-realignment (nested, `live-git-1`) store file is rejected
|
|
23
|
+
* EXPLICITLY as unsupported — never silently migrated, never silently
|
|
24
|
+
* read: L6a is not consumed yet, so no migration replay exists and the
|
|
25
|
+
* operator removes the file to start fresh.
|
|
26
|
+
* - Update is revision-guarded ATOMICALLY: the caller composes the next
|
|
27
|
+
* record through the contract rules (declarationRevision + 1, immutable
|
|
28
|
+
* identity triangle, binding renewal-or-preserved); the store verifies
|
|
29
|
+
* the guard, the triangle, the binding monotonicity (first binding
|
|
30
|
+
* exactly INITIAL_BINDING_REVISION, then strictly greater) and the
|
|
31
|
+
* final DTOs, then re-verifies the durable revision and persists under
|
|
32
|
+
* ONE exclusive lock. A stale writer is refused with the typed
|
|
33
|
+
* LiveRevisionConflict, never clobbering; a declaration removed after
|
|
34
|
+
* the read is never resurrected. Insert and remove hold the same lock,
|
|
35
|
+
* so every read-check-write (including removals) is serialized.
|
|
36
|
+
*/
|
|
37
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmdirSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
38
|
+
import { randomUUID } from "node:crypto";
|
|
39
|
+
import { join } from "node:path";
|
|
40
|
+
import { INITIAL_BINDING_REVISION, validateCloneIdentity, validateWorkspaceDeclaration, validateWorktreeIdentity, } from "../vendor/engram-live/contracts.js";
|
|
41
|
+
export const LIVE_DECLARATION_KIND = "h2a-live-declaration";
|
|
42
|
+
export const LIVE_DECLARATION_SCHEMA_VERSION = 1;
|
|
43
|
+
/**
|
|
44
|
+
* Typed revision conflict: the durable declaration moved (or vanished)
|
|
45
|
+
* under a writer holding a stale base revision. The message keeps the
|
|
46
|
+
* `revision_conflict` marker; the name and the revision fields let callers
|
|
47
|
+
* branch on it without parsing text.
|
|
48
|
+
*/
|
|
49
|
+
export class LiveRevisionConflict extends Error {
|
|
50
|
+
declarationId;
|
|
51
|
+
expectedDeclarationRevision;
|
|
52
|
+
/** Current durable revision; undefined when the declaration is gone. */
|
|
53
|
+
actualDeclarationRevision;
|
|
54
|
+
constructor(declarationId, expectedDeclarationRevision, actualDeclarationRevision) {
|
|
55
|
+
super(actualDeclarationRevision === undefined
|
|
56
|
+
? `revision_conflict: live declaration ${declarationId} was removed; stale writer held declaration revision ${expectedDeclarationRevision}`
|
|
57
|
+
: `revision_conflict: live declaration ${declarationId} is at declaration revision ` +
|
|
58
|
+
`${actualDeclarationRevision}, stale writer held ${expectedDeclarationRevision}`);
|
|
59
|
+
this.name = "LiveRevisionConflict";
|
|
60
|
+
this.declarationId = declarationId;
|
|
61
|
+
this.expectedDeclarationRevision = expectedDeclarationRevision;
|
|
62
|
+
this.actualDeclarationRevision = actualDeclarationRevision;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Exclusive store lock (synchronous, no dependency).
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
//
|
|
69
|
+
// Every mutation (insert/update/remove) holds this lock from its read to
|
|
70
|
+
// its persisted rename, so no stale revision can slip between the guard
|
|
71
|
+
// check and the write — across processes as well as across store
|
|
72
|
+
// instances. The lock is an atomically published nonempty directory; acquisition
|
|
73
|
+
// retries briefly, recovers abandoned locks by age, then fails explicitly
|
|
74
|
+
// (never silently proceeding unlocked). Re-entry by the SAME process only
|
|
75
|
+
// bumps a counter: the pre-persist re-verification inside update() still
|
|
76
|
+
// rejects a same-process interleaving, so re-entrancy never hides a
|
|
77
|
+
// conflict. Each acquisition has a unique token directory: takeover removes
|
|
78
|
+
// that generation, including its staged writes. Even a holder suspended
|
|
79
|
+
// after its final fence check cannot rename a removed source into the store.
|
|
80
|
+
// Reads stay lock-free: the tmp+rename persistence is atomic,
|
|
81
|
+
// so readers always observe one whole committed file.
|
|
82
|
+
const STORE_LOCK_DIRNAME = ".declarations.lock";
|
|
83
|
+
const STORE_LOCK_TIMEOUT_MS = 5_000;
|
|
84
|
+
const STORE_LOCK_STALE_MS = 10_000;
|
|
85
|
+
const STORE_LOCK_POLL_MS = 5;
|
|
86
|
+
/** Re-entry shares the SAME generation, never a successor's token. */
|
|
87
|
+
const storeLocksHeld = new Map();
|
|
88
|
+
const lockDirFor = (root) => join(root, "live", STORE_LOCK_DIRNAME);
|
|
89
|
+
const sleepSync = (ms) => {
|
|
90
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
91
|
+
};
|
|
92
|
+
/** Remove only the observed generation; never recursively delete a successor. */
|
|
93
|
+
function removeStoreLockGeneration(dir, token) {
|
|
94
|
+
rmSync(join(dir, token), { recursive: true, force: true });
|
|
95
|
+
try {
|
|
96
|
+
rmdirSync(dir);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
const code = error.code;
|
|
100
|
+
if (code !== "ENOENT" && code !== "ENOTEMPTY" && code !== "EEXIST")
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function acquireStoreLock(root) {
|
|
105
|
+
const dir = lockDirFor(root);
|
|
106
|
+
mkdirSync(join(root, "live"), { recursive: true });
|
|
107
|
+
const held = storeLocksHeld.get(dir);
|
|
108
|
+
if (held !== undefined) {
|
|
109
|
+
held.depth += 1;
|
|
110
|
+
return held;
|
|
111
|
+
}
|
|
112
|
+
const deadline = Date.now() + STORE_LOCK_TIMEOUT_MS;
|
|
113
|
+
for (;;) {
|
|
114
|
+
const lock = { token: randomUUID(), depth: 1 };
|
|
115
|
+
const candidate = `${dir}.${lock.token}.candidate`;
|
|
116
|
+
try {
|
|
117
|
+
mkdirSync(candidate, { mode: 0o700 });
|
|
118
|
+
mkdirSync(join(candidate, lock.token), { mode: 0o700 });
|
|
119
|
+
// One atomic publication, with the generation already inside. An
|
|
120
|
+
// existing nonempty lock cannot be replaced by rename. A suspended
|
|
121
|
+
// publisher can never resume by adding its token to a successor.
|
|
122
|
+
renameSync(candidate, dir);
|
|
123
|
+
storeLocksHeld.set(dir, lock);
|
|
124
|
+
return lock;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
const code = error.code;
|
|
128
|
+
if (code !== "EEXIST" && code !== "ENOENT" && code !== "ENOTEMPTY")
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
rmSync(candidate, { recursive: true, force: true });
|
|
133
|
+
}
|
|
134
|
+
// Age permits takeover, but does NOT prove the holder stopped. Invalidate
|
|
135
|
+
// only the generation observed before the age check. A competing cleanup
|
|
136
|
+
// cannot erase a newly acquired token or its staged write.
|
|
137
|
+
try {
|
|
138
|
+
const tokens = readdirSync(dir);
|
|
139
|
+
if (Date.now() - statSync(dir).mtimeMs > STORE_LOCK_STALE_MS) {
|
|
140
|
+
for (const token of tokens)
|
|
141
|
+
removeStoreLockGeneration(dir, token);
|
|
142
|
+
if (tokens.length === 0)
|
|
143
|
+
rmdirSync(dir);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// The directory vanished under us; the next iteration retries.
|
|
148
|
+
}
|
|
149
|
+
if (Date.now() >= deadline) {
|
|
150
|
+
throw new Error(`live declarations store busy: cannot acquire lock at ${dir}`);
|
|
151
|
+
}
|
|
152
|
+
sleepSync(STORE_LOCK_POLL_MS);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function releaseStoreLock(root) {
|
|
156
|
+
const dir = lockDirFor(root);
|
|
157
|
+
const held = storeLocksHeld.get(dir);
|
|
158
|
+
if (held === undefined)
|
|
159
|
+
return;
|
|
160
|
+
if (held.depth > 1) {
|
|
161
|
+
held.depth -= 1;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
storeLocksHeld.delete(dir);
|
|
165
|
+
removeStoreLockGeneration(dir, held.token);
|
|
166
|
+
}
|
|
167
|
+
function withStoreLock(root, fn) {
|
|
168
|
+
const lock = acquireStoreLock(root);
|
|
169
|
+
try {
|
|
170
|
+
return fn(lock);
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
releaseStoreLock(root);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** Structural validation of a record: envelope, triangle consistency, then the engram validators. */
|
|
177
|
+
const validateRecord = (record) => {
|
|
178
|
+
if (record.kind !== LIVE_DECLARATION_KIND)
|
|
179
|
+
return "unexpected declaration kind";
|
|
180
|
+
if (record.schemaVersion !== LIVE_DECLARATION_SCHEMA_VERSION) {
|
|
181
|
+
return "unsupported declaration schema version";
|
|
182
|
+
}
|
|
183
|
+
const declaration = validateWorkspaceDeclaration(record.declaration);
|
|
184
|
+
if (!declaration.ok)
|
|
185
|
+
return `invalid declaration: ${declaration.errors.join("; ")}`;
|
|
186
|
+
if (record.clone.cloneId !== record.declaration.cloneId) {
|
|
187
|
+
return "clone/worktree attachment mismatch: clone.cloneId differs from declaration.cloneId";
|
|
188
|
+
}
|
|
189
|
+
if (record.worktree.cloneId !== record.declaration.cloneId) {
|
|
190
|
+
return "clone/worktree attachment mismatch: worktree.cloneId differs from declaration.cloneId";
|
|
191
|
+
}
|
|
192
|
+
if (record.worktree.worktreeId !== record.declaration.worktreeId) {
|
|
193
|
+
return "clone/worktree attachment mismatch: worktree.worktreeId differs from declaration.worktreeId";
|
|
194
|
+
}
|
|
195
|
+
const clone = validateCloneIdentity(record.clone);
|
|
196
|
+
if (!clone.ok)
|
|
197
|
+
return `invalid clone identity: ${clone.errors.join("; ")}`;
|
|
198
|
+
const worktree = validateWorktreeIdentity(record.worktree);
|
|
199
|
+
if (!worktree.ok)
|
|
200
|
+
return `invalid worktree identity: ${worktree.errors.join("; ")}`;
|
|
201
|
+
for (const field of ["createdAt", "activatedAt", "updatedAt"]) {
|
|
202
|
+
if (typeof record[field] !== "string" || record[field].length === 0) {
|
|
203
|
+
return `missing ${field}`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
};
|
|
208
|
+
const isRecord = (value) => {
|
|
209
|
+
if (typeof value !== "object" || value === null)
|
|
210
|
+
return false;
|
|
211
|
+
const record = value;
|
|
212
|
+
if (record.kind !== LIVE_DECLARATION_KIND ||
|
|
213
|
+
record.schemaVersion !== LIVE_DECLARATION_SCHEMA_VERSION ||
|
|
214
|
+
typeof record.declaration !== "object" ||
|
|
215
|
+
record.declaration === null ||
|
|
216
|
+
typeof record.clone !== "object" ||
|
|
217
|
+
record.clone === null ||
|
|
218
|
+
typeof record.worktree !== "object" ||
|
|
219
|
+
record.worktree === null ||
|
|
220
|
+
typeof record.declaration.declarationId !== "string") {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
return validateRecord(record) === undefined;
|
|
224
|
+
};
|
|
225
|
+
/** Pre-realignment entries (nested shape, top-level hostScope/revision, no neutral DTO) are never read as records. */
|
|
226
|
+
const isLegacyRecord = (value) => {
|
|
227
|
+
if (typeof value !== "object" || value === null)
|
|
228
|
+
return false;
|
|
229
|
+
const record = value;
|
|
230
|
+
return ("hostScope" in record ||
|
|
231
|
+
("declarationId" in record && !("declaration" in record)));
|
|
232
|
+
};
|
|
233
|
+
/** Durable declarations live under the injected h2a root, never a worktree. */
|
|
234
|
+
export function liveDeclarationsPath(root) {
|
|
235
|
+
return join(root, "live", "declarations.json");
|
|
236
|
+
}
|
|
237
|
+
const readStoreFile = (root) => {
|
|
238
|
+
const path = liveDeclarationsPath(root);
|
|
239
|
+
if (!existsSync(path)) {
|
|
240
|
+
return { kind: "h2a-live-declarations", version: 1, declarations: [] };
|
|
241
|
+
}
|
|
242
|
+
let parsed;
|
|
243
|
+
try {
|
|
244
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
// Explicit failure: a corrupt declaration store must never be treated
|
|
248
|
+
// as an empty registry (LIVE §12: database loss must not erase live
|
|
249
|
+
// registrations; silent loss is worse).
|
|
250
|
+
throw new Error(`live declarations store unreadable at ${path}: ${error.message}`);
|
|
251
|
+
}
|
|
252
|
+
if (typeof parsed !== "object" ||
|
|
253
|
+
parsed === null ||
|
|
254
|
+
parsed.kind !== "h2a-live-declarations" ||
|
|
255
|
+
parsed.version !== 1 ||
|
|
256
|
+
!Array.isArray(parsed.declarations)) {
|
|
257
|
+
throw new Error(`live declarations store invalid at ${path}`);
|
|
258
|
+
}
|
|
259
|
+
const file = parsed;
|
|
260
|
+
for (const entry of file.declarations) {
|
|
261
|
+
if (isLegacyRecord(entry)) {
|
|
262
|
+
throw new Error(`live declarations store uses the pre-realignment L6a format at ${path}: ` +
|
|
263
|
+
`remove the file to start fresh (L6a is not consumed yet; no migration replay exists)`);
|
|
264
|
+
}
|
|
265
|
+
if (!isRecord(entry)) {
|
|
266
|
+
throw new Error(`live declarations store contains a malformed declaration at ${path}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return file;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* A store instance is a thin read-through over the durable file: every
|
|
273
|
+
* operation re-reads, so two instances (or two processes) on the same root
|
|
274
|
+
* observe each other's committed writes.
|
|
275
|
+
*/
|
|
276
|
+
export function createLiveDeclarationStore(root) {
|
|
277
|
+
const load = () => readStoreFile(root).declarations;
|
|
278
|
+
const persist = (lock, expected, declarations, declarationId, expectedRevision) => {
|
|
279
|
+
const generation = join(lockDirFor(root), lock.token);
|
|
280
|
+
const tmp = join(generation, `${randomUUID()}.tmp`);
|
|
281
|
+
const conflict = () => new LiveRevisionConflict(declarationId, expectedRevision, load().find((record) => record.declaration.declarationId === declarationId)
|
|
282
|
+
?.declaration.declarationRevision);
|
|
283
|
+
const file = {
|
|
284
|
+
kind: "h2a-live-declarations",
|
|
285
|
+
version: 1,
|
|
286
|
+
declarations: [...declarations],
|
|
287
|
+
};
|
|
288
|
+
try {
|
|
289
|
+
if (!existsSync(generation))
|
|
290
|
+
throw conflict();
|
|
291
|
+
// The source belongs to this unique token and cannot survive takeover.
|
|
292
|
+
// Never mkdir here: a dispossessed holder must not recreate its source.
|
|
293
|
+
writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n", { mode: 0o600, flag: "wx" });
|
|
294
|
+
const fresh = load();
|
|
295
|
+
if (!existsSync(generation) || JSON.stringify(fresh) !== JSON.stringify(expected)) {
|
|
296
|
+
throw conflict();
|
|
297
|
+
}
|
|
298
|
+
// Atomic rename is the commit point. A suspension AFTER the checks
|
|
299
|
+
// above is fenced by takeover removing this generation's source file.
|
|
300
|
+
renameSync(tmp, liveDeclarationsPath(root));
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
// Cleanup can unlink the source before removing its directory.
|
|
304
|
+
if (error.code === "ENOENT" || !existsSync(generation)) {
|
|
305
|
+
throw conflict();
|
|
306
|
+
}
|
|
307
|
+
throw error;
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
rmSync(tmp, { force: true });
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
return {
|
|
314
|
+
list() {
|
|
315
|
+
return [...load()].sort((a, b) => a.declaration.declarationId < b.declaration.declarationId
|
|
316
|
+
? -1
|
|
317
|
+
: a.declaration.declarationId > b.declaration.declarationId
|
|
318
|
+
? 1
|
|
319
|
+
: 0);
|
|
320
|
+
},
|
|
321
|
+
get(declarationId) {
|
|
322
|
+
return load().find((record) => record.declaration.declarationId === declarationId);
|
|
323
|
+
},
|
|
324
|
+
findByPath(path) {
|
|
325
|
+
return load().find((record) => record.declaration.authorizedRoots.includes(path));
|
|
326
|
+
},
|
|
327
|
+
insert(record) {
|
|
328
|
+
const problem = validateRecord(record);
|
|
329
|
+
if (problem !== undefined) {
|
|
330
|
+
throw new Error(`invalid live declaration record: ${problem}`);
|
|
331
|
+
}
|
|
332
|
+
withStoreLock(root, (lock) => {
|
|
333
|
+
const declarations = load();
|
|
334
|
+
if (declarations.some((existing) => existing.declaration.declarationId === record.declaration.declarationId)) {
|
|
335
|
+
throw new Error(`live declaration already exists: ${record.declaration.declarationId}`);
|
|
336
|
+
}
|
|
337
|
+
persist(lock, declarations, [...declarations, record], record.declaration.declarationId, record.declaration.declarationRevision);
|
|
338
|
+
});
|
|
339
|
+
},
|
|
340
|
+
update(declarationId, expectedDeclarationRevision, mutate) {
|
|
341
|
+
return withStoreLock(root, (lock) => {
|
|
342
|
+
const declarations = load();
|
|
343
|
+
const index = declarations.findIndex((record) => record.declaration.declarationId === declarationId);
|
|
344
|
+
if (index === -1) {
|
|
345
|
+
throw new Error(`unknown live declaration: ${declarationId}`);
|
|
346
|
+
}
|
|
347
|
+
const current = declarations[index];
|
|
348
|
+
if (current.declaration.declarationRevision !== expectedDeclarationRevision) {
|
|
349
|
+
throw new LiveRevisionConflict(declarationId, expectedDeclarationRevision, current.declaration.declarationRevision);
|
|
350
|
+
}
|
|
351
|
+
const next = mutate(current);
|
|
352
|
+
if (next.declaration.declarationId !== declarationId) {
|
|
353
|
+
throw new Error(`update must not change declarationId: ${declarationId}`);
|
|
354
|
+
}
|
|
355
|
+
if (next.declaration.declarationRevision !== expectedDeclarationRevision + 1) {
|
|
356
|
+
throw new Error(`update must advance declarationRevision by exactly one: held ${expectedDeclarationRevision}`);
|
|
357
|
+
}
|
|
358
|
+
for (const field of [
|
|
359
|
+
"tenant",
|
|
360
|
+
"principal",
|
|
361
|
+
"hostFingerprint",
|
|
362
|
+
"cloneId",
|
|
363
|
+
"worktreeId",
|
|
364
|
+
"liveCapability",
|
|
365
|
+
]) {
|
|
366
|
+
if (next.declaration[field] !== current.declaration[field]) {
|
|
367
|
+
throw new Error(`update must not change declaration identity field "${field}": ${declarationId}`);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
// Binding renewal-or-preserved: a workspace/issuer/revision change
|
|
371
|
+
// renews the binding (complete triplet, first binding exactly
|
|
372
|
+
// INITIAL_BINDING_REVISION, then strictly greater); any other
|
|
373
|
+
// mutation preserves it.
|
|
374
|
+
const previous = current.declaration;
|
|
375
|
+
const candidate = next.declaration;
|
|
376
|
+
const workspaceChanged = candidate.serverWorkspaceId !== previous.serverWorkspaceId;
|
|
377
|
+
const issuerChanged = candidate.serverIssuer !== previous.serverIssuer;
|
|
378
|
+
const revisionTouched = candidate.bindingRevision !== previous.bindingRevision;
|
|
379
|
+
if (workspaceChanged || issuerChanged || revisionTouched) {
|
|
380
|
+
if (candidate.serverWorkspaceId === undefined ||
|
|
381
|
+
candidate.serverIssuer === undefined ||
|
|
382
|
+
candidate.bindingRevision === undefined) {
|
|
383
|
+
throw new Error(`update must carry the complete serverWorkspaceId + serverIssuer + bindingRevision triplet when the binding changes: ${declarationId}`);
|
|
384
|
+
}
|
|
385
|
+
if (previous.bindingRevision === undefined) {
|
|
386
|
+
if (candidate.bindingRevision !== INITIAL_BINDING_REVISION) {
|
|
387
|
+
throw new Error(`update must carry bindingRevision ${INITIAL_BINDING_REVISION} for the first product binding: ${declarationId}`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else if (candidate.bindingRevision <= previous.bindingRevision) {
|
|
391
|
+
throw new Error(`update must carry a strictly increasing bindingRevision: ${declarationId}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const problem = validateRecord(next);
|
|
395
|
+
if (problem !== undefined) {
|
|
396
|
+
throw new Error(`invalid updated live declaration record: ${problem}`);
|
|
397
|
+
}
|
|
398
|
+
// Atomic compare-and-write under the same lock: re-read the durable
|
|
399
|
+
// file and refuse when the declaration moved (a concurrent writer
|
|
400
|
+
// committed inside mutate()) or vanished (an interleaved removal).
|
|
401
|
+
// The merge applies onto the FRESH list, so unrelated concurrent
|
|
402
|
+
// records are never dropped; a stale write never clobbers and a
|
|
403
|
+
// removed declaration never resurrects.
|
|
404
|
+
const fresh = load();
|
|
405
|
+
const refetch = fresh.find((record) => record.declaration.declarationId === declarationId);
|
|
406
|
+
if (refetch === undefined) {
|
|
407
|
+
throw new LiveRevisionConflict(declarationId, expectedDeclarationRevision, undefined);
|
|
408
|
+
}
|
|
409
|
+
if (refetch.declaration.declarationRevision !== expectedDeclarationRevision) {
|
|
410
|
+
throw new LiveRevisionConflict(declarationId, expectedDeclarationRevision, refetch.declaration.declarationRevision);
|
|
411
|
+
}
|
|
412
|
+
persist(lock, fresh, fresh.map((record) => record.declaration.declarationId === declarationId ? next : record), declarationId, expectedDeclarationRevision);
|
|
413
|
+
return next;
|
|
414
|
+
});
|
|
415
|
+
},
|
|
416
|
+
remove(declarationId) {
|
|
417
|
+
return withStoreLock(root, (lock) => {
|
|
418
|
+
const declarations = load();
|
|
419
|
+
const remaining = declarations.filter((record) => record.declaration.declarationId !== declarationId);
|
|
420
|
+
if (remaining.length === declarations.length)
|
|
421
|
+
return false;
|
|
422
|
+
persist(lock, declarations, remaining, declarationId, declarations.find((record) => record.declaration.declarationId === declarationId)
|
|
423
|
+
.declaration.declarationRevision);
|
|
424
|
+
return true;
|
|
425
|
+
});
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
//# sourceMappingURL=live-declarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-declarations.js","sourceRoot":"","sources":["../../src/gateway-host/live-declarations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAO5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAC5D,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,aAAa,CAAS;IACtB,2BAA2B,CAAS;IAC7C,wEAAwE;IAC/D,yBAAyB,CAAqB;IAEvD,YACE,aAAqB,EACrB,2BAAmC,EACnC,yBAA6C;QAE7C,KAAK,CACH,yBAAyB,KAAK,SAAS;YACrC,CAAC,CAAC,uCAAuC,aAAa,wDAAwD,2BAA2B,EAAE;YAC3I,CAAC,CAAC,uCAAuC,aAAa,8BAA8B;gBAChF,GAAG,yBAAyB,uBAAuB,2BAA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EAAE;gBAClC,MAAM,YAAY,GAAG,IAAI,EAAE,CAAC;gBAC5B,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CACnC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,KAAK,aAAa,CAC/D,CAAC;gBACF,IAAI,SAAS,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;oBAAE,OAAO,KAAK,CAAC;gBAC3D,OAAO,CACL,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAC5C,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,KAAK,aAAa,CAAE;qBAC/E,WAAW,CAAC,mBAAmB,CACnC,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GithubPrTransportPort } from "../vendor/engram-live/pr-sync.js";
|
|
2
|
+
export interface LiveGithubOptions {
|
|
3
|
+
readonly ghPath: string;
|
|
4
|
+
readonly hostDirectory: string;
|
|
5
|
+
readonly timeoutMs?: number;
|
|
6
|
+
readonly maxConcurrent?: number;
|
|
7
|
+
readonly now?: () => number;
|
|
8
|
+
}
|
|
9
|
+
/** The caller owns scheduling/durable backoff; a single call never sleeps. */
|
|
10
|
+
export declare function createLiveGithubTransport(options: LiveGithubOptions): GithubPrTransportPort;
|
|
11
|
+
//# sourceMappingURL=live-github.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-github.d.ts","sourceRoot":"","sources":["../../src/gateway-host/live-github.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,qBAAqB,EAAoC,MAAM,kCAAkC,CAAC;AAEhH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AA8KD,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,qBAAqB,CAyH3F"}
|