@indigoai-us/hq-cloud 6.14.40 → 6.14.42

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/src/cli/sync.ts CHANGED
@@ -2903,6 +2903,48 @@ function computePullPlan(
2903
2903
  continue;
2904
2904
  }
2905
2905
 
2906
+ // ── Untracked-local guard (unjournaled local file) ──────────────
2907
+ // Both `localChanged` and `remoteChanged` are gated on `!!journalEntry`,
2908
+ // so a key with NO journal entry reads "clean on both sides" and falls
2909
+ // all the way through to a plain `download` — silently replacing a local
2910
+ // file that exists on disk. There is no conflict, no `.conflict-` mirror
2911
+ // and no conflict-index record, so the loss is invisible unless someone
2912
+ // happens to know what the file should contain.
2913
+ //
2914
+ // This destroyed in-progress edits to
2915
+ // `companies/*/projects/*/prd.json` three times on 2026-08-01/02, but
2916
+ // nothing about it is prd- or project-specific: it fires for ANY synced
2917
+ // path whose journal entry is absent. Absence is common — a file created
2918
+ // on this machine and on a peer under the same key before either pushed,
2919
+ // a journal shard reset/lost/rebuilt (`readJournal` returns an empty
2920
+ // `files` map for a missing shard, so EVERY divergent local file is in
2921
+ // scope), a run under a different `HQ_STATE_DIR`, or an entry dropped by
2922
+ // scope-shrink or rescue.
2923
+ //
2924
+ // No journal entry means no evidence that local and remote ever agreed,
2925
+ // which is exactly when an overwrite is least safe. Route it through the
2926
+ // conflict path instead: the executor's convergence probe fetches the
2927
+ // remote once and, when the bytes already match (the ordinary
2928
+ // fresh-machine / rebuilt-journal case), reconciles silently — no
2929
+ // conflict, no mirror, journal stamped. Only genuine divergence surfaces,
2930
+ // and there local is PRESERVED as-is with the cloud copy written beside
2931
+ // it under `--on-conflict keep`, or the run halts under `abort`.
2932
+ // Cloud-authoritative paths (board.json, ontology/, signals/, …) are
2933
+ // unaffected — the conflict executor short-circuits those back to a
2934
+ // pull-wins download before any mirror is minted.
2935
+ if (!journalEntry) {
2936
+ items.push({
2937
+ action: "conflict",
2938
+ remoteFile,
2939
+ localPath,
2940
+ localHash,
2941
+ localMtime: localLstat!.mtime,
2942
+ localSize: isLocalSymlink ? 0 : localLstat!.size,
2943
+ localSnapshot: plannedLocalSnapshot,
2944
+ });
2945
+ continue;
2946
+ }
2947
+
2906
2948
  // Mirror the original 3-way merge from the inline loop. Tested by
2907
2949
  // `does NOT flag a pull conflict when only local changed since last
2908
2950
  // sync` and `detects conflicts with local changes…`.