@quolu/lattice 0.39.1 → 0.39.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.39.1",
3
+ "version": "0.39.2",
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",
@@ -2287,6 +2287,11 @@ export async function runManagedSupervisorDaemon({
2287
2287
  }
2288
2288
  activation = await activateController({ repoRoot, runId: request.request_id,
2289
2289
  adapterKind: legacyMeta.executor_adapter });
2290
+ const activationDelayMs = process.env.NODE_ENV === 'test'
2291
+ ? Number(process.env.LATTICE_INTERNAL_TEST_ACTIVATION_DELAY_MS ?? 0) : 0;
2292
+ if (Number.isSafeInteger(activationDelayMs) && activationDelayMs > 0) {
2293
+ await new Promise((resolve) => setTimeout(resolve, activationDelayMs));
2294
+ }
2290
2295
  if (process.env.NODE_ENV === 'test'
2291
2296
  && process.env.LATTICE_INTERNAL_TEST_CONTROLLER_COUNT === '2') {
2292
2297
  additionalActivations = [await activateController({ repoRoot, runId: request.request_id,
@@ -3293,6 +3298,21 @@ export async function runManagedSupervisorDaemon({
3293
3298
  known = { ...known, state: 'in_progress', response: null };
3294
3299
  }
3295
3300
  }
3301
+ // 初回activateがsocket timeoutを超えても、同一request_idの再照会を二重activateとして
3302
+ // 実行しない。初回daemon(run_meta.v1)に残るin_progressは、activation代入前後のどちらでも
3303
+ // 同じ処理がまだ走っている状態なのでunknownを返す。daemon再起動後(run_meta.v2)の
3304
+ // in_progressだけは、直後のrecovery分岐がdurable ledgerから処理を再開する。
3305
+ if (known?.state === 'in_progress' && controlRequest.operation === 'activate'
3306
+ && !restarting) {
3307
+ const events = await readBoundedJson(path.join(runDir, 'events.json'), 'run events').catch(() => []);
3308
+ const journal = await eventStore.readEvents();
3309
+ const result = buildControlResult({ operation: controlRequest.operation, outcome: 'unknown',
3310
+ eventHeadDigest: events.at(-1)?.event_digest ?? null,
3311
+ controlHeadDigest: journal.at(-1)?.event_digest ?? null, activeEpoch: 1,
3312
+ unmet: ['RUN_OUTCOME_UNKNOWN', '同一request_idのactivateはまだ処理中'] });
3313
+ return buildControlResponse(controlRequest, 'unknown', result,
3314
+ journal.at(-1)?.event_digest ?? null);
3315
+ }
3296
3316
  if (known !== null && controlRequest.operation === 'activate') {
3297
3317
  const active = await resolveActiveRuntimePaths({ runDir }).catch(() => null);
3298
3318
  if (active?.pointer?.activation_request_id === controlRequest.request_id
@@ -2110,8 +2110,13 @@ function stateMigrationFor(previous, revision) {
2110
2110
  if (revision.schema === 'lattice.phase_todo_revision.v3') {
2111
2111
  validateAcquirePhaseCarry(previous, revision, migration, idMap);
2112
2112
  } else {
2113
- const before = taskSemantics(previous.plan, migration.from_task_id, idMap, {});
2114
- const after = taskSemantics(revision.desired_plan, migration.to_task_id, new Map(), {});
2113
+ const predecessorTask = previous.plan.tasks
2114
+ .find(({ task_id }) => task_id === migration.from_task_id);
2115
+ const includeDesignMemo = typeof predecessorTask?.design_memo === 'string';
2116
+ const before = taskSemantics(previous.plan, migration.from_task_id, idMap,
2117
+ { includeDesignMemo });
2118
+ const after = taskSemantics(revision.desired_plan, migration.to_task_id, new Map(),
2119
+ { includeDesignMemo });
2115
2120
  if (canonicalizeTodoArtifact(before) !== canonicalizeTodoArtifact(after)) {
2116
2121
  fail('REVISION_INVALID', 'carry_semantics_changed', { from_task_id: migration.from_task_id });
2117
2122
  }