@hearsay-tools/squawk 0.18.0-dev.7816 → 0.18.0-dev.7820

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/activity/publisher.js +2 -2
  2. package/dist/activity/publisher.js.map +1 -1
  3. package/dist/activity/read-model.js +1 -1
  4. package/dist/activity/read-model.js.map +1 -1
  5. package/dist/activity/requests.d.ts +4 -2
  6. package/dist/activity/requests.js +1 -1
  7. package/dist/activity/requests.js.map +1 -1
  8. package/dist/artifacts/reports-index.d.ts +2 -1
  9. package/dist/artifacts/reports-index.js +1 -1
  10. package/dist/artifacts/reports-index.js.map +1 -1
  11. package/dist/ci-wait/controller.d.ts +46 -46
  12. package/dist/delegation/conversations.d.ts +6 -2
  13. package/dist/delegation/conversations.js +3 -2
  14. package/dist/delegation/conversations.js.map +1 -1
  15. package/dist/delegation/family-end.d.ts +4 -2
  16. package/dist/delegation/results.js +2 -2
  17. package/dist/delegation/results.js.map +1 -1
  18. package/dist/delegation/routes.d.ts +10 -10
  19. package/dist/delegation/routes.js +1 -1
  20. package/dist/delegation/routes.js.map +1 -1
  21. package/dist/delegation/scratch-cleanup.js +2 -2
  22. package/dist/delegation/scratch-cleanup.js.map +1 -1
  23. package/dist/delegation/service.js +2 -2
  24. package/dist/delegation/service.js.map +1 -1
  25. package/dist/delegation/transport.d.ts +79 -79
  26. package/dist/delegation/worker-cleanup.js +1 -1
  27. package/dist/delegation/worker-cleanup.js.map +1 -1
  28. package/dist/preview/host.d.ts +2 -1
  29. package/dist/preview/host.js +1 -1
  30. package/dist/preview/host.js.map +1 -1
  31. package/dist/project-migration/live.js +3 -3
  32. package/dist/project-migration/live.js.map +1 -1
  33. package/dist/runs/claim-families.d.ts +1 -1
  34. package/dist/runs/claim-families.js +1 -1
  35. package/dist/runs/live-tasks.js +1 -1
  36. package/dist/runs/live-tasks.js.map +1 -1
  37. package/dist/runs/loaded-run-exits.d.ts +23 -0
  38. package/dist/runs/loaded-run-exits.js +46 -1
  39. package/dist/runs/loaded-run-exits.js.map +1 -1
  40. package/dist/runs/ports.d.ts +27 -13
  41. package/dist/runs/retention.d.ts +3 -1
  42. package/dist/runs/retention.js +5 -5
  43. package/dist/runs/retention.js.map +1 -1
  44. package/dist/runs/run-claims-topic.d.ts +130 -0
  45. package/dist/runs/run-claims-topic.js +258 -0
  46. package/dist/runs/run-claims-topic.js.map +1 -0
  47. package/dist/runs/run-claims.d.ts +1 -1
  48. package/dist/runs/run-claims.js +1 -1
  49. package/dist/runs/run-claims.js.map +1 -1
  50. package/dist/runs/run-database.d.ts +1 -1
  51. package/dist/runs/run-index.js +3 -1
  52. package/dist/runs/run-index.js.map +1 -1
  53. package/dist/runs/run-pins.d.ts +38 -0
  54. package/dist/runs/run-pins.js +45 -0
  55. package/dist/runs/run-pins.js.map +1 -0
  56. package/dist/runs/run-references.d.ts +1 -1
  57. package/dist/runs/run-references.js +1 -1
  58. package/dist/runs/run-references.js.map +1 -1
  59. package/dist/runs/store-open.d.ts +45 -0
  60. package/dist/runs/store-open.js +89 -0
  61. package/dist/runs/store-open.js.map +1 -0
  62. package/dist/runs/store.d.ts +6 -139
  63. package/dist/runs/store.js +44 -417
  64. package/dist/runs/store.js.map +1 -1
  65. package/dist/runs/webhook.d.ts +3 -1
  66. package/dist/runs/webhook.js +2 -2
  67. package/dist/runs/webhook.js.map +1 -1
  68. package/dist/serve-boot.d.ts +2 -2
  69. package/dist/server/completion-actions.js +2 -2
  70. package/dist/server/completion-actions.js.map +1 -1
  71. package/dist/server/models-routes.d.ts +13 -13
  72. package/dist/server/project-run-files.d.ts +3 -1
  73. package/dist/server/project-run-files.js +3 -3
  74. package/dist/server/project-run-files.js.map +1 -1
  75. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  76. package/dist/server/reports-api.d.ts +2 -2
  77. package/dist/server/run-checkout.d.ts +3 -1
  78. package/dist/server/run-checkout.js +3 -3
  79. package/dist/server/run-checkout.js.map +1 -1
  80. package/dist/server/run-event-feed.js +2 -2
  81. package/dist/server/run-event-feed.js.map +1 -1
  82. package/dist/server/runner-install-routes.d.ts +10 -10
  83. package/dist/server/server.d.ts +1648 -1648
  84. package/dist/server/server.js +9 -9
  85. package/dist/server/server.js.map +1 -1
  86. package/dist/server/workspace-live-routes.d.ts +6 -6
  87. package/dist/workflows/run/family-reconciler.js +2 -2
  88. package/dist/workflows/run/family-reconciler.js.map +1 -1
  89. package/dist/workflows/run/maintenance-claims.js +6 -6
  90. package/dist/workflows/run/maintenance-claims.js.map +1 -1
  91. package/dist/workflows/run/run-cancel.js +1 -1
  92. package/dist/workflows/run/run-cancel.js.map +1 -1
  93. package/dist/workflows/run/run-recovery.js +3 -3
  94. package/dist/workflows/run/run-recovery.js.map +1 -1
  95. package/dist/workflows/run/run-settlement.js +1 -1
  96. package/dist/workflows/run/run-settlement.js.map +1 -1
  97. package/dist/workflows/run.js +7 -7
  98. package/dist/workflows/run.js.map +1 -1
  99. package/package.json +4 -4
  100. package/scripts/benchmark-run-store.ts +2 -2
@@ -0,0 +1,89 @@
1
+ /**
2
+ * What `RunStore.open` does besides building the store (hearsay-tools/squawk#4042): the pauses
3
+ * between busy open attempts, the one-time import of a legacy `runs.json`, and the SQL that picks
4
+ * the rows open repairs. `open` and `openOnce` stay on `RunStore` as its constructors.
5
+ */
6
+ import { join } from 'node:path';
7
+ import { guardedJsonSql } from './guarded-json-sql.js';
8
+ import { assertNoLegacyCockpit, assertNoLegacyWriter, backUpLegacyIndex, LEGACY_INDEX_FILE, readLegacyIndex } from './legacy-index.js';
9
+ import { legacyIndexRows } from './legacy-run-rows.js';
10
+ import { RUNS_IMPORT_COMPLETE_KEY } from './run-database.js';
11
+ /** The pauses between open attempts while the database is busy, when `open` may wait (a boot):
12
+ * about 3.5 s in all, with each attempt's own busy timeout. Long enough for another process to
13
+ * finish importing a large `runs.json`. */
14
+ export const OPEN_RETRY_DELAYS_MS = [50, 100, 200, 400, 800, 1600];
15
+ /** Block this thread for `ms`. Only `open` does, at boot, when there is nothing else to run. */
16
+ export function sleepSync(ms) {
17
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
18
+ }
19
+ /** Test seam (#779): `beforeTransaction` runs once `runs.json` is read and parsed, before the
20
+ * import asks for the write lock; `beforeCommit` runs inside the import transaction, after every
21
+ * row is written and before the last check that no older Squawk wrote `runs.json` meanwhile. */
22
+ let legacyImportHook;
23
+ export function __setLegacyImportHookForTests(hook) {
24
+ legacyImportHook = hook;
25
+ }
26
+ /**
27
+ * Import legacy rows and the completion marker atomically, once. Recheck live-writer evidence
28
+ * before commit and preserve exact input bytes in a synced backup. Leave runs.json untouched;
29
+ * invalid entries are skipped and reported.
30
+ */
31
+ export function importLegacyIndex(db, dataDir, parseRunRecords) {
32
+ assertNoLegacyCockpit(dataDir);
33
+ const snapshot = readLegacyIndex(join(dataDir, LEGACY_INDEX_FILE));
34
+ const parsed = snapshot ? legacyIndexRows(snapshot.bytes, parseRunRecords) : undefined;
35
+ const rows = parsed?.rows ?? [];
36
+ const skipped = parsed?.skipped ?? 0;
37
+ const source = !snapshot ? 'none' : parsed ? LEGACY_INDEX_FILE : `${LEGACY_INDEX_FILE} (unparseable)`;
38
+ assertNoLegacyWriter(dataDir, snapshot);
39
+ legacyImportHook?.beforeTransaction?.();
40
+ let backup;
41
+ const commit = db.transaction({
42
+ upserts: rows,
43
+ deletes: [],
44
+ onlyIfMetaAbsent: RUNS_IMPORT_COMPLETE_KEY,
45
+ beforeCommit: () => {
46
+ legacyImportHook?.beforeCommit?.();
47
+ assertNoLegacyWriter(dataDir, snapshot);
48
+ backup = snapshot ? backUpLegacyIndex(dataDir, snapshot) : undefined;
49
+ const read = snapshot ? { bytes: snapshot.bytes.length, sha256: snapshot.sha256, backup } : {};
50
+ return { [RUNS_IMPORT_COMPLETE_KEY]: JSON.stringify({ at: new Date().toISOString(), source, records: rows.length, ...(skipped > 0 ? { skipped } : {}), ...read }) };
51
+ },
52
+ });
53
+ // Told once, by the import that committed: the marker means no later open reads runs.json again.
54
+ if (commit.skipped || backup === undefined)
55
+ return;
56
+ const kept = `Its exact bytes are kept in ${join(dataDir, backup)}; https://github.com/hearsay-tools/squawk/blob/main/docs/run-history-recovery.md says how to import it after a repair.`;
57
+ if (!parsed)
58
+ console.warn(`[hsq] ${LEGACY_INDEX_FILE} could not be read; no run was imported, and this project starts with an empty history. ${kept}`);
59
+ else if (skipped > 0)
60
+ console.warn(`[hsq] ${skipped} of ${parsed.total} runs in ${LEGACY_INDEX_FILE} could not be read and were not imported. ${kept}`);
61
+ }
62
+ /**
63
+ * Finished rows whose stored summary an open-time normalization would still change: a referenced
64
+ * PR an older Squawk's created-PR declaration erased, or issue attribution displaced by a
65
+ * follow-up declaration (see `reconcileLoadedRun`), or a summary that is not JSON. Not live, so not
66
+ * in the `live` column; open decodes these few and keeps the ones it actually repaired.
67
+ */
68
+ export const LEGACY_REFERENCE_HEAL_SQL = guardedJsonSql("(json_extract(summary, '$.markerRefs.pr') IS NOT NULL AND json_extract(summary, '$.referencedPullRequestUrl') IS NULL)" +
69
+ " OR (NOT EXISTS (SELECT 1 FROM meta WHERE key = 'issue-attribution:' || runs.id AND value = CAST(runs.revision AS TEXT)) AND json_extract(summary, '$.markerRefs.issue') IS NOT NULL)", 1);
70
+ /**
71
+ * The rows whose stored summary reading their record can change, as SQL over `runs`: the rows
72
+ * `open` decodes to normalize (the `live` column it loads by, then `LEGACY_REFERENCE_HEAL_SQL`).
73
+ * With a repository handle, a row whose summary `namesForeignReference` is one too, as
74
+ * `setRepoHandle` reads it. The cold reader (run-index.ts) decodes exactly these rows and serves
75
+ * every other stored summary, so the two read paths cannot disagree about which rows to read.
76
+ * `AUTOMATION_ORIGIN_HEAL_SQL` is left out on purpose: no cross-project view reads
77
+ * `automationId`, and asking it scans `data`.
78
+ */
79
+ export const LOAD_REPAIR_SQL = `live = 1 OR ${LEGACY_REFERENCE_HEAL_SQL}`;
80
+ /**
81
+ * Rows whose record names the automation that launched it while the stored summary does not
82
+ * (hearsay-tools/cezarion#1332): summaries a Squawk wrote before `RunSummary.automationId`
83
+ * existed. Open rewrites each one's summary once, so the sidebar's Automations tab classifies a
84
+ * finished task nobody has opened since the upgrade. `instr` keeps the JSON parse off every
85
+ * other row.
86
+ */
87
+ export const AUTOMATION_ORIGIN_HEAL_SQL = `instr(data, '"automation') > 0 AND ${guardedJsonSql("json_extract(summary, '$.automationId') IS NULL" +
88
+ " AND (json_extract(data, '$.automation.automationId') IS NOT NULL OR json_extract(data, '$.automationTrigger.automationId') IS NOT NULL)", 0, ['summary', 'data'])}`;
89
+ //# sourceMappingURL=store-open.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-open.js","sourceRoot":"","sources":["../../src/runs/store-open.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvI,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAoB,MAAM,mBAAmB,CAAC;AAK/E;;4CAE4C;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AAEnE,gGAAgG;AAChG,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAED;;iGAEiG;AACjG,IAAI,gBAA2F,CAAC;AAEhG,MAAM,UAAU,6BAA6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,EAAE,CAAC"}
@@ -19,6 +19,8 @@ export { ciWaitEntry, holdsWorkerWait, upgradeLegacyWaits, workerWaitEntry } fro
19
19
  import { RunRetentionTopic } from './run-retention.ts';
20
20
  import { type RawExtras } from './raw-record.ts';
21
21
  import { RunStoreOpenError } from './store-open-error.ts';
22
+ import { RunClaimsTopic } from './run-claims-topic.ts';
23
+ import { RunPinsTopic } from './run-pins.ts';
22
24
  import { type SpawnCapacityRefusal } from './owned-run-create.ts';
23
25
  import { WorkerResultsTopic } from './worker-results.ts';
24
26
  import { RunEventLogTopic } from './event-log.ts';
@@ -3168,71 +3170,7 @@ export type RepoHandle = {
3168
3170
  owner: string;
3169
3171
  name: string;
3170
3172
  };
3171
- /**
3172
- * Reconcile one record just read off disk with the fact that whichever process wrote it is gone.
3173
- *
3174
- * Mutates and returns `run`. Extracted from `RunStore.open` so the read-only index reader
3175
- * (`./run-index.ts`) answers the SAME question about a `running` row on disk. Two parsers that
3176
- * disagree here is a visible bug, not an internal one: the cockpit would show a task as running
3177
- * in the ⌘K index and failed the moment you opened it.
3178
- *
3179
- * `keepLive` (#367): leave `queued`/`running`/`waiting` untouched so the caller can recover them
3180
- * (RunManager.recover re-queues queued runs, resumes interrupted ones). Without it — one-shot CLI
3181
- * paths that never recover, and the index reader, which has no manager at all — live-looking runs
3182
- * are marked failed so no ghost stays behind.
3183
- */
3184
- export declare function reconcileLoadedRun(run: RunRecord, opts?: {
3185
- keepLive?: boolean;
3186
- }): RunRecord;
3187
- /**
3188
- * Settle an adopted dead owner’s live run without starting work. Untouched runs cancel; started
3189
- * runs become interrupted. Stop explicitly cancels its target. Mutates run.
3190
- */
3191
- export declare function settleOrphanedRun(run: RunRecord, opts?: {
3192
- stop?: boolean | undefined;
3193
- }): RunRecord;
3194
- export declare function __setLegacyImportHookForTests(hook?: {
3195
- beforeTransaction?: () => void;
3196
- beforeCommit?: () => void;
3197
- }): void;
3198
- /**
3199
- * The rows whose stored summary reading their record can change, as SQL over `runs`: the rows
3200
- * `open` decodes to normalize (the `live` column it loads by, then `LEGACY_REFERENCE_HEAL_SQL`).
3201
- * With a repository handle, a row whose summary `namesForeignReference` is one too, as
3202
- * `setRepoHandle` reads it. The cold reader (run-index.ts) decodes exactly these rows and serves
3203
- * every other stored summary, so the two read paths cannot disagree about which rows to read.
3204
- * `AUTOMATION_ORIGIN_HEAL_SQL` is left out on purpose: no cross-project view reads
3205
- * `automationId`, and asking it scans `data`.
3206
- */
3207
- export declare const LOAD_REPAIR_SQL: string;
3208
3173
  export { branchOwnerOf, type BranchOwner } from './branch-owners.ts';
3209
- /** Who may hold a run in memory besides its own record (see `RunStore.pin`). `maintenance` is the
3210
- * RunManager's publish, worktree-reclaim and branch-cleanup claims, held across their async work. */
3211
- export type RunPinHolder = 'active' | 'continue' | 'cleanup' | 'maintenance';
3212
- /**
3213
- * Who may change a run, as this store sees it (#779, plan step 3; `RunStore.runOwnership`):
3214
- * - `held`: this store claims its delegation family;
3215
- * - `free`: no live process claims it and nothing in its family is live; a write takes it. A
3216
- * proven-dead owner's claim on such a family counts for nothing: there is nothing to recover;
3217
- * - `orphaned`: nobody alive owns a family that still has a live run (its owner died, or nobody
3218
- * claimed it): taking it means adopting it first (`RunStore.adoptFamily` settles it, then the
3219
- * manager recovers the family);
3220
- * - `foreign`: another process that is alive (or cannot be proven dead) holds it: read-only here;
3221
- * - `quarantined`: a write found it changed under this store; refused until Squawk restarts;
3222
- * - `fallback`: a family member is read from the fallback directory: refused as `foreign` until a control adopts it.
3223
- */
3224
- export type RunOwnership = 'held' | 'free' | 'orphaned' | 'foreign' | 'quarantined' | 'fallback';
3225
- /** The one answer every control gives for a run another Squawk process owns (`409 { error }`). */
3226
- export declare const RUN_IN_USE_ELSEWHERE = "run is in use by another Squawk process";
3227
- /** The answer for a run this process stopped writing after a conflicting write. */
3228
- export declare const RUN_QUARANTINED = "run changed under this Squawk process \u2014 restart Squawk to reload it";
3229
- /** A write this store must not make: another process owns the run, its owner died with work
3230
- * still live (adopt it first), or a conflict quarantined it. Nothing was changed. */
3231
- export declare class RunWriteRefusedError extends Error {
3232
- readonly runId: string;
3233
- readonly ownership: Exclude<RunOwnership, 'held' | 'free'>;
3234
- constructor(runId: string, ownership: Exclude<RunOwnership, 'held' | 'free'>, fallbackError?: string);
3235
- }
3236
3174
  /** Why a `run` event fired, when a delegation checkpoint caused it or nothing durable changed
3237
3175
  * (`republish`) (in-process only). */
3238
3176
  export type CommitSource = 'delegation-checkpoint' | 'delegation-destroy-progress' | 'live-release';
@@ -3318,6 +3256,10 @@ export declare class RunStore {
3318
3256
  readonly eventLog: RunEventLogTopic;
3319
3257
  /** The scrub of events and free text (hearsay-tools/squawk#4040). */
3320
3258
  readonly redaction: RunRedaction;
3259
+ /** Claims, ownership, sources and fallback (hearsay-tools/squawk#4042). */
3260
+ readonly claims: RunClaimsTopic;
3261
+ /** The holds that keep a run loaded (hearsay-tools/squawk#4042). */
3262
+ readonly runPins: RunPinsTopic;
3321
3263
  private executions;
3322
3264
  /** A worker's execution, process, identity and scope records (hearsay-tools/squawk#4039), built on
3323
3265
  * first use by the factory this process registered; throws when none is registered. */
@@ -3370,69 +3312,6 @@ export declare class RunStore {
3370
3312
  /** Why this store has no database, when it is `RunStore.unavailable`'s: its runs are unknown,
3371
3313
  * not absent. */
3372
3314
  get unavailable(): RunStoreOpenError | undefined;
3373
- /** Every sidecar for a run follows the winning record, never file-by-file fallback. */
3374
- sourceDataDir(id: string): string;
3375
- isFallbackRun(id: string): boolean;
3376
- hasFallbackRun(id: string): boolean;
3377
- /**
3378
- * Open-time load: the live rows, the finished rows a load normalization repairs, then the
3379
- * delegation families of the live ones. A row that does not parse is skipped and left in the
3380
- * database untouched; one warning says how many.
3381
- *
3382
- * Only rows this store can claim are loaded (#779, plan step 3). A live row whose family another
3383
- * live process claims — `serve`'s parked run, seen by a headless `cez run` — is that process's:
3384
- * it is not loaded, normalized or recovered here, and stays readable through `getRun` and the
3385
- * list rows. A live row nobody alive claims is taken over, as before: this open recovers it
3386
- * (`keepLive`) or settles it as interrupted.
3387
- */
3388
- private loadHeldRows;
3389
- /** Normalize a record just read from `row` (see `reconcileLoadedRun`) and hold it. Marks the row
3390
- * dirty only when normalization changed it, so the next save persists exactly the runs open()
3391
- * rewrote. A row read up from schema-3 wait fields counts as changed: its rewrite drops them
3392
- * and recomputes its summary and live column (`upgradeLegacyWaits`), as does a summary that does
3393
- * not parse (hearsay-tools/squawk#3530). The caller has claimed the row's family. */
3394
- private adoptLoadedRun;
3395
- /**
3396
- * Hold one delegation family: its root and every worker filed under it, read through the
3397
- * `parent_run_id` index. No recursion: a worker's own id never names a family. The caller has claimed it. `settle` settles its live rows instead of keeping
3398
- * them for recovery (`settleOrphanedRun`); `stopId` is the run a Stop settles as cancelled.
3399
- */
3400
- private holdFamily;
3401
- /** Make sure this store claims each of `families`; `claimStoreFamilies` takes the free ones. */
3402
- private claimFamilies;
3403
- /** Release the claim of every family with nothing left in memory, once nothing is pending: a
3404
- * failed save keeps its families claimed until it succeeds. A failed release retries at the
3405
- * next sweep; `close()` releases the rest. */
3406
- private releaseUnheldClaims;
3407
- /**
3408
- * Who may change this run right now (see `RunOwnership`), or undefined when there is no such
3409
- * run. Read-only: nothing is claimed. Controls ask this first, so a run another process owns is
3410
- * refused with `RUN_IN_USE_ELSEWHERE` and a dead process's run is adopted before it is changed.
3411
- */
3412
- runOwnership(id: string): RunOwnership | undefined;
3413
- /** Why a control on this run must be refused here, or undefined when this store may change it. */
3414
- writeRefusal(id: string): string | undefined;
3415
- /**
3416
- * Claim an orphaned family before a control, then settle its live rows.
3417
- * Stop cancels its target. Return the root id, or undefined for a live owner or missing run.
3418
- */
3419
- adoptFamily(id: string, opts?: {
3420
- stop?: boolean;
3421
- }): string | undefined;
3422
- /** Explicit controls only (`requireRunControl`): copy a fallback family in so it can be written. */
3423
- adoptFallbackFamily(id: string): boolean;
3424
- private fallbackRefusal;
3425
- /** Run files are written only for a family this store may write, never a fallback family. */
3426
- /** The error `appendEvent` throws for a run this store cannot write or does not know. */
3427
- private missingRunError;
3428
- private writeDir;
3429
- /** Every run whose family another process owns (`foreignClaimedRunIds`). */
3430
- listForeignClaimedRunIds(): string[];
3431
- /** Non-terminal rows in the database (both directories) and the runs of families another live store claims. */
3432
- persistedLiveRunIds(): {
3433
- live: string[];
3434
- foreign: string[];
3435
- };
3436
3315
  /**
3437
3316
  * Whether a held run anchors itself (and its family) in memory. Anything else held is a family
3438
3317
  * member or a settled write, and leaves at the next sweep (`evictSettled`).
@@ -3484,18 +3363,6 @@ export declare class RunStore {
3484
3363
  withReadCache<T>(fn: () => T): T;
3485
3364
  /** Whether the run exists, held or not, without decoding it. */
3486
3365
  private hasRun;
3487
- /**
3488
- * Keep a run in memory for `holder` until `unpin(id, holder)`: a RunManager pins the runs it is
3489
- * executing (`active`) and the run a Continue is admitting (`continue`). A finished run is
3490
- * loaded. Pins are per holder, so releasing one never releases another. Returns the held record.
3491
- */
3492
- pin(id: string, holder: RunPinHolder): RunRecord | undefined;
3493
- /** Publish a run's current record again without a write: something read beside the record
3494
- * changed, such as the run leaving the manager's live registries, which a detail's finish
3495
- * verdict reads (hearsay-tools/cezarion#1301). */
3496
- republish(id: string): void;
3497
- /** Release `holder`'s pin. The run leaves memory at the next sweep once nothing else holds it. */
3498
- unpin(id: string, holder: RunPinHolder): void;
3499
3366
  /**
3500
3367
  * Set discovered repository identity without blocking boot. Recompute conclusions from retained
3501
3368
  * evidence, including cold records; null retains unknown-handle behavior.