@inerrata-corporation/errata 2.0.17-dev.3464 → 2.0.17-dev.3469

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.
@@ -15656,9 +15656,6 @@ function projectSymbolId(projectSalt, projectId, relPath, qname, kind) {
15656
15656
  const path = normalizeSymbolPath(relPath);
15657
15657
  return `sym_${createHmac("sha256", projectSalt).update(`${projectId}:${path}:${qname}:${kind}`).digest("hex").slice(0, 24)}`;
15658
15658
  }
15659
- function isMembraneSaltedId(id) {
15660
- return typeof id === "string" && /^(orgn_|teamn_|projn_)/.test(id);
15661
- }
15662
15659
  var init_project_symbol = __esm({
15663
15660
  "../../packages/shared/src/project-symbol.ts"() {
15664
15661
  "use strict";
@@ -18584,6 +18581,18 @@ init_src();
18584
18581
  // src/instance-receipts.ts
18585
18582
  var INSTANCE_SEMANTIC_EDGE_TYPES = ["CAUSED_BY", "SOLVED_BY"];
18586
18583
  var INSTANCE_ANCHOR_EDGE_TYPES = ["OCCURS_IN", "DEPENDS_ON", "PERTAIN_TO", "CONCERNS"];
18584
+ function instanceCloudWithdrawal(n, destination, getMeta) {
18585
+ const id = n.attrs["source"] === "cloud" ? n.attrs["cloudNodeId"] ?? n.id : instanceReceipt(n, destination)["cloudNodeId"];
18586
+ if (typeof id !== "string") return false;
18587
+ const raw = getMeta(`history-correction:${id}`);
18588
+ if (!raw) return false;
18589
+ try {
18590
+ const correction = JSON.parse(raw);
18591
+ return correction.nodeId === id && correction.action === "quarantine" && correction.sourceSupport !== "supported";
18592
+ } catch {
18593
+ return false;
18594
+ }
18595
+ }
18587
18596
  function receiptMap(attrs) {
18588
18597
  const value = attrs["instanceReceipts"];
18589
18598
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -19474,7 +19483,7 @@ function stripCodebaseScope(scope) {
19474
19483
  }
19475
19484
  function contributedWireId(n, destinationKey) {
19476
19485
  const cloudId = instanceReceipt(n, destinationKey)["cloudNodeId"];
19477
- return isMembraneSaltedId(cloudId) ? cloudId : n.id;
19486
+ return typeof cloudId === "string" && cloudId ? cloudId : n.id;
19478
19487
  }
19479
19488
  var WIRE_CANONICAL_ID_MIN = 6;
19480
19489
  var SHIP_TERMINAL_REFUSALS = 3;
@@ -19482,7 +19491,7 @@ function refusalFingerprint(reason, description) {
19482
19491
  return digest(`${reason}\0${description}`);
19483
19492
  }
19484
19493
  function isRetryableRefusal(reason) {
19485
- return /\bretry\b/i.test(reason);
19494
+ return reason === "blocked" || /\bretry\b/i.test(reason);
19486
19495
  }
19487
19496
  function isTerminallyRefused(n) {
19488
19497
  const reason = String(n.attrs["shipRefusedReason"] ?? "");
@@ -19602,6 +19611,8 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
19602
19611
  const semanticEndpoints = /* @__PURE__ */ new Map();
19603
19612
  const includedByLabel = /* @__PURE__ */ new Map();
19604
19613
  const composition = {
19614
+ cloudWithdrawn: 0,
19615
+ withdrawnAnchorTargets: 0,
19605
19616
  privateTargetMissing: 0,
19606
19617
  candidates: 0,
19607
19618
  shipped: 0,
@@ -19670,6 +19681,10 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
19670
19681
  composition.ignored++;
19671
19682
  continue;
19672
19683
  }
19684
+ if (instanceCloudWithdrawal(n, opts.destinationKey, (key) => store.getMeta?.(key) ?? opts.sharedStore?.getMeta?.(key))) {
19685
+ composition.cloudWithdrawn++;
19686
+ continue;
19687
+ }
19673
19688
  const contributedAtSeq = instanceReceipt(n, opts.destinationKey)["contributedAtSeq"];
19674
19689
  if (typeof contributedAtSeq === "number" && (n.lastReinforcedAtSeq ?? 0) <= contributedAtSeq) {
19675
19690
  composition.watermarked++;
@@ -19718,6 +19733,10 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
19718
19733
  for (const e of store.outEdges(sourceId, [...ANCHOR_EDGES])) {
19719
19734
  const t = nodeOf(e.to);
19720
19735
  if (!t || !ANCHOR_TARGET_LABELS.includes(t.label)) continue;
19736
+ if (instanceCloudWithdrawal(t, opts.destinationKey, (key) => store.getMeta?.(key) ?? opts.sharedStore?.getMeta?.(key))) {
19737
+ composition.withdrawnAnchorTargets++;
19738
+ continue;
19739
+ }
19721
19740
  if (e.type === "OCCURS_IN" && t.label !== "Language") continue;
19722
19741
  if (e.type === "DEPENDS_ON" && t.label !== "Package") continue;
19723
19742
  if (e.type === "PERTAIN_TO" && t.label !== "Domain") continue;
package/errata.mjs CHANGED
@@ -17056,7 +17056,7 @@ function depsForUnit(spine, touched, readParentText) {
17056
17056
  for (const purl of declared.keys()) context.delete(purl);
17057
17057
  return { declared: [...declared.values()], context: [...context.values()] };
17058
17058
  }
17059
- var ECOSYSTEM_SYSTEM, ECOSYSTEM_LANGUAGE, TOOL_KINDS, MANIFEST_PATH_RE, LOCAL_IMAGE_RE, PACKAGE_JSON_SECTIONS, GRADLE_CONFIGS, POM_FOREIGN_BLOCKS;
17059
+ var ECOSYSTEM_SYSTEM, ECOSYSTEM_LANGUAGE, TOOL_KINDS, MANIFEST_PATH_RE, LOCAL_IMAGE_RE, PACKAGE_JSON_SECTIONS, GRADLE_CONFIGS, POM_FOREIGN_BLOCKS, HISTORY_MAX_SPINE_DEPS;
17060
17060
  var init_manifests = __esm({
17061
17061
  "../../packages/shared/src/manifests.ts"() {
17062
17062
  "use strict";
@@ -17089,6 +17089,7 @@ var init_manifests = __esm({
17089
17089
  PACKAGE_JSON_SECTIONS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
17090
17090
  GRADLE_CONFIGS = "implementation|api|compileOnly|compileOnlyApi|runtimeOnly|testImplementation|testCompileOnly|testRuntimeOnly|annotationProcessor|kapt|ksp|classpath|developmentOnly";
17091
17091
  POM_FOREIGN_BLOCKS = /<(parent|dependencies|dependencyManagement|build|profiles|reporting|distributionManagement|modules)>[\s\S]*?<\/\1>/g;
17092
+ HISTORY_MAX_SPINE_DEPS = 64;
17092
17093
  }
17093
17094
  });
17094
17095
 
@@ -17346,6 +17347,7 @@ __export(src_exports, {
17346
17347
  GIT_EDGES: () => GIT_EDGES,
17347
17348
  GRAPH_EVENT_VOCABULARIES: () => GRAPH_EVENT_VOCABULARIES,
17348
17349
  HISTORY_EVIDENCE_SCHEMA_VERSION: () => HISTORY_EVIDENCE_SCHEMA_VERSION,
17350
+ HISTORY_MAX_SPINE_DEPS: () => HISTORY_MAX_SPINE_DEPS,
17349
17351
  HISTORY_SCRUBBER_VERSION: () => HISTORY_SCRUBBER_VERSION,
17350
17352
  HistoryAnchorSourceSchema: () => HistoryAnchorSourceSchema,
17351
17353
  HistoryCandidateBatchSchema: () => HistoryCandidateBatchSchema,
@@ -26155,6 +26157,8 @@ var init_oauth = __esm({
26155
26157
 
26156
26158
  // ../../packages/cloud-client/src/client.ts
26157
26159
  import { randomUUID } from "node:crypto";
26160
+ import { gzip } from "node:zlib";
26161
+ import { promisify } from "node:util";
26158
26162
  function wirePerContext(value) {
26159
26163
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
26160
26164
  const out2 = {};
@@ -26406,7 +26410,7 @@ function parseRestErrorEnvelope(text) {
26406
26410
  return null;
26407
26411
  }
26408
26412
  }
26409
- var asWireCount, INGEST_NODE_CHUNK, INGEST_EDGE_CHUNK, E6B_PUBLIC_CONTEXT_SENTINEL, CloudClient, CloudError;
26413
+ var asWireCount, INGEST_NODE_CHUNK, INGEST_EDGE_CHUNK, E6B_PUBLIC_CONTEXT_SENTINEL, gzipAsync, CloudClient, CloudError;
26410
26414
  var init_client = __esm({
26411
26415
  "../../packages/cloud-client/src/client.ts"() {
26412
26416
  "use strict";
@@ -26416,7 +26420,9 @@ var init_client = __esm({
26416
26420
  INGEST_NODE_CHUNK = 8;
26417
26421
  INGEST_EDGE_CHUNK = 32;
26418
26422
  E6B_PUBLIC_CONTEXT_SENTINEL = "00000000-0000-4e6b-8000-000000000e6b";
26423
+ gzipAsync = promisify(gzip);
26419
26424
  CloudClient = class {
26425
+ compressedRoutes = /* @__PURE__ */ new Set();
26420
26426
  baseUrl;
26421
26427
  apiKey;
26422
26428
  accessToken;
@@ -26648,7 +26654,7 @@ var init_client = __esm({
26648
26654
  merged.nodes.push(...r.nodes);
26649
26655
  merged.edges.push(...r.edges);
26650
26656
  for (const rn of r.nodes) {
26651
- if (rn.nodeId && rn.nodeId !== rn.canonicalId && isMembraneSaltedId(rn.nodeId)) {
26657
+ if (rn.nodeId && rn.nodeId !== rn.canonicalId && rn.decision !== "rejected") {
26652
26658
  echoedCloudId.set(rn.canonicalId, rn.nodeId);
26653
26659
  }
26654
26660
  }
@@ -27080,12 +27086,23 @@ var init_client = __esm({
27080
27086
  const ac = new AbortController();
27081
27087
  const tid = setTimeout(() => ac.abort(), this.timeoutMs);
27082
27088
  try {
27083
- const res = await this.fetchFn(url2, {
27089
+ const serialized = body2 === void 0 ? void 0 : JSON.stringify(body2);
27090
+ const compressible = method === "POST" && (path2 === "/v2/ingest" || /^\/v2\/projects\/[^/]+\/history\/units$/.test(path2));
27091
+ const send = async (compressed2) => this.fetchFn(url2, {
27084
27092
  method,
27085
- headers,
27086
- body: body2 === void 0 ? void 0 : JSON.stringify(body2),
27093
+ headers: compressed2 ? { ...headers, "content-encoding": "gzip" } : headers,
27094
+ body: compressed2 && serialized !== void 0 ? new Uint8Array(await gzipAsync(serialized)) : serialized,
27087
27095
  signal: ac.signal
27088
27096
  });
27097
+ let compressed = compressible && this.compressedRoutes.has(path2);
27098
+ let res = await send(compressed);
27099
+ if (!res.ok && compressible && !compressed && serialized !== void 0) {
27100
+ const text = await res.clone().text();
27101
+ if (isIntermediaryRejection(new CloudError(`HTTP ${res.status} ${text.slice(0, 200)}`, res.status))) {
27102
+ compressed = true;
27103
+ res = await send(true);
27104
+ }
27105
+ }
27089
27106
  if (!res.ok) {
27090
27107
  const text = await res.text();
27091
27108
  const envelope = parseRestErrorEnvelope(text);
@@ -27095,6 +27112,7 @@ var init_client = __esm({
27095
27112
  envelope?.code
27096
27113
  );
27097
27114
  }
27115
+ if (compressed) this.compressedRoutes.add(path2);
27098
27116
  return await res.json();
27099
27117
  } finally {
27100
27118
  clearTimeout(tid);
@@ -64914,7 +64932,7 @@ var require_mock_interceptor = __commonJS({
64914
64932
  var require_mock_client = __commonJS({
64915
64933
  "../../node_modules/.pnpm/undici@6.24.1/node_modules/undici/lib/mock/mock-client.js"(exports, module2) {
64916
64934
  "use strict";
64917
- var { promisify: promisify4 } = __require("node:util");
64935
+ var { promisify: promisify5 } = __require("node:util");
64918
64936
  var Client = require_client();
64919
64937
  var { buildMockDispatch } = require_mock_utils();
64920
64938
  var {
@@ -64954,7 +64972,7 @@ var require_mock_client = __commonJS({
64954
64972
  return new MockInterceptor(opts, this[kDispatches]);
64955
64973
  }
64956
64974
  async [kClose]() {
64957
- await promisify4(this[kOriginalClose])();
64975
+ await promisify5(this[kOriginalClose])();
64958
64976
  this[kConnected] = 0;
64959
64977
  this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
64960
64978
  }
@@ -64967,7 +64985,7 @@ var require_mock_client = __commonJS({
64967
64985
  var require_mock_pool = __commonJS({
64968
64986
  "../../node_modules/.pnpm/undici@6.24.1/node_modules/undici/lib/mock/mock-pool.js"(exports, module2) {
64969
64987
  "use strict";
64970
- var { promisify: promisify4 } = __require("node:util");
64988
+ var { promisify: promisify5 } = __require("node:util");
64971
64989
  var Pool = require_pool();
64972
64990
  var { buildMockDispatch } = require_mock_utils();
64973
64991
  var {
@@ -65007,7 +65025,7 @@ var require_mock_pool = __commonJS({
65007
65025
  return new MockInterceptor(opts, this[kDispatches]);
65008
65026
  }
65009
65027
  async [kClose]() {
65010
- await promisify4(this[kOriginalClose])();
65028
+ await promisify5(this[kOriginalClose])();
65011
65029
  this[kConnected] = 0;
65012
65030
  this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
65013
65031
  }
@@ -73728,6 +73746,46 @@ import { execFileSync as execFileSync5 } from "node:child_process";
73728
73746
  import { existsSync as existsSync28, statSync as statSync8, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync4, readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
73729
73747
  import { basename as basename7, join as join35, relative as relative6, sep as sep4 } from "node:path";
73730
73748
 
73749
+ // src/coalesced-file-pass.ts
73750
+ function createCoalescedFilePass(delayMs, run3, onError) {
73751
+ const pending = /* @__PURE__ */ new Set();
73752
+ let timer;
73753
+ let running = false;
73754
+ let stopped = false;
73755
+ const clear = () => {
73756
+ if (timer) clearTimeout(timer);
73757
+ timer = void 0;
73758
+ pending.clear();
73759
+ };
73760
+ const schedule = () => {
73761
+ if (stopped || running || !pending.size) return;
73762
+ if (timer) clearTimeout(timer);
73763
+ timer = setTimeout(() => {
73764
+ timer = void 0;
73765
+ const paths = [...pending];
73766
+ pending.clear();
73767
+ running = true;
73768
+ void Promise.resolve().then(() => run3(paths)).catch(onError).finally(() => {
73769
+ running = false;
73770
+ schedule();
73771
+ });
73772
+ }, delayMs);
73773
+ };
73774
+ return {
73775
+ add(path2) {
73776
+ if (!stopped) {
73777
+ pending.add(path2);
73778
+ schedule();
73779
+ }
73780
+ },
73781
+ clear,
73782
+ stop() {
73783
+ stopped = true;
73784
+ clear();
73785
+ }
73786
+ };
73787
+ }
73788
+
73731
73789
  // src/source-watcher.ts
73732
73790
  import { EventEmitter as EventEmitter2 } from "node:events";
73733
73791
  import { statSync as statSync5, watch as watch2 } from "node:fs";
@@ -82176,7 +82234,7 @@ function createWatchBreaker(deps) {
82176
82234
  }
82177
82235
 
82178
82236
  // src/engine.ts
82179
- var DAEMON_VERSION = true ? "2.0.17-dev.3464" : "2.0.0-alpha.0";
82237
+ var DAEMON_VERSION = true ? "2.0.17-dev.3469" : "2.0.0-alpha.0";
82180
82238
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
82181
82239
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
82182
82240
  var GIT_OP_MUTE_MS = 4e3;
@@ -82327,7 +82385,8 @@ function createWorkspaceEngine(opts) {
82327
82385
  let watchBreaker = null;
82328
82386
  let lastActivityTs = Date.now();
82329
82387
  let stopGit = null;
82330
- let flushTimer = null;
82388
+ let fsReindex;
82389
+ let stopping = false;
82331
82390
  if (!opts.skipWatchers) {
82332
82391
  const watchTargets = gitSourceWatchTargets(opts.workspaceRoot);
82333
82392
  watcher = createSourceWatcher(watchTargets, {
@@ -82387,6 +82446,7 @@ function createWorkspaceEngine(opts) {
82387
82446
  for (const e of identityEvaluations) auditIdentity(t, e);
82388
82447
  return r;
82389
82448
  } catch (err2) {
82449
+ if (stopping) throw err2;
82390
82450
  console.warn(
82391
82451
  "[errata] reindex worker unavailable, running inline:",
82392
82452
  err2 instanceof Error ? err2.message : err2
@@ -82403,51 +82463,46 @@ function createWorkspaceEngine(opts) {
82403
82463
  done();
82404
82464
  }
82405
82465
  };
82406
- const dirty = /* @__PURE__ */ new Set();
82407
82466
  let gitOpMuteUntil = 0;
82408
- const scheduleFlush = () => {
82409
- if (flushTimer) clearTimeout(flushTimer);
82410
- flushTimer = setTimeout(() => {
82411
- const changed = [...dirty];
82412
- dirty.clear();
82413
- if (changed.length === 0) return;
82414
- const t = Date.now();
82415
- const relChanged = changed.map((p) => relative6(opts.workspaceRoot, p).split(sep4).join("/"));
82416
- const causal = causalBuffer.correlate(relChanged, t) ?? void 0;
82417
- void runReindexPass(
82418
- `fs-reindex:${profile.name} (${changed.length} files)`,
82419
- changed,
82420
- t,
82421
- causal?.declaredRenames
82422
- ).then((r) => {
82423
- if (r.filesReindexed > 0) {
82467
+ fsReindex = createCoalescedFilePass(REINDEX_DEBOUNCE_MS, async (changed) => {
82468
+ if (stopping) return;
82469
+ const t = Date.now();
82470
+ const relChanged = changed.map((p) => relative6(opts.workspaceRoot, p).split(sep4).join("/"));
82471
+ const causal = causalBuffer.correlate(relChanged, t) ?? void 0;
82472
+ await runReindexPass(
82473
+ `fs-reindex:${profile.name} (${changed.length} files)`,
82474
+ changed,
82475
+ t,
82476
+ causal?.declaredRenames
82477
+ ).then((r) => {
82478
+ if (stopping) return;
82479
+ if (r.filesReindexed > 0) {
82480
+ console.log(
82481
+ `[errata] incremental reindex: ${r.filesReindexed} file(s), +${r.nodesEmitted} nodes / +${r.edgesEmitted} edges`
82482
+ );
82483
+ if (r.continuations.length > 0) {
82424
82484
  console.log(
82425
- `[errata] incremental reindex: ${r.filesReindexed} file(s), +${r.nodesEmitted} nodes / +${r.edgesEmitted} edges`
82485
+ `[errata] identity: ${r.continuations.map((c) => `${c.kind}(${c.confidence.toFixed(2)})`).join(", ")}`
82426
82486
  );
82427
- if (r.continuations.length > 0) {
82428
- console.log(
82429
- `[errata] identity: ${r.continuations.map((c) => `${c.kind}(${c.confidence.toFixed(2)})`).join(", ")}`
82430
- );
82431
- }
82432
- const epId = recordEpisode(store, profile.id, t, r.delta, causal);
82433
- if (epId) {
82434
- const d = r.delta;
82435
- console.log(
82436
- `[errata] ${epId}: +${d.symbolsAdded} ~${d.symbolsChanged} -${d.symbolsRemoved} symbols, +${d.edgesAdded}/-${d.edgesRemoved} edges` + (causal ? ` \xB7 causal[${causal.tool}${causal.intentHints.length ? ":" + causal.intentHints.join(",") : ""}]` : "")
82437
- );
82438
- }
82439
82487
  }
82440
- }).catch((err2) => {
82441
- console.warn("[errata] incremental reindex failed:", err2);
82442
- });
82443
- }, REINDEX_DEBOUNCE_MS);
82444
- };
82488
+ const epId = recordEpisode(store, profile.id, t, r.delta, causal);
82489
+ if (epId) {
82490
+ const d = r.delta;
82491
+ console.log(
82492
+ `[errata] ${epId}: +${d.symbolsAdded} ~${d.symbolsChanged} -${d.symbolsRemoved} symbols, +${d.edgesAdded}/-${d.edgesRemoved} edges` + (causal ? ` \xB7 causal[${causal.tool}${causal.intentHints.length ? ":" + causal.intentHints.join(",") : ""}]` : "")
82493
+ );
82494
+ }
82495
+ }
82496
+ });
82497
+ }, (err2) => {
82498
+ if (stopping) return;
82499
+ console.warn("[errata] incremental reindex failed:", err2);
82500
+ });
82445
82501
  const markDirty = (p) => {
82446
82502
  if (Date.now() < gitOpMuteUntil) return;
82447
82503
  if (IGNORED_PATH.test(p)) return;
82448
82504
  if (!/\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p)) return;
82449
- dirty.add(p);
82450
- scheduleFlush();
82505
+ fsReindex.add(p);
82451
82506
  };
82452
82507
  watcher.on("add", markDirty);
82453
82508
  watcher.on("change", markDirty);
@@ -82455,11 +82510,7 @@ function createWorkspaceEngine(opts) {
82455
82510
  const handleGitEvent = async (ev) => {
82456
82511
  if (ev.kind !== "commit") {
82457
82512
  gitOpMuteUntil = Date.now() + GIT_OP_MUTE_MS;
82458
- dirty.clear();
82459
- if (flushTimer) {
82460
- clearTimeout(flushTimer);
82461
- flushTimer = null;
82462
- }
82513
+ fsReindex.clear();
82463
82514
  }
82464
82515
  if (!ev.oldSha || !ev.newSha || ev.oldSha === ev.newSha) return;
82465
82516
  const t = Date.now();
@@ -84805,6 +84856,8 @@ B: ${b}`,
84805
84856
  }
84806
84857
  },
84807
84858
  async stop() {
84859
+ stopping = true;
84860
+ fsReindex?.stop();
84808
84861
  clearInterval(fileActivityTimer);
84809
84862
  fileActivity.stop();
84810
84863
  if (stopGit) stopGit();
@@ -84814,7 +84867,6 @@ B: ${b}`,
84814
84867
  await watcher.close();
84815
84868
  noteWatcherClosed();
84816
84869
  }
84817
- if (flushTimer) clearTimeout(flushTimer);
84818
84870
  for (const tmr of diagTimers.values()) clearTimeout(tmr);
84819
84871
  diagTimers.clear();
84820
84872
  if (ctxRefreshTimer) clearTimeout(ctxRefreshTimer);
@@ -84925,8 +84977,8 @@ init_profile2();
84925
84977
  // src/project-link.ts
84926
84978
  init_profile2();
84927
84979
  import { execFile as execFile3 } from "node:child_process";
84928
- import { promisify } from "node:util";
84929
- var execFileAsync = promisify(execFile3);
84980
+ import { promisify as promisify2 } from "node:util";
84981
+ var execFileAsync = promisify2(execFile3);
84930
84982
  function isClaimedElsewhere(err2) {
84931
84983
  if (!err2 || typeof err2 !== "object") return false;
84932
84984
  const e = err2;
@@ -85095,6 +85147,18 @@ function instanceEdgeReceipts(sent, received, cloudIds) {
85095
85147
  ).map(([group]) => group));
85096
85148
  return { complete: (source, kind) => complete.has(groupKey(source, kind)) };
85097
85149
  }
85150
+ function instanceCloudWithdrawal(n, destination, getMeta) {
85151
+ const id = n.attrs["source"] === "cloud" ? n.attrs["cloudNodeId"] ?? n.id : instanceReceipt(n, destination)["cloudNodeId"];
85152
+ if (typeof id !== "string") return false;
85153
+ const raw2 = getMeta(`history-correction:${id}`);
85154
+ if (!raw2) return false;
85155
+ try {
85156
+ const correction = JSON.parse(raw2);
85157
+ return correction.nodeId === id && correction.action === "quarantine" && correction.sourceSupport !== "supported";
85158
+ } catch {
85159
+ return false;
85160
+ }
85161
+ }
85098
85162
  var FIELDS = ["contributedAtSeq", "cloudNodeId", "anchorsContributedDigest", "projectAnchorsContributedDigest", "semanticEdgesContributedDigest", "shipRefusedSinceSeq", "shipRefusedCount", "shipRefusedReason", "shipRefusedFingerprint"];
85099
85163
  function instanceDestinationKey(input) {
85100
85164
  return createHash18("sha256").update(JSON.stringify([
@@ -85139,7 +85203,6 @@ function acceptedInstanceReceipt(current, sent, decision, destination, mirrorLeg
85139
85203
  }
85140
85204
 
85141
85205
  // src/multi.ts
85142
- init_src();
85143
85206
  init_dist();
85144
85207
  init_src5();
85145
85208
  import { existsSync as existsSync34, readFileSync as readFileSync36, unlinkSync as unlinkSync5, writeFileSync as writeFileSync26 } from "node:fs";
@@ -85546,7 +85609,7 @@ function compositionCounters(c) {
85546
85609
  }
85547
85610
  function contributedWireId(n, destinationKey) {
85548
85611
  const cloudId = instanceReceipt(n, destinationKey)["cloudNodeId"];
85549
- return isMembraneSaltedId(cloudId) ? cloudId : n.id;
85612
+ return typeof cloudId === "string" && cloudId ? cloudId : n.id;
85550
85613
  }
85551
85614
  var WIRE_CANONICAL_ID_MIN = 6;
85552
85615
  var SHIP_TERMINAL_REFUSALS = 3;
@@ -85554,7 +85617,7 @@ function refusalFingerprint(reason, description) {
85554
85617
  return digest(`${reason}\0${description}`);
85555
85618
  }
85556
85619
  function isRetryableRefusal(reason) {
85557
- return /\bretry\b/i.test(reason);
85620
+ return reason === "blocked" || /\bretry\b/i.test(reason);
85558
85621
  }
85559
85622
  function isTerminallyRefused(n) {
85560
85623
  const reason = String(n.attrs["shipRefusedReason"] ?? "");
@@ -85674,6 +85737,8 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
85674
85737
  const semanticEndpoints = /* @__PURE__ */ new Map();
85675
85738
  const includedByLabel = /* @__PURE__ */ new Map();
85676
85739
  const composition = {
85740
+ cloudWithdrawn: 0,
85741
+ withdrawnAnchorTargets: 0,
85677
85742
  privateTargetMissing: 0,
85678
85743
  candidates: 0,
85679
85744
  shipped: 0,
@@ -85742,6 +85807,10 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
85742
85807
  composition.ignored++;
85743
85808
  continue;
85744
85809
  }
85810
+ if (instanceCloudWithdrawal(n, opts.destinationKey, (key) => store.getMeta?.(key) ?? opts.sharedStore?.getMeta?.(key))) {
85811
+ composition.cloudWithdrawn++;
85812
+ continue;
85813
+ }
85745
85814
  const contributedAtSeq = instanceReceipt(n, opts.destinationKey)["contributedAtSeq"];
85746
85815
  if (typeof contributedAtSeq === "number" && (n.lastReinforcedAtSeq ?? 0) <= contributedAtSeq) {
85747
85816
  composition.watermarked++;
@@ -85790,6 +85859,10 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
85790
85859
  for (const e of store.outEdges(sourceId, [...ANCHOR_EDGES])) {
85791
85860
  const t = nodeOf(e.to);
85792
85861
  if (!t || !ANCHOR_TARGET_LABELS.includes(t.label)) continue;
85862
+ if (instanceCloudWithdrawal(t, opts.destinationKey, (key) => store.getMeta?.(key) ?? opts.sharedStore?.getMeta?.(key))) {
85863
+ composition.withdrawnAnchorTargets++;
85864
+ continue;
85865
+ }
85793
85866
  if (e.type === "OCCURS_IN" && t.label !== "Language") continue;
85794
85867
  if (e.type === "DEPENDS_ON" && t.label !== "Package") continue;
85795
85868
  if (e.type === "PERTAIN_TO" && t.label !== "Domain") continue;
@@ -86921,10 +86994,10 @@ async function hydrateProject(opts) {
86921
86994
  init_src11();
86922
86995
  init_src();
86923
86996
  import { execFile as execFile4 } from "node:child_process";
86924
- import { promisify as promisify2 } from "node:util";
86997
+ import { promisify as promisify3 } from "node:util";
86925
86998
  import { extname as extname3 } from "node:path";
86926
86999
  init_profile2();
86927
- var exec = promisify2(execFile4);
87000
+ var exec = promisify3(execFile4);
86928
87001
  var KINDS = { function: "Function", class: "Class", method: "Method", interface: "Interface", const: "Const", enum: "Enum", typealias: "TypeAlias", namespace: "Namespace", property: "Property" };
86929
87002
  var inFlight = /* @__PURE__ */ new Map();
86930
87003
  async function syncHistoryRevision(opts) {
@@ -87044,7 +87117,7 @@ init_src();
87044
87117
  import { execFile as execFile5 } from "node:child_process";
87045
87118
  import { readFileSync as readFileSync35 } from "node:fs";
87046
87119
  import { join as join39 } from "node:path";
87047
- import { promisify as promisify3 } from "node:util";
87120
+ import { promisify as promisify4 } from "node:util";
87048
87121
 
87049
87122
  // src/history-walk.ts
87050
87123
  var LOCKFILE_NAMES = /* @__PURE__ */ new Set([
@@ -87578,11 +87651,12 @@ async function historicalAnchors(input) {
87578
87651
 
87579
87652
  // src/project-history.ts
87580
87653
  init_profile2();
87581
- var execFileAsync2 = promisify3(execFile5);
87654
+ var execFileAsync2 = promisify4(execFile5);
87582
87655
  var HISTORY_EXTRACTOR_VERSION = "history-2";
87583
87656
  var LEASE_POLL_MS = 2e4;
87584
87657
  var RECOVERY_DEADLINE_MS = 15 * 6e4;
87585
87658
  var DEFAULT_LOOKAHEAD = 2;
87659
+ var CONTENT_TRANSPORT_VERSION = 1;
87586
87660
  async function defaultGit(root, args2) {
87587
87661
  const { stdout } = await execFileAsync2("git", ["-C", root, ...args2], { maxBuffer: 64 * 1024 * 1024, windowsHide: true });
87588
87662
  return stdout;
@@ -87615,7 +87689,14 @@ function manifestBlobs(listing) {
87615
87689
  }
87616
87690
  return out2;
87617
87691
  }
87618
- async function spineForUnit(git3, root, unit, readBlob) {
87692
+ function boundedHistorySpine(rings, log) {
87693
+ const omittedDeclared = Math.max(0, rings.declared.length - HISTORY_MAX_SPINE_DEPS);
87694
+ const omittedContext = Math.max(0, rings.context.length - HISTORY_MAX_SPINE_DEPS);
87695
+ if (omittedDeclared || omittedContext) log(`dependency context bounded: omitted ${omittedDeclared} declared and ${omittedContext} context entries (limit ${HISTORY_MAX_SPINE_DEPS} per ring; source diff retained)`);
87696
+ const wire = (d) => ({ ecosystem: d.ecosystem, name: d.name, version: d.version, kind: d.kind, manifest: d.manifest });
87697
+ return { declared: rings.declared.slice(0, HISTORY_MAX_SPINE_DEPS).map(wire), context: rings.context.slice(0, HISTORY_MAX_SPINE_DEPS).map(wire) };
87698
+ }
87699
+ async function spineForUnit(git3, root, unit, readBlob, log) {
87619
87700
  const blobs = manifestBlobs(await git3(root, ["ls-tree", "-r", unit.sha]));
87620
87701
  if (blobs.size === 0) return void 0;
87621
87702
  const texts = /* @__PURE__ */ new Map();
@@ -87629,8 +87710,7 @@ async function spineForUnit(git3, root, unit, readBlob) {
87629
87710
  parentTexts.set(f.path, await readBlob(`${unit.sha}^:${f.path}`).catch(() => null));
87630
87711
  }
87631
87712
  const rings = depsForUnit(spine, unit.files.map((f) => f.path), readParent);
87632
- const wire = (d) => ({ ecosystem: d.ecosystem, name: d.name, version: d.version, kind: d.kind, manifest: d.manifest });
87633
- return { declared: rings.declared.map(wire), context: rings.context.map(wire) };
87713
+ return boundedHistorySpine(rings, log);
87634
87714
  }
87635
87715
  function stage(profile, patch, now) {
87636
87716
  const at = now().toISOString();
@@ -87725,8 +87805,13 @@ async function walk10(root, input, client, opts, readBlob) {
87725
87805
  const dryRun = !consents.contributeHistory;
87726
87806
  const headSha = (await git3(root, ["rev-parse", "HEAD"])).trim();
87727
87807
  const since = profile.historyStage?.watermarkSha ?? null;
87728
- const units = await (opts.enumerate ?? enumerateUnits)(root, since ? { since } : {});
87729
- const total = (profile.historyStage?.unitsDone ?? 0) + units.length;
87808
+ const enumerate = opts.enumerate ?? enumerateUnits;
87809
+ const pendingUnits = await enumerate(root, since ? { since } : {});
87810
+ const unitKey = (u) => `${u.sha}/${u.subIndex}`;
87811
+ const recoveryKeys = new Set(dryRun ? [] : (profile.historyStage?.coverageGaps ?? []).filter((g) => g.reason === "edge-blocked" && (g.transportVersion ?? 0) < CONTENT_TRANSPORT_VERSION).map(unitKey));
87812
+ const oldUnits = recoveryKeys.size ? (await enumerate(root)).filter((u) => recoveryKeys.has(unitKey(u))) : [];
87813
+ const units = [...oldUnits, ...pendingUnits.filter((u) => !oldUnits.some((old) => unitKey(old) === unitKey(u)))];
87814
+ const total = (profile.historyStage?.unitsDone ?? 0) + pendingUnits.filter((u) => !recoveryKeys.has(unitKey(u))).length;
87730
87815
  const anchor = profile.historyStage?.backfillAnchor ? { ...profile.historyStage.backfillAnchor } : { index: Number((await git3(root, ["rev-list", "--first-parent", "--count", headSha])).trim()) - 1 };
87731
87816
  profile = stage(profile, { state: "scanning", unitsTotal: total, headSha, lastError: void 0, backfillAnchor: anchor }, now);
87732
87817
  persist(profile);
@@ -87760,7 +87845,7 @@ async function walk10(root, input, client, opts, readBlob) {
87760
87845
  const launched = /* @__PURE__ */ new Map();
87761
87846
  const cap = opts.maxUnits;
87762
87847
  const edgeParked = /* @__PURE__ */ new Set();
87763
- const parkedEarlier = new Set((profile.historyStage?.coverageGaps ?? []).filter((g) => g.reason === "edge-blocked").map((g) => `${g.sha}/${g.subIndex}`));
87848
+ const parkedEarlier = new Set((profile.historyStage?.coverageGaps ?? []).filter((g) => g.reason === "edge-blocked" && !recoveryKeys.has(unitKey(g))).map(unitKey));
87764
87849
  units.forEach((u, j) => {
87765
87850
  if (parkedEarlier.has(`${u.sha}/${u.subIndex}`)) edgeParked.add(j);
87766
87851
  });
@@ -87801,7 +87886,7 @@ async function walk10(root, input, client, opts, readBlob) {
87801
87886
  ...prev ? { after: { sha: prev.sha, subIndex: prev.subIndex } } : {},
87802
87887
  ...!dryRun && u.index <= anchor.index ? { backfill: { anchorIndex: anchor.index, ...anchor.seq !== void 0 ? { anchorSeq: anchor.seq } : {} } } : {}
87803
87888
  };
87804
- const spine = await spineForUnit(git3, root, u, readBlob);
87889
+ const spine = await spineForUnit(git3, root, u, readBlob, (line) => log(`[errata] history ${u.sha.slice(0, 12)}/${u.subIndex}: ${line}`));
87805
87890
  if (spine) body2.spine = spine;
87806
87891
  const anchors = opts.anchors ? await historicalAnchors({
87807
87892
  root,
@@ -87838,12 +87923,14 @@ async function walk10(root, input, client, opts, readBlob) {
87838
87923
  const u = units[k];
87839
87924
  if (cap !== void 0 && processed >= cap) break;
87840
87925
  const label = `${u.sha.slice(0, 12)}${u.subIndex ? `/${u.subIndex}` : ""}`;
87841
- const doneSoFar = (profile.historyStage?.unitsDone ?? 0) + 1;
87926
+ const recovering = recoveryKeys.has(unitKey(u));
87927
+ const walkIncrement = recovering ? 0 : 1;
87928
+ const doneSoFar = (profile.historyStage?.unitsDone ?? 0) + walkIncrement;
87842
87929
  const group = byIndex.get(u.index) ?? [u];
87843
87930
  const positionSha = u.groupSha ?? u.sha;
87844
- const lastInPosition = group[group.length - 1] === u;
87931
+ const lastInPosition = !recovering && group[group.length - 1] === u;
87845
87932
  if (u.skip) {
87846
- counts = addCounts(counts, { commitsWalked: 1 });
87933
+ counts = addCounts(counts, { commitsWalked: walkIncrement });
87847
87934
  profile = stage(profile, { state: dryRun ? "extracting" : "contributing", unitsDone: doneSoFar, counts, ...lastInPosition ? { watermarkSha: positionSha } : {} }, now);
87848
87935
  persist(profile);
87849
87936
  processed += 1;
@@ -87858,7 +87945,7 @@ async function walk10(root, input, client, opts, readBlob) {
87858
87945
  continue;
87859
87946
  }
87860
87947
  const { body: body2, prepMs } = await prepare(k);
87861
- profile = stage(profile, { state: dryRun ? "extracting" : "contributing", unitsDone: doneSoFar - 1, lastError: void 0 }, now);
87948
+ profile = stage(profile, { state: dryRun ? "extracting" : "contributing", unitsDone: doneSoFar - walkIncrement, lastError: void 0 }, now);
87862
87949
  persist(profile);
87863
87950
  response = await reportHistoryStage(client, profile, log);
87864
87951
  if (response?.stopRequested) {
@@ -87936,8 +88023,10 @@ async function walk10(root, input, client, opts, readBlob) {
87936
88023
  const runId = `edge-blocked:${u.sha}/${u.subIndex}`;
87937
88024
  const gaps = [...profile.historyStage?.coverageGaps ?? []];
87938
88025
  const known = gaps.some((g) => g.runId === runId);
87939
- counts = addCounts(counts, { commitsWalked: 1, deferredUnits: known ? 0 : 1 });
87940
- if (!known) gaps.push({ sha: u.sha, subIndex: u.subIndex, runId, reason: "edge-blocked" });
88026
+ counts = addCounts(counts, { commitsWalked: walkIncrement, deferredUnits: known ? 0 : 1 });
88027
+ const gap = { sha: u.sha, subIndex: u.subIndex, runId, reason: "edge-blocked", transportVersion: CONTENT_TRANSPORT_VERSION };
88028
+ if (!known) gaps.push(gap);
88029
+ else gaps[gaps.findIndex((g) => g.runId === runId)] = gap;
87941
88030
  profile = stage(profile, { coverageGaps: gaps.slice(-1e3), unitsDone: doneSoFar, counts, ...lastInPosition ? { watermarkSha: positionSha } : {} }, now);
87942
88031
  persist(profile);
87943
88032
  processed += 1;
@@ -87954,18 +88043,18 @@ async function walk10(root, input, client, opts, readBlob) {
87954
88043
  return { profile, processed, state: "paused" };
87955
88044
  }
87956
88045
  const packages = new Set(outcome.result.nodes.filter((n) => n.decision !== "rejected" && n.canonicalId.startsWith("pkg:")).map((n) => n.canonicalId)).size;
87957
- counts = addCounts(counts, { commitsWalked: 1, changesExtracted: 1, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims, anchors: outcome.receipt.anchors, packages });
88046
+ counts = addCounts(counts, { commitsWalked: walkIncrement, changesExtracted: 1, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims, anchors: outcome.receipt.anchors, packages });
87958
88047
  log(`[errata] history ${label}: ${outcome.result.nodes.length} nodes, ${outcome.result.edges.length} edges (${outcome.receipt.keptPairs} pairs, ${outcome.receipt.claims} claims)${unitDecisions(outcome.receipt)}${unitTiming(started2, prepMs, outcome.receipt)}`);
87959
88048
  break;
87960
88049
  }
87961
88050
  case "replayed": {
87962
- counts = addCounts(counts, { commitsWalked: 1, changesExtracted: 1, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims, anchors: outcome.receipt.anchors });
88051
+ counts = addCounts(counts, { commitsWalked: walkIncrement, changesExtracted: 1, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims, anchors: outcome.receipt.anchors });
87963
88052
  log(`[errata] history ${label}: replayed (${outcome.result.nodes.length} nodes already in)`);
87964
88053
  break;
87965
88054
  }
87966
88055
  case "empty":
87967
88056
  case "dry-run":
87968
- counts = addCounts(counts, { commitsWalked: 1, changesExtracted: outcome.status === "dry-run" ? 1 : 0, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims });
88057
+ counts = addCounts(counts, { commitsWalked: walkIncrement, changesExtracted: outcome.status === "dry-run" ? 1 : 0, pairs: outcome.receipt.keptPairs, claims: outcome.receipt.claims });
87969
88058
  log(`[errata] history ${label}: ${outcome.status} (${outcome.receipt.keptPairs} pairs, dropped ${outcome.receipt.droppedByEvidence} by evidence, ${outcome.receipt.droppedByAnchor} by anchor)${unitDecisions(outcome.receipt)}${unitTiming(started2, prepMs, outcome.receipt)}`);
87970
88059
  break;
87971
88060
  case "refused":
@@ -87977,8 +88066,10 @@ async function walk10(root, input, client, opts, readBlob) {
87977
88066
  case "error":
87978
88067
  if (outcome.status === "error" && outcome.parked && outcome.runId && ["deferred-context", "deferred-budget"].includes(outcome.errorCode ?? "")) {
87979
88068
  const gaps = [...profile.historyStage?.coverageGaps ?? []];
88069
+ const recoveredGap = recovering ? gaps.findIndex((g) => g.reason === "edge-blocked" && unitKey(g) === unitKey(u)) : -1;
88070
+ if (recoveredGap >= 0) gaps.splice(recoveredGap, 1);
87980
88071
  const known = gaps.some((g) => g.runId === outcome.runId);
87981
- counts = addCounts(counts, { commitsWalked: 1, deferredUnits: known ? 0 : 1 });
88072
+ counts = addCounts(counts, { commitsWalked: walkIncrement, deferredUnits: known || recoveredGap >= 0 ? 0 : 1 });
87982
88073
  if (!known) gaps.push({ sha: u.sha, subIndex: u.subIndex, runId: outcome.runId, reason: outcome.errorCode });
87983
88074
  profile = stage(profile, { coverageGaps: gaps.slice(-1e3) }, now);
87984
88075
  log(`[errata] history ${label}: deferred (${outcome.errorCode}); coverage gap retained as ${outcome.runId}`);
@@ -87989,6 +88080,12 @@ async function walk10(root, input, client, opts, readBlob) {
87989
88080
  await reportHistoryStage(client, profile, log);
87990
88081
  return { profile, processed, state: "paused" };
87991
88082
  }
88083
+ if (recovering && ["completed", "replayed", "empty"].includes(outcome.status)) {
88084
+ const gaps = (profile.historyStage?.coverageGaps ?? []).filter((g) => !(g.reason === "edge-blocked" && unitKey(g) === unitKey(u)));
88085
+ counts.deferredUnits = Math.max(0, (counts.deferredUnits ?? 0) - 1);
88086
+ profile = stage(profile, { coverageGaps: gaps }, now);
88087
+ log(`[errata] history ${label}: recovered retained edge-blocked source`);
88088
+ }
87992
88089
  profile = stage(profile, { unitsDone: doneSoFar, counts, ...lastInPosition ? { watermarkSha: positionSha } : {} }, now);
87993
88090
  persist(profile);
87994
88091
  processed += 1;
@@ -90403,7 +90500,7 @@ async function startMultiDaemon(opts = {}) {
90403
90500
  const rejectedEdges = res.result.edges.filter((re) => re.decision === "rejected");
90404
90501
  const cloudIds = /* @__PURE__ */ new Map();
90405
90502
  for (const node2 of res.result.nodes) {
90406
- if (isMembraneSaltedId(node2.nodeId)) cloudIds.set(node2.canonicalId, node2.nodeId);
90503
+ if (node2.nodeId && node2.decision !== "rejected") cloudIds.set(node2.canonicalId, node2.nodeId);
90407
90504
  }
90408
90505
  for (const localId of /* @__PURE__ */ new Set([
90409
90506
  ...Object.keys(instances.anchorDigests),
@@ -90412,7 +90509,7 @@ async function startMultiDaemon(opts = {}) {
90412
90509
  ])) {
90413
90510
  const owner = owningStore(localId);
90414
90511
  const cloudId = owner && instanceReceipt(owner.n, destinationKey)["cloudNodeId"];
90415
- if (isMembraneSaltedId(cloudId)) cloudIds.set(localId, cloudId);
90512
+ if (typeof cloudId === "string" && cloudId) cloudIds.set(localId, cloudId);
90416
90513
  }
90417
90514
  const edgeReceipts = instanceEdgeReceipts(instances.edges, res.result.edges, cloudIds);
90418
90515
  if (rejectedEdges.length > 0) {
@@ -90454,7 +90551,7 @@ async function startMultiDaemon(opts = {}) {
90454
90551
  nowHeld.push({ id, reason });
90455
90552
  }
90456
90553
  };
90457
- for (const id of blocked) noteRefused(id, "blocked", () => blockedRepeat++);
90554
+ for (const id of blocked) noteRefused(id, "blocked-gzip", () => blockedRepeat++);
90458
90555
  for (const [id, why] of rejected) noteRefused(id, why, () => rejectedRepeat++);
90459
90556
  if (nowHeld.length > 0) {
90460
90557
  console.warn(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.17-dev.3464",
3
+ "version": "2.0.17-dev.3469",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {