@quolu/lattice 0.39.1 → 0.39.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.
@@ -250,8 +250,8 @@
250
250
  "from_task_id": { "$ref": "#/$defs/identifier" },
251
251
  "to_task_id": { "oneOf": [{ "const": "removed" }, { "$ref": "#/$defs/identifier" }] },
252
252
  "state_policy": {
253
- "enum": ["carry", "carry_reconciled_metadata", "reset_pending", "removed"],
254
- "$comment": "'removed'はto_task_id==='removed'の時だけ、他の3値はto_task_idがidentifierの時だけ許される(runtime cross-check)。runtime_task_migrationのdisposition投影とも一致していなければならない(validRuntimeTodoProjection)。"
253
+ "enum": ["carry", "carry_reconciled_metadata", "acquire_phase", "reset_pending", "removed"],
254
+ "$comment": "'removed'はto_task_id==='removed'の時だけ、他の4値はto_task_idがidentifierの時だけ許される(runtime cross-check)。runtime_task_migrationのdisposition投影とも一致していなければならない(validRuntimeTodoProjection)。"
255
255
  }
256
256
  }
257
257
  },
@@ -191,8 +191,8 @@
191
191
  "from_task_id": { "$ref": "#/$defs/identifier" },
192
192
  "to_task_id": { "oneOf": [{ "const": "removed" }, { "$ref": "#/$defs/identifier" }] },
193
193
  "state_policy": {
194
- "enum": ["carry", "carry_reconciled_metadata", "reset_pending", "removed"],
195
- "$comment": "'removed'はto_task_id==='removed'の時だけ、他の3値はto_task_idがidentifierの時だけ許される(runtime cross-check)。"
194
+ "enum": ["carry", "carry_reconciled_metadata", "acquire_phase", "reset_pending", "removed"],
195
+ "$comment": "'removed'はto_task_id==='removed'の時だけ、他の4値はto_task_idがidentifierの時だけ許される(runtime cross-check)。"
196
196
  }
197
197
  }
198
198
  },
@@ -209,7 +209,7 @@
209
209
  "properties": {
210
210
  "from_task_id": { "$ref": "#/$defs/identifier" },
211
211
  "to_task_id": { "oneOf": [{ "const": "removed" }, { "$ref": "#/$defs/identifier" }] },
212
- "state_policy": { "enum": ["carry", "carry_reconciled_metadata", "reset_pending", "removed"] }
212
+ "state_policy": { "enum": ["carry", "carry_reconciled_metadata", "acquire_phase", "reset_pending", "removed"] }
213
213
  }
214
214
  },
215
215
  "phaseMigrationEntry": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.39.1",
3
+ "version": "0.39.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",
@@ -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,32 @@ 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
+ }
3316
+ // 初回daemonにはrestart candidate pointerが無い。完了後に元socketの応答だけを失った
3317
+ // 同一requestをpointer recoveryへ流すと、既存activationをもう一度executeしてRUN_BUSYになる。
3318
+ // ledgerのexact request digestへ束縛されたcompleted responseをそのまま返す。
3319
+ if (known?.state === 'completed' && controlRequest.operation === 'activate'
3320
+ && !restarting) {
3321
+ if (known.request_digest !== controlRequest.request_digest) {
3322
+ throw new ManagedRuntimeError('REQUEST_ID_CONFLICT',
3323
+ '同一activate request_idへ異なるrequest digest');
3324
+ }
3325
+ return known.response;
3326
+ }
3296
3327
  if (known !== null && controlRequest.operation === 'activate') {
3297
3328
  const active = await resolveActiveRuntimePaths({ runDir }).catch(() => null);
3298
3329
  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
  }