@quolu/lattice 0.114.2 → 0.114.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/chart-cli.mjs +16 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.114.2",
3
+ "version": "0.114.3",
4
4
  "description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
5
5
  "author": {
6
6
  "name": "Quo / クオ at kitepon.dev",
package/src/chart-cli.mjs CHANGED
@@ -254,8 +254,10 @@ async function runSensor(command, dir) {
254
254
 
255
255
  /**
256
256
  * K7 sync. Named protection: never reset, clean, force or repoint; tracked edits make it `dirty` and a HEAD that is
257
- * not the accepted baseline makes it `diverged` (nothing moves). Self-exit: a failed step is reported and the next
258
- * sync tries again. HEAD moves only from the baseline. Only the first fetch is depth-1; later fetches keep the previous tip
257
+ * not the accepted baseline makes it `diverged` (nothing moves). Self-exits: a failed step is reported and the next
258
+ * sync tries again; the one state that is not an edit, our own checkout interrupted after it wrote index and work tree
259
+ * but before it moved HEAD (HEAD = baseline, index and work tree = FETCH_HEAD, a descendant), is finished.
260
+ * HEAD moves only from the baseline. Only the first fetch is depth-1; later fetches keep the previous tip
259
261
  * an ancestor of the new one (gate 4's merged-sha check and the structure adapter's `rev-list baseline..HEAD` need that).
260
262
  */
261
263
  async function chartRepoSync({ cwd, env }) {
@@ -281,13 +283,22 @@ async function chartRepoSync({ cwd, env }) {
281
283
  await mkdir(path.dirname(exclude), { recursive: true });
282
284
  await appendFile(exclude, `${excluded === '' || excluded.endsWith('\n') ? '' : '\n'}.lattice/\n`);
283
285
  }
284
- if (await git('status', ['status', '--porcelain', '--untracked-files=no'])) return result('dirty');
286
+ // Charts moved before 0.101.0 kept the baseline in refs/remotes/origin/<branch>.
287
+ let accepted = meta.repo.accepted_tip ?? await optional(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}`]);
288
+ if (await git('status', ['status', '--porcelain', '--untracked-files=no'])) {
289
+ const interrupted = await optional(['rev-parse', '--verify', '--quiet', 'FETCH_HEAD^{commit}']);
290
+ const holds = (args) => runGit('git', args, { cwd: dir }).then(() => true, () => false);
291
+ if (interrupted === null || accepted === null || accepted !== await optional(['rev-parse', '--verify', '--quiet', 'HEAD'])
292
+ || !await holds(['merge-base', '--is-ancestor', 'HEAD', interrupted])
293
+ || !await holds(['diff', '--cached', '--quiet', interrupted]) || !await holds(['diff', '--quiet'])) return result('dirty');
294
+ await git('checkout', ['checkout', '--quiet', '-B', branch, interrupted]);
295
+ accepted = interrupted;
296
+ await writeTodoChartMeta({ repoRoot: dir, patch: { repo: { url, branch, accepted_tip: interrupted } } });
297
+ }
285
298
  // A lazily fetching (promisor) clone fetches each missing blob on every full object walk; never fetch lazily.
286
299
  for (const key of ['remote.origin.promisor', 'remote.origin.partialclonefilter', 'extensions.partialclone']) {
287
300
  await optional(['config', '--unset-all', key]);
288
301
  }
289
- // Charts moved before 0.101.0 kept the baseline in refs/remotes/origin/<branch>.
290
- const accepted = meta.repo.accepted_tip ?? await optional(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branch}`]);
291
302
  const head = await optional(['rev-parse', '--verify', '--quiet', 'HEAD']);
292
303
  await git('fetch', ['fetch', '--quiet', ...(head === null ? ['--depth=1'] : []), '--no-tags', url, branch]);
293
304
  const tip = await git('fetch', ['rev-parse', 'FETCH_HEAD']);