@evomap/evolver-cli 2.0.41 → 2.0.44

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 (50) hide show
  1. package/dist/autoRecall.d.ts +24 -5
  2. package/dist/autoRecall.js +233 -12
  3. package/dist/autoexec.d.ts +69 -10
  4. package/dist/autoexec.js +847 -137
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.js +71 -26
  7. package/dist/cliContracts.js +29 -7
  8. package/dist/cliEntry.d.ts +3 -0
  9. package/dist/cliEntry.js +63 -0
  10. package/dist/commandCatalog.d.ts +1 -0
  11. package/dist/commandCatalog.js +1 -0
  12. package/dist/contextDelivery.d.ts +12 -0
  13. package/dist/contextDelivery.js +139 -0
  14. package/dist/cycleConsumer.js +9 -1
  15. package/dist/dispatch.js +6 -0
  16. package/dist/feedbackOutbox.d.ts +96 -0
  17. package/dist/feedbackOutbox.js +510 -0
  18. package/dist/feedbackOutboxCli.d.ts +7 -0
  19. package/dist/feedbackOutboxCli.js +208 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +286 -69
  22. package/dist/lifecycle.d.ts +18 -0
  23. package/dist/lifecycle.js +130 -3
  24. package/dist/lifecycleBootstrapTransaction.js +1 -6
  25. package/dist/liveStatus.d.ts +27 -0
  26. package/dist/liveStatus.js +197 -0
  27. package/dist/outboxLock.d.ts +7 -0
  28. package/dist/outboxLock.js +141 -0
  29. package/dist/promptRecallHook.d.ts +7 -22
  30. package/dist/promptRecallHook.js +20 -489
  31. package/dist/promptRecallRuntime.d.ts +24 -0
  32. package/dist/promptRecallRuntime.js +678 -0
  33. package/dist/promptRecallShared.d.ts +18 -0
  34. package/dist/promptRecallShared.js +119 -0
  35. package/dist/recall.js +27 -6
  36. package/dist/runtimeTelemetry.d.ts +9 -0
  37. package/dist/runtimeTelemetry.js +16 -0
  38. package/dist/sessionIngest.d.ts +25 -2
  39. package/dist/sessionIngest.js +196 -32
  40. package/dist/setupHooks.js +63 -13
  41. package/dist/setupHooksLifecycle.js +39 -17
  42. package/dist/skill2gep.d.ts +11 -0
  43. package/dist/skill2gep.js +23 -3
  44. package/dist/solo/mode.js +4 -0
  45. package/dist/taskCommitments.d.ts +4 -2
  46. package/dist/taskCommitments.js +208 -114
  47. package/dist/taskOutcomeOutbox.d.ts +83 -0
  48. package/dist/taskOutcomeOutbox.js +553 -0
  49. package/dist/workflowRuntime.js +12 -0
  50. package/package.json +11 -7
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env -S node --
2
2
  export {};
package/dist/cli.js CHANGED
@@ -1,27 +1,72 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env -S node --
2
2
  import { settleCliProcess } from './cliLifecycle.js';
3
- import { bootstrap } from '@evomap/evolver-core';
4
- const argv = process.argv.slice(2);
5
- // Emit deprecation warnings for any V1 env vars still present in the environment.
6
- bootstrap.checkV1EnvCompat(process.env);
7
- async function main() {
8
- if (argv[0] === 'proxy-token') {
9
- const { runProxyToken } = await import('./proxyToken.js');
10
- return runProxyToken(argv.slice(1));
11
- }
12
- if (argv[0] === 'inject' && argv[1] === 'prompt-recall') {
13
- const recallMode = String(process.env['EVOLVER_RECALL_MODE'] ?? '').trim().toLowerCase();
14
- const hasEnvFile = Boolean(process.env['EVOLVER_ENV_FILE']?.trim());
15
- if (!hasEnvFile && recallMode !== 'shadow' && recallMode !== 'enforce') {
16
- process.stdout.write('{}\n');
17
- return 0;
18
- }
19
- const { runPromptRecallHook } = await import('./promptRecallHook.js');
20
- return runPromptRecallHook(argv.slice(2));
21
- }
22
- const { dispatch } = await import('./dispatch.js');
23
- // Single dispatch path (registry in dispatch.ts): async handler if the verb is registered, else the runCli core.
24
- // Promise.resolve normalizes the sync (runCli → number) and async (handler → Promise<number>) branches to one exit.
25
- return await Promise.resolve(dispatch(argv));
26
- }
27
- void settleCliProcess(main);
3
+ import { isReadOnlyStatusInvocation, runCliEntry } from './cliEntry.js';
4
+ const workerFlag = '--internal-posix-snapshot-worker';
5
+ if (process.argv[2] === workerFlag && process.argv.length === 3) {
6
+ void import('@evomap/evolver-core/snapshot-worker').then(({ runPosixSnapshotWorker }) => runPosixSnapshotWorker()).then(() => { process.exitCode = 0; }, () => { process.exitCode = 1; });
7
+ }
8
+ else if (process.argv[2] === '--internal-protected-audit-service' && process.argv.length === 4) {
9
+ void import('@evomap/evolver-core/protected-audit-service').then(({ runProtectedAuditService }) => runProtectedAuditService(process.argv[3])).then(() => { process.exitCode = 0; }, () => { process.exitCode = 1; });
10
+ }
11
+ else if (process.argv[2] === '--internal-protected-audit-ready' && process.argv.length === 4) {
12
+ void import('@evomap/evolver-core/protected-audit-service').then(({ runProtectedAuditReady }) => runProtectedAuditReady(process.argv[3])).then(() => { process.exitCode = 0; }, () => { process.exitCode = 1; });
13
+ }
14
+ else if (process.argv[2] === '--internal-protected-audit-rpc-child' && process.argv.length === 3) {
15
+ void settleCliProcess(async () => {
16
+ const { runProtectedAuditRpcChild } = await import('@evomap/evolver-core/protected-audit-rpc-child');
17
+ await runProtectedAuditRpcChild();
18
+ return Number(process.exitCode ?? 0);
19
+ });
20
+ }
21
+ else if (process.argv[2] === '--internal-protected-audit-migrate' && process.argv.length === 4) {
22
+ void settleCliProcess(async () => {
23
+ const { runProtectedAuditMigration } = await import('@evomap/evolver-core/protected-audit-migration');
24
+ runProtectedAuditMigration(process.argv[3]);
25
+ return 0;
26
+ });
27
+ }
28
+ else if (process.argv[2] === '--internal-protected-audit-verify' && process.argv.length === 4) {
29
+ void settleCliProcess(async () => {
30
+ const { runProtectedAuditMigration } = await import('@evomap/evolver-core/protected-audit-migration');
31
+ runProtectedAuditMigration(process.argv[3], 'verify');
32
+ return 0;
33
+ });
34
+ }
35
+ else if (process.argv[2] === '--internal-protected-audit-upgrade-verify' && process.argv.length === 4) {
36
+ void settleCliProcess(async () => {
37
+ const { runProtectedAuditMigration } = await import('@evomap/evolver-core/protected-audit-migration');
38
+ runProtectedAuditMigration(process.argv[3], 'upgrade-verify');
39
+ return 0;
40
+ });
41
+ }
42
+ else if (process.argv[2] === '--internal-protected-audit-fence' && process.argv.length === 4) {
43
+ void settleCliProcess(async () => {
44
+ const { runProtectedAuditMigration } = await import('@evomap/evolver-core/protected-audit-migration');
45
+ runProtectedAuditMigration(process.argv[3], 'fence');
46
+ return 0;
47
+ });
48
+ }
49
+ else if (process.argv[2] === '--internal-protected-audit-unfence' && process.argv.length === 4) {
50
+ void settleCliProcess(async () => {
51
+ const { runProtectedAuditMigration } = await import('@evomap/evolver-core/protected-audit-migration');
52
+ runProtectedAuditMigration(process.argv[3], 'unfence');
53
+ return 0;
54
+ });
55
+ }
56
+ else {
57
+ // Version is a pure metadata query used to authenticate an installer binary
58
+ // even while the required marker is published and activation is incomplete.
59
+ // Internal workers must not initialize the service/schema graph within their
60
+ // caller's I/O deadline. Normal commands retain the original admission gate.
61
+ void settleCliProcess(async () => {
62
+ const { configureProtectedAuditRpcChildCommand, requireProtectedAuditServiceForProcess } = await import('@evomap/evolver-core/protected-audit-rpc-child');
63
+ const readOnlyStatus = isReadOnlyStatusInvocation(process.argv.slice(2));
64
+ if (!(process.argv.length === 3 && process.argv[2] === '--version') && !readOnlyStatus)
65
+ requireProtectedAuditServiceForProcess();
66
+ const { configurePosixSnapshotWorkerCommand } = await import('@evomap/evolver-core/snapshot-worker');
67
+ const entry = process.argv[1] && /\.[cm]?js$/.test(process.argv[1]) ? [process.argv[1]] : [];
68
+ configurePosixSnapshotWorkerCommand({ command: process.execPath, args: [...entry, workerFlag] });
69
+ configureProtectedAuditRpcChildCommand({ command: process.execPath, args: [...entry, '--internal-protected-audit-rpc-child'] });
70
+ return runCliEntry(process.argv.slice(2));
71
+ });
72
+ }
@@ -208,7 +208,7 @@ export async function runPublishCommand(args, deps = {}) {
208
208
  // A field-level refusal is a defect in the RECORD, not a verdict on the work in it. Read the Hub's own
209
209
  // `details[]`, mend what is mechanically derivable, and (only when asked) try once more — otherwise the
210
210
  // envelope still carries the plan, so the operator can see the asset is salvageable instead of losing it.
211
- const validationAttempt = await callHubWithRepair(validate, bundle.sanitized, parsed.repair === true);
211
+ const validationAttempt = await callHubWithRepair(validate, referenceOnly ? structuredClone(bundle.sanitized) : bundle.sanitized, parsed.repair === true);
212
212
  const validation = validationAttempt.result;
213
213
  let effectiveAssets = validationAttempt.assets;
214
214
  const validationCredits = extractCredits(validation.body);
@@ -242,7 +242,8 @@ export async function runPublishCommand(args, deps = {}) {
242
242
  ...repairEnvelopeField(validationAttempt),
243
243
  }), 1);
244
244
  }
245
- if (referenceOnly && !validReferenceReceipt(validation.body, bundle.sanitized, true)) {
245
+ if (referenceOnly && (wire.canonicalize(validationAttempt.assets) !== wire.canonicalize(bundle.sanitized)
246
+ || !validReferenceReceipt(validation.body, bundle.sanitized, true))) {
246
247
  return write(publishFailure('quality_gate_failed', 'reference validation response does not attest the submitted non-execution pair', {
247
248
  retryable: false, mode: parsed.dryRun ? 'dry_run' : 'publish', gates: { ...bundle.gates, quality: 'fail' },
248
249
  }), 1);
@@ -250,7 +251,7 @@ export async function runPublishCommand(args, deps = {}) {
250
251
  if (parsed.dryRun)
251
252
  return write(dryRunEnvelope(bundle, validationCredits, undefined, validationAttempt), 0);
252
253
  const publish = deps.publish ?? transport.publish;
253
- const publishAttempt = await callHubWithRepair(publish, effectiveAssets, parsed.repair === true);
254
+ const publishAttempt = await callHubWithRepair(publish, referenceOnly ? structuredClone(bundle.sanitized) : effectiveAssets, parsed.repair === true);
254
255
  const published = publishAttempt.result;
255
256
  effectiveAssets = publishAttempt.assets;
256
257
  const repairApplied = mergeRepairAttempts(validationAttempt, publishAttempt);
@@ -347,7 +348,7 @@ export async function runPublishCommand(args, deps = {}) {
347
348
  }
348
349
  async function callHubWithRepair(call, assets, allowRepair) {
349
350
  const first = await call(assets);
350
- if (first.ok)
351
+ if (first.ok || hasReferenceEvidenceMode(assets))
351
352
  return { result: first, assets, applied: false, entries: [] };
352
353
  const plan = planBundleRepair(assets, first.body);
353
354
  // Retry only when the WHOLE bundle is mended. One unrepairable asset means the Hub will refuse the bundle
@@ -809,7 +810,7 @@ function sanitizePublishBundle(original, env) {
809
810
  // 已绑定记录的 business-id 引用同样属于完整内容,不能在验证后改成另一种引用并重算资产。
810
811
  // 脱敏若真正改变内容,后续 host ledger 会要求重新验证;人工无声明路径保留旧引用规范化。
811
812
  if (hub.requiresPublishBinding(original))
812
- return sanitized;
813
+ return hub.rebindSanitizedEvolutionEventBundle(original, sanitized);
813
814
  const finalGeneIdByOriginalRef = new Map();
814
815
  for (let i = 0; i < original.length; i++) {
815
816
  const source = original[i];
@@ -821,7 +822,7 @@ function sanitizePublishBundle(original, env) {
821
822
  finalGeneIdByOriginalRef.set(ref, finalAsset.asset_id);
822
823
  }
823
824
  }
824
- return sanitized.map((asset, index) => {
825
+ const rebound = sanitized.map((asset, index) => {
825
826
  if (asset.type !== 'Capsule')
826
827
  return asset;
827
828
  const originalGeneRef = stringField(original[index], 'gene');
@@ -832,6 +833,7 @@ function sanitizePublishBundle(original, env) {
832
833
  return asset;
833
834
  return withRecomputedAssetId({ ...asset, gene: finalGeneId });
834
835
  });
836
+ return hub.rebindSanitizedEvolutionEventBundle(original, rebound);
835
837
  }
836
838
  function withRecomputedAssetId(asset) {
837
839
  const assetId = wire.computeAssetId(asset);
@@ -1033,6 +1035,18 @@ function checkBundle(bundle) {
1033
1035
  const geneIds = new Set([gene.asset_id, stringField(gene, 'id')].filter((id) => Boolean(id)));
1034
1036
  if (!geneIds.has(String(capsule['gene'] ?? '')))
1035
1037
  return { ok: false, message: 'gene must publish with its capsule' };
1038
+ if (eventsFound.length > 0) {
1039
+ try {
1040
+ hub.assertEvolutionEventPublishBundle(bundle);
1041
+ }
1042
+ catch (error) {
1043
+ return {
1044
+ ok: false,
1045
+ message: error instanceof Error && /^publish_event_[a-z_]+$/.test(error.message)
1046
+ ? error.message : 'publish_event_bundle_invalid',
1047
+ };
1048
+ }
1049
+ }
1036
1050
  return { ok: true };
1037
1051
  }
1038
1052
  function finalPayloadLeakCheck(bundle, env) {
@@ -1240,7 +1254,15 @@ function createDefaultTransport(deps, opts = {}) {
1240
1254
  return {
1241
1255
  fetchAssetById: (assetId) => connected.hub.fetchAssetById(assetId),
1242
1256
  validate: (bundle) => call('/a2a/validate', 'validate', bundle),
1243
- publish: (bundle) => withLocalPublishBinding(bundle, env, (authorized) => call('/a2a/publish', 'publish', authorized), deps.resolveProxyClient),
1257
+ publish: (bundle) => {
1258
+ if (hasReferenceEvidenceMode(bundle)) {
1259
+ const assets = structuredClone(bundle);
1260
+ // Reference originals cannot enter execution normalization or acquire a host execution binding.
1261
+ validateReferencePublishBundle(assets);
1262
+ return call('/a2a/publish', 'publish', assets);
1263
+ }
1264
+ return withLocalPublishBinding(bundle, env, (authorized) => call('/a2a/publish', 'publish', authorized), deps.resolveProxyClient);
1265
+ },
1244
1266
  ...(opts.composeRecipe === false ? {} : {
1245
1267
  composeRecipe: (payload) => hub.composeRecipeAfterAssetPublish(connected.hub, payload),
1246
1268
  }),
@@ -0,0 +1,3 @@
1
+ export declare function isReadOnlyStatusInvocation(argv: readonly string[]): boolean;
2
+ /** Executable-only routing; launchers retain their exit contract and prompt hooks arm a process watchdog. */
3
+ export declare function runCliEntry(argv: string[]): Promise<number>;
@@ -0,0 +1,63 @@
1
+ import { checkV1EnvCompat } from '@evomap/evolver-core/v1-env-compat';
2
+ export function isReadOnlyStatusInvocation(argv) {
3
+ return argv[0] === 'status' && argv.slice(1).some(arg => arg === '--help' || arg === '-h' || arg === '--live' || arg.startsWith('--live='));
4
+ }
5
+ /** Executable-only routing; launchers retain their exit contract and prompt hooks arm a process watchdog. */
6
+ export async function runCliEntry(argv) {
7
+ checkV1EnvCompat(process.env);
8
+ if (isReadOnlyStatusInvocation(argv)) {
9
+ const { runLiveStatus } = await import('./liveStatus.js');
10
+ return runLiveStatus(argv.slice(1));
11
+ }
12
+ if (argv[0] === 'proxy-token') {
13
+ const { runProxyToken } = await import('./proxyToken.js');
14
+ return runProxyToken(argv.slice(1));
15
+ }
16
+ if (argv[0] === 'inject' && argv[1] === 'prompt-recall') {
17
+ const recallMode = String(process.env['EVOLVER_RECALL_MODE'] ?? '').trim().toLowerCase();
18
+ const hasEnvFile = Boolean(process.env['EVOLVER_ENV_FILE']?.trim());
19
+ if (!hasEnvFile && recallMode !== 'shadow' && recallMode !== 'enforce') {
20
+ process.stdout.write('{}\n');
21
+ return 0;
22
+ }
23
+ let settledCode;
24
+ const finish = () => process.exit(settledCode === undefined ? 1 : Number(process.exitCode ?? settledCode));
25
+ // Own the disposable process before imports or hook work can suspend. The
26
+ // pre-output allowance covers stdin (250ms), selection (750ms), stdout and
27
+ // startup overhead; it does not pretend to interrupt synchronous JS/native work.
28
+ let watchdog = setTimeout(finish, 3000);
29
+ let outputWritten = false;
30
+ try {
31
+ const { runPromptRecallHook } = await import('./promptRecallHook.js');
32
+ const { writeHookStdout } = await import('./promptRecallShared.js');
33
+ const code = await runPromptRecallHook(argv.slice(2), {
34
+ stdout: text => writeHookStdout(text, { destroyOnTimeout: true }),
35
+ stdoutWithSettlement: (text, onSettled) => writeHookStdout(text, { destroyOnTimeout: true, onSettled }),
36
+ onOutputWritten: () => {
37
+ // Only this disposable process owns forced exit. Confirmed stdout does
38
+ // not confirm hook settlement: an unfinished hook must never exit success.
39
+ // A pending Promise does not keep Node alive. Own one referenced guard
40
+ // until settlement; afterward it only guards lingering OS handles.
41
+ if (outputWritten)
42
+ return;
43
+ outputWritten = true;
44
+ clearTimeout(watchdog);
45
+ watchdog = setTimeout(finish, 1000);
46
+ if (settledCode !== undefined)
47
+ watchdog.unref();
48
+ },
49
+ });
50
+ settledCode = code;
51
+ return code;
52
+ }
53
+ catch (error) {
54
+ settledCode = 1;
55
+ throw error;
56
+ }
57
+ finally {
58
+ watchdog.unref();
59
+ }
60
+ }
61
+ const { dispatch } = await import('./dispatch.js');
62
+ return await Promise.resolve(dispatch(argv));
63
+ }
@@ -12,6 +12,7 @@ export declare const COMMAND_GROUPS: {
12
12
  readonly run: "Evolution";
13
13
  readonly cycle: "Evolution";
14
14
  readonly autoexec: "Evolution";
15
+ readonly 'autoexec-feedback': "Evolution";
15
16
  readonly solidify: "Evolution";
16
17
  readonly distill: "Evolution";
17
18
  readonly review: "Evolution";
@@ -25,6 +25,7 @@ export const COMMAND_GROUPS = {
25
25
  run: 'Evolution',
26
26
  cycle: 'Evolution',
27
27
  autoexec: 'Evolution',
28
+ 'autoexec-feedback': 'Evolution',
28
29
  solidify: 'Evolution',
29
30
  distill: 'Evolution',
30
31
  review: 'Evolution',
@@ -0,0 +1,12 @@
1
+ import type { PreparedContextDelivery } from '@evomap/evolver-core/prompt-recall';
2
+ export { waitContextDelivery } from './promptRecallShared.js';
3
+ /** Both production context entrypoints share the same prepare -> actual callback -> projection protocol. */
4
+ export declare function deliverContextOutput(options: {
5
+ text: string;
6
+ prepare?: (options: {
7
+ deadlineAt: number;
8
+ }) => PreparedContextDelivery | Promise<PreparedContextDelivery>;
9
+ stdout?: (text: string) => void | Promise<void>;
10
+ stdoutWithSettlement?: (text: string, onSettled: (written: boolean) => void) => Promise<void>;
11
+ onOutputWritten?: () => void;
12
+ }): Promise<'written' | 'prepare_failed' | 'output_unknown'>;
@@ -0,0 +1,139 @@
1
+ import { contextDeliveryRejectionCode, startContextReadStage } from '@evomap/evolver-core/prompt-recall';
2
+ import { waitContextDelivery, writeHookStdout } from './promptRecallShared.js';
3
+ export { waitContextDelivery } from './promptRecallShared.js';
4
+ /** Both production context entrypoints share the same prepare -> actual callback -> projection protocol. */
5
+ export async function deliverContextOutput(options) {
6
+ const deadlineAt = Date.now() + 200;
7
+ const finishPreparation = startContextReadStage('delivery_prepare');
8
+ let failureCode = 'timeout';
9
+ const { text, prepare, stdout, stdoutWithSettlement, onOutputWritten } = options;
10
+ let prepared;
11
+ const release = (owned) => {
12
+ try {
13
+ owned.release();
14
+ }
15
+ catch { /* Release is unconfirmed; the durable core/service owner remains authoritative. */ }
16
+ };
17
+ const unused = (owned) => {
18
+ const finishCleanup = startContextReadStage('delivery_cleanup');
19
+ try {
20
+ owned.outputUnknown();
21
+ }
22
+ catch {
23
+ finishCleanup?.('rejected');
24
+ return;
25
+ } // Keep the capability when its unknown-output transition is unconfirmed.
26
+ try {
27
+ owned.release();
28
+ finishCleanup?.('fulfilled');
29
+ }
30
+ catch {
31
+ finishCleanup?.('rejected'); /* The durable owner remains authoritative. */
32
+ }
33
+ };
34
+ const valid = (owned) => Boolean(owned && typeof owned.confirmOutput === 'function' && typeof owned.outputUnknown === 'function'
35
+ && typeof owned.project === 'function' && typeof owned.release === 'function');
36
+ // Start the one absolute budget before invoking preparation. Its original
37
+ // continuation retains ownership after caller timeout; only a timely durable
38
+ // capability admits stdout, and a late one can never dispatch or project.
39
+ let expired = false;
40
+ try {
41
+ const attempt = prepare?.({ deadlineAt });
42
+ if (!prepare)
43
+ failureCode = 'not_configured';
44
+ const continuation = Promise.resolve(attempt).then(owned => {
45
+ if (!valid(owned)) {
46
+ if (prepare)
47
+ failureCode = 'invalid_capability';
48
+ return undefined;
49
+ }
50
+ if (expired || Date.now() >= deadlineAt) {
51
+ failureCode = 'deadline';
52
+ unused(owned);
53
+ return undefined;
54
+ }
55
+ return owned;
56
+ }, error => { failureCode = contextDeliveryRejectionCode(error); return undefined; });
57
+ prepared = await waitContextDelivery(continuation, Math.max(0, deadlineAt - Date.now()));
58
+ if (!prepared) {
59
+ expired = true;
60
+ finishPreparation?.('rejected', failureCode);
61
+ return 'prepare_failed';
62
+ }
63
+ if (Date.now() >= deadlineAt) {
64
+ expired = true;
65
+ unused(prepared);
66
+ finishPreparation?.('rejected', 'deadline');
67
+ return 'prepare_failed';
68
+ }
69
+ finishPreparation?.('fulfilled', 'prepared');
70
+ }
71
+ catch (error) {
72
+ finishPreparation?.('rejected', contextDeliveryRejectionCode(error));
73
+ return 'prepare_failed';
74
+ }
75
+ let settled = false;
76
+ let outputWritten = false;
77
+ let projection;
78
+ const actual = (written) => {
79
+ if (settled)
80
+ return;
81
+ settled = true;
82
+ outputWritten = written;
83
+ if (!written) {
84
+ try {
85
+ prepared?.outputUnknown();
86
+ }
87
+ catch { /* Private transition remains retained. */ }
88
+ if (prepared)
89
+ release(prepared);
90
+ return;
91
+ }
92
+ // Confirmation precedes optional logging and the caller's completion notification.
93
+ try {
94
+ prepared?.confirmOutput();
95
+ }
96
+ catch { /* Same capability is retained for confirmation-only recovery. */ }
97
+ try {
98
+ onOutputWritten?.();
99
+ }
100
+ catch { /* Observer cannot invalidate stdout. */ }
101
+ const owned = prepared;
102
+ try {
103
+ // Join the original projection, including after our bounded wait. A
104
+ // cleanup RPC failure cannot revoke the physical write acknowledgement
105
+ // or become a detached rejection. It does not prove the owner released.
106
+ projection = owned.project({ deadlineAt: Date.now() + 200 }).catch(() => undefined).then(() => release(owned));
107
+ }
108
+ catch { /* A malformed synchronous projector retains its original owner for recovery. */ }
109
+ };
110
+ try {
111
+ if (stdoutWithSettlement) {
112
+ // Adapter completion may lag its actual write callback indefinitely.
113
+ // Bound only caller waiting; the original callback still owns settlement,
114
+ // and a late rejection cannot revoke a write or dispatch output again.
115
+ await waitContextDelivery(Promise.resolve().then(() => stdoutWithSettlement(text, actual)), 1000);
116
+ }
117
+ else if (stdout) {
118
+ // A custom callback is privileged. Its actual promise owns the attempt even after our bounded wait.
119
+ const run = Promise.resolve().then(() => stdout(text)).then(() => { actual(true); return true; }, () => { actual(false); return false; });
120
+ const result = await waitContextDelivery(run, 1000);
121
+ if (!result)
122
+ return 'output_unknown';
123
+ }
124
+ else {
125
+ await writeHookStdout(text, { onSettled: actual });
126
+ }
127
+ }
128
+ catch {
129
+ // Adapter failure cannot revoke the original callback's acknowledgement.
130
+ // Without one, timeout is not settlement and the callback still owns prepared.
131
+ if (!outputWritten)
132
+ return 'output_unknown';
133
+ }
134
+ if (!outputWritten)
135
+ return 'output_unknown'; // Adapter completion alone is not an actual write acknowledgement.
136
+ if (projection)
137
+ await waitContextDelivery(projection);
138
+ return 'written';
139
+ }
@@ -191,13 +191,16 @@ function printRuntimeCapabilities() {
191
191
  }
192
192
  }
193
193
  function resolveMaterialCycleDeps(deps = {}) {
194
+ assetstore.assertPromptProviderNotProxy(deps.store);
194
195
  const materialStore = deps.materialStore ?? new materialNs.MaterialStore({ path: events.materialStorePath() });
195
196
  const consumer = deps.consumer ?? new materialNs.ConsumerGroups({
196
197
  store: materialStore,
197
198
  path: join(dirname(events.materialStorePath()), 'cycle-consumer.json'),
198
199
  });
199
200
  const store = deps.store ?? new assetstore.LocalJsonlProvider(events.assetsDir());
200
- const assetDir = store instanceof assetstore.LocalJsonlProvider ? store.baseDir : events.assetsDir();
201
+ const localDir = assetstore.LocalJsonlProvider.isBuiltInPromptReader(store)
202
+ ? Object.getOwnPropertyDescriptor(store, 'baseDir')?.value : undefined;
203
+ const assetDir = typeof localDir === 'string' ? localDir : events.assetsDir();
201
204
  const provenance = deps.provenance ?? new assetstore.ProvenanceStore(assetDir);
202
205
  const review = deps.review ?? new assetstore.ReviewLedger(assetDir);
203
206
  const ingestor = deps.ingestor ?? new events.Ingestor({ path: events.rootEventsPath() });
@@ -599,6 +602,11 @@ async function processMaterial(material, opts, deps) {
599
602
  const verdict = await exec.runAutoExecTask({
600
603
  engine: deps.engine,
601
604
  store: deps.store,
605
+ cycleId,
606
+ assertPromptAdapter: () => {
607
+ if (!assetstore.isBuiltInPromptProvider(deps.store))
608
+ throw new Error('unsupported_unsupervised_prompt_provider_v1');
609
+ },
602
610
  provenance: deps.provenance,
603
611
  ...(process.env['EVOLVER_BENCHMARK_ID'] !== undefined ? { benchmark: assetstore.benchmarkContext(process.env['EVOLVER_BENCHMARK_ID']) } : {}),
604
612
  review: deps.review,
package/dist/dispatch.js CHANGED
@@ -5,6 +5,7 @@
5
5
  // config for a verb the CLI never actually dispatches — a green build hides it, the user hits a usage error.
6
6
  import { runCli, runMigrate, runAssetLog, runDistill, runIngest, runInject, runReview, runDaily, } from './index.js';
7
7
  import { runAutoExec } from './autoexec.js';
8
+ import { runAutoExecFeedbackCommand } from './feedbackOutboxCli.js';
8
9
  import { runAtpCommand, runBuyCommand, runOrdersCommand, runVerifyCommand } from './atp.js';
9
10
  import { runLogin, runLogout } from './login.js';
10
11
  import { runSetupHooks } from './setupHooks.js';
@@ -26,6 +27,8 @@ import { runSyncCommand } from './sync.js';
26
27
  import { runAntiGeneBenchmarkCommand } from './antiGeneBenchmark.js';
27
28
  import { runAntiGeneRolloutCommand } from './antiGeneRollout.js';
28
29
  import { runLifecycleCommand } from './lifecycle.js';
30
+ import { runLiveStatus } from './liveStatus.js';
31
+ import { isReadOnlyStatusInvocation } from './cliEntry.js';
29
32
  import { runCycleCommand } from './cycleConsumer.js';
30
33
  import { runProxyToken } from './proxyToken.js';
31
34
  import { runMaterialCommand } from './materialPackage.js';
@@ -57,6 +60,7 @@ const ASYNC_COMMAND_TABLE = {
57
60
  'skill-md-update': runSkillMdUpdate,
58
61
  thesis: runThesisCommand,
59
62
  autoexec: runAutoExec,
63
+ 'autoexec-feedback': runAutoExecFeedbackCommand,
60
64
  login: runLogin,
61
65
  logout: runLogout,
62
66
  'proxy-token': runProxyToken,
@@ -113,6 +117,8 @@ export function v1TopLevelRunArgs(argv) {
113
117
  }
114
118
  /** Run a top-level argv against the registry: async handler if present, else the synchronous runCli core. */
115
119
  export function dispatch(argv) {
120
+ if (isReadOnlyStatusInvocation(argv))
121
+ return runLiveStatus(argv.slice(1));
116
122
  const topLevelRunArgs = v1TopLevelRunArgs(argv);
117
123
  if (topLevelRunArgs)
118
124
  return runV1RunCompat(topLevelRunArgs);
@@ -0,0 +1,96 @@
1
+ import { hub, type exec } from '@evomap/evolver-core';
2
+ declare const SCHEMA_VERSION = "autoexec-feedback-outbox.v1";
3
+ export type FeedbackNetworkStatus = 'not_applicable' | 'pending' | 'ambiguous' | 'acknowledged' | 'terminal';
4
+ export type FeedbackLocalStatus = 'pending' | 'acknowledged';
5
+ export interface FeedbackOutboxRecord {
6
+ schemaVersion: typeof SCHEMA_VERSION;
7
+ /** Stable across daemon restarts and independent of a task id reused by a later claim. */
8
+ operationId: string;
9
+ /** Stable source id for idempotent local event projection. */
10
+ sourceEventId: string;
11
+ /** The claim identity is hashed; its raw path/name is not retained. */
12
+ claimRootDigest: string;
13
+ taskId: string;
14
+ signals: readonly string[];
15
+ appliedUse: exec.AppliedUseOutcome;
16
+ /** Present only when exact Hub use is proven to originate at this destination. */
17
+ report?: hub.ReuseResultReport;
18
+ /** Nonsecret fingerprint of the observed destination; dispatch also requires origin agreement. */
19
+ destinationId?: string;
20
+ payloadDigest: string;
21
+ localStatus: FeedbackLocalStatus;
22
+ networkStatus: FeedbackNetworkStatus;
23
+ revision: number;
24
+ preparedAt: string;
25
+ localAcknowledgedAt?: string;
26
+ dispatchStartedAt?: string;
27
+ settledAt?: string;
28
+ receiptId?: string;
29
+ terminalReason?: string;
30
+ ambiguousReason?: string;
31
+ reconciliationEvidence?: string;
32
+ }
33
+ export interface PrepareFeedbackInput {
34
+ claimRoot: string;
35
+ /** If supplied, must equal feedbackIdentity(claimRoot, appliedUse.assetId).operationId. */
36
+ operationId?: string;
37
+ /** Required for reportable Hub use; sha256 fingerprint of the effective destination and principal. */
38
+ destinationId?: string;
39
+ task: Pick<exec.AutoExecTask, 'id' | 'signals' | 'generation'>;
40
+ verdict: Pick<exec.AutoExecVerdict, 'taskId' | 'status' | 'generation' | 'appliedUse'>;
41
+ }
42
+ export type FeedbackSendResult = {
43
+ status: 'acknowledged';
44
+ receiptId?: string;
45
+ } | {
46
+ status: 'terminal';
47
+ reason: string;
48
+ } | {
49
+ status: 'ambiguous';
50
+ reason?: string;
51
+ };
52
+ export type FeedbackSender = (record: Readonly<FeedbackOutboxRecord>) => Promise<FeedbackSendResult>;
53
+ export type FeedbackReconciliation = {
54
+ status: 'acknowledged';
55
+ evidence: string;
56
+ receiptId?: string;
57
+ } | {
58
+ status: 'terminal';
59
+ evidence: string;
60
+ reason: string;
61
+ };
62
+ export declare class FeedbackOutboxError extends Error {
63
+ constructor(message: string);
64
+ }
65
+ /** Only a sender that proves no Hub request began may permit a later retry. */
66
+ export declare class FeedbackNotDispatchedError extends Error {
67
+ constructor(message: string);
68
+ }
69
+ /** One operation per claim root and exact asset, even if the task id is later reused. */
70
+ export declare function feedbackIdentity(claimRoot: string, assetId: string): {
71
+ operationId: string;
72
+ sourceEventId: string;
73
+ claimRootDigest: string;
74
+ };
75
+ export declare class FeedbackOutbox {
76
+ readonly dir: string;
77
+ private readonly directory;
78
+ private readonly reportedUnreadable;
79
+ constructor(dir: string);
80
+ private path;
81
+ get(operationId: string): Readonly<FeedbackOutboxRecord> | null;
82
+ private save;
83
+ /** Persist exact applied-use evidence before any local projection or Hub call. */
84
+ prepare(input: PrepareFeedbackInput): Readonly<FeedbackOutboxRecord> | null;
85
+ private rows;
86
+ localPending(): Readonly<FeedbackOutboxRecord>[];
87
+ /** This acknowledgement follows idempotent ingestion under sourceEventId. */
88
+ acknowledgeLocal(operationId: string): Readonly<FeedbackOutboxRecord>;
89
+ /** Never dispatched Hub rows; ambiguous rows are intentionally excluded. */
90
+ pending(): Readonly<FeedbackOutboxRecord>[];
91
+ /** Mark ambiguous durably before first send. No replay from ambiguous state. */
92
+ deliver(operationId: string, destinationId: string, sender: FeedbackSender): Promise<Readonly<FeedbackOutboxRecord>>;
93
+ /** External receipt or operator evidence can settle ambiguity without resending. */
94
+ reconcile(operationId: string, resolution: FeedbackReconciliation): Readonly<FeedbackOutboxRecord>;
95
+ }
96
+ export {};