@indigoai-us/hq-cloud 6.18.59 → 6.18.60

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 (47) hide show
  1. package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
  2. package/dist/bin/sync-runner-watch-loop.js +5 -2
  3. package/dist/bin/sync-runner-watch-loop.js.map +1 -1
  4. package/dist/bin/sync-runner.d.ts.map +1 -1
  5. package/dist/bin/sync-runner.js +8 -1
  6. package/dist/bin/sync-runner.js.map +1 -1
  7. package/dist/cli/share.d.ts.map +1 -1
  8. package/dist/cli/share.js +88 -9
  9. package/dist/cli/share.js.map +1 -1
  10. package/dist/cli/sync.d.ts.map +1 -1
  11. package/dist/cli/sync.js +46 -8
  12. package/dist/cli/sync.js.map +1 -1
  13. package/dist/conflict-notices.d.ts +18 -1
  14. package/dist/conflict-notices.d.ts.map +1 -1
  15. package/dist/conflict-notices.js +27 -2
  16. package/dist/conflict-notices.js.map +1 -1
  17. package/dist/hq-root-recovery.d.ts +57 -5
  18. package/dist/hq-root-recovery.d.ts.map +1 -1
  19. package/dist/hq-root-recovery.js +172 -3
  20. package/dist/hq-root-recovery.js.map +1 -1
  21. package/dist/ignore.d.ts +29 -1
  22. package/dist/ignore.d.ts.map +1 -1
  23. package/dist/ignore.js +46 -5
  24. package/dist/ignore.js.map +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/lib/conflict-index.d.ts +22 -0
  30. package/dist/lib/conflict-index.d.ts.map +1 -1
  31. package/dist/lib/conflict-index.js +62 -1
  32. package/dist/lib/conflict-index.js.map +1 -1
  33. package/dist/personal-vault.d.ts.map +1 -1
  34. package/dist/personal-vault.js +2 -1
  35. package/dist/personal-vault.js.map +1 -1
  36. package/dist/session-log-capture.d.ts +10 -0
  37. package/dist/session-log-capture.d.ts.map +1 -1
  38. package/dist/session-log-capture.js +140 -14
  39. package/dist/session-log-capture.js.map +1 -1
  40. package/dist/sync-decision-log.d.ts +1 -1
  41. package/dist/sync-decision-log.d.ts.map +1 -1
  42. package/dist/sync-decision-log.js.map +1 -1
  43. package/dist/watch-owner-lease.d.ts +14 -0
  44. package/dist/watch-owner-lease.d.ts.map +1 -1
  45. package/dist/watch-owner-lease.js +17 -0
  46. package/dist/watch-owner-lease.js.map +1 -1
  47. package/package.json +1 -1
package/dist/cli/share.js CHANGED
@@ -22,7 +22,7 @@ import * as crypto from "crypto";
22
22
  import { bindObjectIOToContext, PresignObjectIO, RateLimitedError, resolveObjectIO, S3SdkObjectIO, } from "../object-io.js";
23
23
  import { primePrivateFolderUpload } from "../private-folder-transport.js";
24
24
  import { isUnderAnyRoot, readJournalForPass, readJournalScoped, readQuarantinedJournalPaths, writeJournal, setJournalSnapshotQuarantineListener, hashFile, hashSymlinkTarget, journalRows, journalEntryMatchesStat, journalFingerprintMatchesStat, dropJournalDecodeWindow, timestampsTooCoarseToTrust, updateEntry, PrematureJournalEntryError, removeEntry, isTombstone, normalizeEtag, PERSONAL_VAULT_JOURNAL_SLUG, migratePersonalVaultJournal, migrateToV2, } from "../journal.js";
25
- import { createIgnoreFilter, hasControlCharacters, isExpectedIgnore, isSecretPatternIgnore, isWithinSizeLimit, } from "../ignore.js";
25
+ import { createIgnoreFilter, hasControlCharacters, isExpectedIgnore, isPathExcludedFromSync, isSecretPatternIgnore, isWithinSizeLimit, } from "../ignore.js";
26
26
  import { wrapFilterWithPersonalVaultDefaults, } from "../personal-vault-exclusions.js";
27
27
  import { isSecretBearingVaultPath, isSkipSecretPathsEnabled, } from "../sync/secret-path-policy.js";
28
28
  import { getActiveFullPassDecodeWindow, getActiveFullPassUnitSize, } from "../sync/full-pass-caps.js";
@@ -32,7 +32,7 @@ import { fetchFileTombstones, } from "./tombstones.js";
32
32
  import { compileScopeMatcher, } from "../prefix-coalesce.js";
33
33
  import { hasRemoteChanged, isAccessDenied, resolveActiveCompany, resolveTransferConcurrency, resolveUploadByteBudget, readHostLoad, } from "../sync-core.js";
34
34
  import { buildConflictBackupPath, buildConflictId, buildConflictProbePath, readShortMachineId, } from "../lib/conflict-file.js";
35
- import { appendConflictEntry } from "../lib/conflict-index.js";
35
+ import { appendConflictEntry, findReusableConflictBackup } from "../lib/conflict-index.js";
36
36
  import { isLocallyIneligibleForPush } from "../lib/cloud-authoritative.js";
37
37
  import { isOntologyEntityKey, ONTOLOGY_MULTI_WRITER_FLAG, resolveOntologyEntityPush, } from "../lib/ontology-entity-push.js";
38
38
  import { entityIsFreshForCreate, outboxAllowsEntityPush, readOntologyOutbox, } from "../lib/ontology-outbox.js";
@@ -2937,7 +2937,7 @@ async function executeUploads(run, pushPlan, counters, conflictPaths) {
2937
2937
  preserved: "remote",
2938
2938
  decision,
2939
2939
  });
2940
- recordPushConflictNotice(run, item, conflictPath, "local", decision, remoteChangedSinceJournal);
2940
+ recordPushConflictNotice(run, item, conflictPath, "local", decision, remoteChangedSinceJournal, normalizeEtag(remoteMeta.etag));
2941
2941
  const journalEntry = journalRows(run.journal).get(relativePath);
2942
2942
  appendSyncDecision({
2943
2943
  ...(run.options.decisionLogPassId ? { passId: run.options.decisionLogPassId } : {}),
@@ -3243,6 +3243,35 @@ async function executeUploads(run, pushPlan, counters, conflictPaths) {
3243
3243
  const latest = await headRemoteFile(run.ctx, relativePath);
3244
3244
  const probe = await probeRemoteForWinner(run, item, latest?.lastModified ?? null, true, latest?.etag ?? remoteMeta?.etag);
3245
3245
  const decision = probe.decision;
3246
+ // The 412 only proves the remote etag moved, not that its content
3247
+ // differs. A second push of the same bytes (watcher push group and a
3248
+ // full pass racing on one path) lands first and leaves the remote
3249
+ // byte-identical to local; parking that body minted a backup and a
3250
+ // notice for every such race (39 session-log and 8 other parks on
3251
+ // 2026-10-09/10 had local == journal base and remote etag == journal
3252
+ // etag). Compare content first and reconcile the journal instead.
3253
+ if (decision?.reason === "identical" && latest?.etag) {
3254
+ const currentLocalHash = hashFile(item.absolutePath);
3255
+ const remoteBodyHash = probe.remoteContentHash();
3256
+ if (remoteBodyHash !== undefined && currentLocalHash === remoteBodyHash) {
3257
+ probe.discard();
3258
+ const conflictIndex = conflictPaths.lastIndexOf(relativePath);
3259
+ if (conflictIndex >= 0)
3260
+ conflictPaths.splice(conflictIndex, 1);
3261
+ const lstat = fs.lstatSync(item.absolutePath);
3262
+ updateEntry(run.journal, relativePath, currentLocalHash, lstat.size, "up", item.absolutePath, {
3263
+ remoteEtag: normalizeEtag(latest.etag),
3264
+ mtimeMs: lstat.mtimeMs,
3265
+ ctimeMs: ctimeToStamp(item.kind === "file" ? item.statAtHash : undefined, lstat),
3266
+ kind: "file",
3267
+ preserveSyncedAt: true,
3268
+ });
3269
+ checkpointShareJournal(run);
3270
+ run.emit({ type: "reconciled", path: relativePath, direction: "push" });
3271
+ counters.filesSkipped++;
3272
+ return;
3273
+ }
3274
+ }
3246
3275
  run.emit({
3247
3276
  type: "conflict",
3248
3277
  path: relativePath,
@@ -3269,7 +3298,7 @@ async function executeUploads(run, pushPlan, counters, conflictPaths) {
3269
3298
  preserved: "remote",
3270
3299
  decision,
3271
3300
  });
3272
- recordPushConflictNotice(run, item, conflictPath, "local", decision, true);
3301
+ recordPushConflictNotice(run, item, conflictPath, "local", decision, true, normalizeEtag(latest.etag));
3273
3302
  const journalEntry = journalRows(run.journal).get(relativePath);
3274
3303
  appendSyncDecision({
3275
3304
  ...(run.options.decisionLogPassId ? { passId: run.options.decisionLogPassId } : {}),
@@ -3336,7 +3365,7 @@ async function executeUploads(run, pushPlan, counters, conflictPaths) {
3336
3365
  preserved: "remote",
3337
3366
  decision,
3338
3367
  });
3339
- recordPushConflictNotice(run, item, conflictPath, "local", decision, true);
3368
+ recordPushConflictNotice(run, item, conflictPath, "local", decision, true, remoteMeta ? normalizeEtag(remoteMeta.etag) : undefined);
3340
3369
  probe.discard(); // no-op once parked; drops a failed park
3341
3370
  // Deliberately NOT `type: "error"` (a hold is a benign per-file
3342
3371
  // skip; the conflict event + index row above already record it).
@@ -3674,9 +3703,46 @@ async function probeRemoteForWinner(run, item, remoteMtime, remoteChangedSinceJo
3674
3703
  };
3675
3704
  const park = (detectedAt, machineId) => {
3676
3705
  const originalRelative = vaultKeyForLocalPath(run.hqRoot, item.absolutePath);
3706
+ const journalEntry = journalRows(run.journal).get(item.relativePath);
3707
+ // A re-park of the same divergence (same local bytes, same remote etag)
3708
+ // reuses the backup already on disk when it holds exactly the bytes this
3709
+ // probe fetched; the scratch probe is dropped and no new copy is written.
3710
+ const remoteEtagForDivergence = observedRemoteEtag ? normalizeEtag(observedRemoteEtag) : "";
3711
+ const reusable = findReusableConflictBackup(run.hqRoot, {
3712
+ originalPath: originalRelative,
3713
+ localHash: item.localHash,
3714
+ remoteHash: remoteEtagForDivergence,
3715
+ preserved: "remote",
3716
+ });
3717
+ if (reusable && fetched) {
3718
+ try {
3719
+ const existingHash = hashProbeEntry(localPathForVaultKey(run.hqRoot, reusable));
3720
+ if (existingHash === hashProbeEntry(probeAbs)) {
3721
+ discard();
3722
+ parked = true; // the scratch body is gone; later discard() is a no-op
3723
+ appendSyncDecision({
3724
+ ...(run.options.decisionLogPassId ? { passId: run.options.decisionLogPassId } : {}),
3725
+ company: run.options.personalMode === true ? "personal" : run.ctx.slug,
3726
+ vaultRelativePath: item.relativePath,
3727
+ decision: "park-reused",
3728
+ localHashBefore: item.localHash,
3729
+ journalBaseHash: journalEntry?.hash ?? null,
3730
+ journalBaseEtag: journalEntry?.remoteEtag ?? null,
3731
+ remoteEtag: remoteEtagForDivergence || null,
3732
+ remoteLastModified: remoteMtime?.toISOString() ?? null,
3733
+ localHashAfter: item.localHash,
3734
+ backupPath: reusable,
3735
+ backupHash: existingHash,
3736
+ });
3737
+ return reusable;
3738
+ }
3739
+ }
3740
+ catch {
3741
+ /* unreadable existing backup: park a fresh copy below */
3742
+ }
3743
+ }
3677
3744
  const backupKey = buildConflictBackupPath(originalRelative, detectedAt, machineId);
3678
3745
  const backupAbs = localPathForVaultKey(run.hqRoot, backupKey);
3679
- const journalEntry = journalRows(run.journal).get(item.relativePath);
3680
3746
  try {
3681
3747
  fs.mkdirSync(path.dirname(backupAbs), { recursive: true });
3682
3748
  const expectedRemoteHash = fetched?.downloaded?.contentHash ?? hashProbeEntry(probeAbs);
@@ -3787,6 +3853,16 @@ async function probeRemoteForWinner(run, item, remoteMtime, remoteChangedSinceJo
3787
3853
  decision,
3788
3854
  park,
3789
3855
  discard,
3856
+ remoteContentHash: () => {
3857
+ if (!fetched || parked)
3858
+ return undefined;
3859
+ try {
3860
+ return hashProbeEntry(probeAbs);
3861
+ }
3862
+ catch {
3863
+ return undefined;
3864
+ }
3865
+ },
3790
3866
  takeBody: () => {
3791
3867
  if (!fetched || parked)
3792
3868
  return undefined;
@@ -3844,7 +3920,7 @@ function recordPushConflict(run, item, fields) {
3844
3920
  });
3845
3921
  }
3846
3922
  }
3847
- function recordPushConflictNotice(run, item, backupPath, sideKept, decision, remoteChangedSinceJournal = false) {
3923
+ function recordPushConflictNotice(run, item, backupPath, sideKept, decision, remoteChangedSinceJournal = false, remoteEtag) {
3848
3924
  try {
3849
3925
  recordConflictParked({
3850
3926
  scope: run.options.personalMode === true ? "personal" : "company",
@@ -3856,6 +3932,9 @@ function recordPushConflictNotice(run, item, backupPath, sideKept, decision, rem
3856
3932
  : sideKept === "local" ? "local-newer" : "remote-newer",
3857
3933
  sideKept,
3858
3934
  parkedAt: new Date().toISOString(),
3935
+ ...(item.localHash && remoteEtag
3936
+ ? { localHash: item.localHash, remoteEtag }
3937
+ : {}),
3859
3938
  });
3860
3939
  writePendingConflictNoticesToSyncLastPass(readPendingConflictNotices());
3861
3940
  }
@@ -3990,7 +4069,7 @@ async function adoptRemoteOnPush(run, item, remoteHash, decision, probe) {
3990
4069
  preserved: "local",
3991
4070
  decision,
3992
4071
  });
3993
- recordPushConflictNotice(run, item, backupKey, "remote", decision);
4072
+ recordPushConflictNotice(run, item, backupKey, "remote", decision, false, effectiveRemoteHash);
3994
4073
  // Persist the converged remote-backed entry immediately. A conflict
3995
4074
  // resolution is a completed transfer even though the push counter is
3996
4075
  // recorded as skipped, and an interrupted pass must not revive it.
@@ -5793,7 +5872,7 @@ companyScoped = true, skipSecretPaths = false, excludedPaths = new Set()) {
5793
5872
  litterToDelete.push(relativeKey);
5794
5873
  continue;
5795
5874
  }
5796
- if (!shouldSync(localPath, false) && !shouldSync(localPath, true))
5875
+ if (isPathExcludedFromSync(shouldSync, localPath))
5797
5876
  continue;
5798
5877
  // Ephemeral artifacts (conflict mirrors) never propagate-delete via the
5799
5878
  // normal path — see EPHEMERAL_PATH_PATTERN doc. NOTE: this is a no-op