Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/cli/src/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type StepAction = 'next' | 'submit' | 'cancel';
export type DigestAction = 'sync';
export type SuiteAction = 'check' | 'resolve';
export type RunnerAction = 'relay' | 'worker';
export type EvolveAction = 'check' | 'run' | 'resume' | 'status' | 'inspect' | 'export' | 'import';
export type EvolveAction = 'check' | 'run' | 'resume' | 'status' | 'inspect' | 'summary' | 'export' | 'import';
export interface Arguments {
readonly command: 'init' | 'check' | 'run' | 'resume' | 'reconcile' | 'status' | 'inspect' | 'closure' | 'app-serve' | 'step' | 'digest' | 'suite' | 'runner' | 'evolve';
readonly stepAction?: StepAction;
Expand Down Expand Up @@ -91,6 +91,11 @@ const evolveRules: Record<EvolveAction, CommandRule> = {
values: ['campaign', 'campaign-dir', 'root', 'island', 'individual'],
flags: ['json'],
},
summary: {
required: ['out'],
values: ['campaign', 'campaign-dir', 'root', 'out'],
flags: ['overwrite', 'json'],
},
export: {
required: ['out'],
values: ['campaign', 'campaign-dir', 'root', 'out', 'format', 'receipt-secret-env'],
Expand Down Expand Up @@ -340,7 +345,7 @@ export function parseArguments(argv: readonly string[]): Arguments {
} else if (rawAction === 'run') {
const stateAliases = ['state', 'campaign-dir', 'root'].filter(k => values.has(k));
if (stateAliases.length !== 1) throw new UsageError();
} else if (rawAction === 'resume' || rawAction === 'status' || rawAction === 'inspect' || rawAction === 'export') {
} else if (rawAction === 'resume' || rawAction === 'status' || rawAction === 'inspect' || rawAction === 'summary' || rawAction === 'export') {
const dirAliases = ['campaign', 'campaign-dir', 'root'].filter(k => values.has(k));
if (dirAliases.length !== 1) throw new UsageError();
if (rawAction === 'export' && flags.has('snapshot') && values.has('format')) throw new UsageError();
Expand Down
42 changes: 40 additions & 2 deletions packages/cli/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function resolveCliVersion(): string {
return '0.0.0';
}
const CLI_VERSION = resolveCliVersion();
const HELP = `loopwright ${CLI_VERSION}\ninit --directory DIR [--force] [--json]\ncheck --config FILE --registry FILE --registry-sha256 HEX [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--json] [--output FILE]\nrun --dry-run --config FILE --registry FILE --registry-sha256 HEX [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--json] [--output FILE]\nrun --config FILE --registry FILE --registry-sha256 HEX --repo DIR --run-root DIR --run-id ID [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nrun --dry-run --taskpack FILE --repo DIR [--mode candidate|no-change|auto] [--baseline-alignment off|fail-fast|extract-context] [--source-revision REV] [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output FILE]\nrun --taskpack FILE --repo DIR --run-root DIR --run-id ID [--mode candidate|no-change|auto] [--baseline-alignment off|fail-fast|extract-context] [--source-revision REV] [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nresume --run-root DIR --run-id ID --config FILE --registry FILE --registry-sha256 HEX --repo DIR [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nstep next --run-root DIR --run-id ID (--taskpack FILE --repo DIR | --config FILE --registry FILE --registry-sha256 HEX --repo DIR | [--repo DIR]) [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--mode candidate|no-change] [--baseline-alignment off|fail-fast|extract-context] [--source-revision REV] [--reissue-lease] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nstep submit --run-root DIR --run-id ID --lease TOKEN [--submission-file FILE] [--status completed|no_change|failed|blocked] [--reason TEXT] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nstep cancel --run-root DIR --run-id ID [--json] [--output-format FORMATS] [--step-summary-file FILE]\ndigest sync --taskpack FILE [--repo DIR] [--check] [--json]\nsuite check --suite FILE [--repo DIR] [--verify-digests] [--json]\nsuite resolve --suite FILE [--repo DIR] [--event NAME] [--schedule KEY] [--comment-body TEXT] [--pr-head-ref REF] [--pr-base-ref REF] [--domain ID] [--json]\nreconcile --config FILE --registry FILE --registry-sha256 HEX --repo DIR --run-root DIR --run-id ID --receipt FILE [--allow-workflow-writes] [--json] [--output FILE] [--output-format FORMATS] [--step-summary-file FILE]\nstatus --run-root DIR --run-id ID [--json]\ninspect --run-root DIR --run-id ID [--json] [--output DIR]\nclosure [--repo DIR] [--output FILE] [--json] [--verify-failures]\napp-serve --config FILE [--repo DIR] [--json]\nrunner relay --config FILE [--json]\nrunner worker --config FILE [--once] [--json]\nevolve check --campaign FILE [--repo DIR] [--json]\nevolve check --bundle DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\nevolve run --campaign FILE --state DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve resume --campaign DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve status --campaign DIR [--json]\nevolve inspect --campaign DIR [--island ID] [--individual ID] [--json]\nevolve export --campaign DIR --out DIR [--format dir|oci-layout] [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve export --campaign DIR --snapshot --out DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve import --bundle DIR --state DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\nConfig and registry files accept YAML (.yaml, .yml) or JSON (.json); init writes controller.draft.yaml and registry.draft.yaml.\nStatic plans do not establish execution readiness. Strict proven_bound is the default.\nJSON verification requires both complete manifests and framing to fit the 16384-byte header; selected file <=1032184 bytes.\n`;
const HELP = `loopwright ${CLI_VERSION}\ninit --directory DIR [--force] [--json]\ncheck --config FILE --registry FILE --registry-sha256 HEX [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--json] [--output FILE]\nrun --dry-run --config FILE --registry FILE --registry-sha256 HEX [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--json] [--output FILE]\nrun --config FILE --registry FILE --registry-sha256 HEX --repo DIR --run-root DIR --run-id ID [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nrun --dry-run --taskpack FILE --repo DIR [--mode candidate|no-change|auto] [--baseline-alignment off|fail-fast|extract-context] [--source-revision REV] [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output FILE]\nrun --taskpack FILE --repo DIR --run-root DIR --run-id ID [--mode candidate|no-change|auto] [--baseline-alignment off|fail-fast|extract-context] [--source-revision REV] [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nresume --run-root DIR --run-id ID --config FILE --registry FILE --registry-sha256 HEX --repo DIR [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--allow-privileged] [--allow-workflow-writes] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nstep next --run-root DIR --run-id ID (--taskpack FILE --repo DIR | --config FILE --registry FILE --registry-sha256 HEX --repo DIR | [--repo DIR]) [--role-model ROLE=PROVIDER/MODEL[:THINKING]] [--mode candidate|no-change] [--baseline-alignment off|fail-fast|extract-context] [--source-revision REV] [--reissue-lease] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nstep submit --run-root DIR --run-id ID --lease TOKEN [--submission-file FILE] [--status completed|no_change|failed|blocked] [--reason TEXT] [--allow-privileged] [--allow-workflow-writes] [--allow-host-mounts PATHS] [--json] [--output-format FORMATS] [--step-summary-file FILE]\nstep cancel --run-root DIR --run-id ID [--json] [--output-format FORMATS] [--step-summary-file FILE]\ndigest sync --taskpack FILE [--repo DIR] [--check] [--json]\nsuite check --suite FILE [--repo DIR] [--verify-digests] [--json]\nsuite resolve --suite FILE [--repo DIR] [--event NAME] [--schedule KEY] [--comment-body TEXT] [--pr-head-ref REF] [--pr-base-ref REF] [--domain ID] [--json]\nreconcile --config FILE --registry FILE --registry-sha256 HEX --repo DIR --run-root DIR --run-id ID --receipt FILE [--allow-workflow-writes] [--json] [--output FILE] [--output-format FORMATS] [--step-summary-file FILE]\nstatus --run-root DIR --run-id ID [--json]\ninspect --run-root DIR --run-id ID [--json] [--output DIR]\nclosure [--repo DIR] [--output FILE] [--json] [--verify-failures]\napp-serve --config FILE [--repo DIR] [--json]\nrunner relay --config FILE [--json]\nrunner worker --config FILE [--once] [--json]\nevolve check --campaign FILE [--repo DIR] [--json]\nevolve check --bundle DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\nevolve run --campaign FILE --state DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve resume --campaign DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve status --campaign DIR [--json]\nevolve inspect --campaign DIR [--island ID] [--individual ID] [--json]\nevolve summary --campaign DIR --out FILE [--overwrite] [--json]\nevolve export --campaign DIR --out DIR [--format dir|oci-layout] [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve export --campaign DIR --snapshot --out DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve import --bundle DIR --state DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\nConfig and registry files accept YAML (.yaml, .yml) or JSON (.json); init writes controller.draft.yaml and registry.draft.yaml.\nStatic plans do not establish execution readiness. Strict proven_bound is the default.\nJSON verification requires both complete manifests and framing to fit the 16384-byte header; selected file <=1032184 bytes.\n`;
const RUNNER_HELP = `loopwright ${CLI_VERSION} runner\nrunner relay --config FILE [--json]\nrunner worker --config FILE [--once] [--json]\n`;
const EVOLVE_HELP = `loopwright ${CLI_VERSION} evolve\nevolve check --campaign FILE [--repo DIR] [--json]\nevolve check --bundle DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\nevolve run --campaign FILE --state DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve resume --campaign DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve status --campaign DIR [--json]\nevolve inspect --campaign DIR [--island ID] [--individual ID] [--json]\nevolve export --campaign DIR --out DIR [--format dir|oci-layout] [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve export --campaign DIR --snapshot --out DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve import --bundle DIR --state DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\n`;
const EVOLVE_HELP = `loopwright ${CLI_VERSION} evolve\nevolve check --campaign FILE [--repo DIR] [--json]\nevolve check --bundle DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\nevolve run --campaign FILE --state DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve resume --campaign DIR [--repo DIR] [--out DIR] [--format dir|oci-layout] [--allow-synthetic-probe] [--json]\nevolve status --campaign DIR [--json]\nevolve inspect --campaign DIR [--island ID] [--individual ID] [--json]\nevolve summary --campaign DIR --out FILE [--overwrite] [--json]\nevolve export --campaign DIR --out DIR [--format dir|oci-layout] [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve export --campaign DIR --snapshot --out DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--overwrite] [--json]\nevolve import --bundle DIR --state DIR [--receipt-secret-env NAME] [--allow-synthetic-probe] [--allow-host-attested] [--json]\n`;
export interface Envelope { readonly version: 1; readonly kind: 'plan' | 'event' | 'status' | 'inspection' | 'result' | 'diagnostic' | 'incident' | 'closure' | 'step' | 'digest' | 'suite'; readonly sequence: number; readonly runId: string | null; readonly data: unknown }
export function encoded(value: unknown): string {
return JSON.stringify(value).replace(/[\u007f-\u009f\u2028\u2029<>&]/g, char => '\\u' + char.charCodeAt(0).toString(16).padStart(4, '0')).replace(/::/g, '\\u003a\\u003a');
Expand Down Expand Up @@ -246,6 +246,7 @@ export function evolutionExitCode(code: EvolutionErrorCode): number {
return 2;
case 'TEAM_ENVELOPE_VIOLATION':
case 'EXPORT_UNVERIFIED_FORBIDDEN':
case 'EVOLUTION_ATTESTED_BUNDLE_FORBIDDEN_IN_HOST_MODE':
case 'EVOLUTION_SYMLINK_FORBIDDEN':
return 3;
case 'EVOLUTION_NOT_FOUND':
Expand Down Expand Up @@ -2069,6 +2070,43 @@ async function runEvolveCommand(args: Arguments, emit: EmitFn): Promise<number>
return 0;
}

if (action === 'summary') {
const campaignRoot = resolveCampaignDir();
const outPath = resolve(get('out'));
const overwrite = args.flags.has('overwrite');
const store = await evolution.EvolutionCampaignStore.open({
campaignRoot,
createIfMissing: false,
});
try {
const campaigns = await store.listCampaigns();
if (campaigns.length > 1) {
throw new evolution.EvolutionError(
'EVOLUTION_CONFLICT',
`campaign store holds ${campaigns.length} campaigns; summary requires a single campaign`,
);
}
const target = campaigns[0];
if (target === undefined) {
throw new evolution.EvolutionError('EVOLUTION_NOT_FOUND', 'no campaigns found in campaign.sqlite');
}
const exported = await evolution.exportCampaignSummary(store, target.campaignId, outPath, {
scrubber: coreScrubber,
overwrite,
});
await emit(
'result',
scrubJsonPayload(exported, scrubber),
scrubber.scrub(
`evolve summary: ok (${exported.campaignId}, bytes=${exported.byteLength}, out=${exported.outPath})`,
),
);
return 0;
} finally {
await store.close().catch(() => undefined);
}
}

if (action === 'export') {
const campaignRoot = resolveCampaignDir();
const outputDir = resolve(get('out'));
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/test/evolve-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ test('evolve-cli: help flags, zero top-level @loopwright/evolution static import
EVOLUTION_SCHEMA_INVALID: 2,
TEAM_ENVELOPE_VIOLATION: 3,
EXPORT_UNVERIFIED_FORBIDDEN: 3,
EVOLUTION_ATTESTED_BUNDLE_FORBIDDEN_IN_HOST_MODE: 3,
EVOLUTION_SYMLINK_FORBIDDEN: 3,
EVOLUTION_NOT_FOUND: 4,
ARTIFACT_INVALID: 4,
Expand Down Expand Up @@ -511,7 +512,7 @@ test('evolve-cli: end-to-end specialist-then-portfolio run, SIGINT pause + resum
workloadIds: ['decode-bs1-4k', 'decode-bs16-8k', 'decode-portfolio-holdout'],
},
pollWaitMs: 40,
heartbeatIntervalMs: 50,
heartbeatIntervalMs: 250,
requestTimeoutMs: 15_000,
stageATimeoutMs: 45_000,
stageBTimeoutMs: 45_000,
Expand Down Expand Up @@ -1080,7 +1081,7 @@ test('evolve-cli: teamEvolution.enabled triggers isolated read-only LocalRunStor
workloadIds: ['decode-bs1-4k'],
},
pollWaitMs: 40,
heartbeatIntervalMs: 50,
heartbeatIntervalMs: 250,
requestTimeoutMs: 15_000,
stageATimeoutMs: 45_000,
stageBTimeoutMs: 45_000,
Expand Down Expand Up @@ -1461,7 +1462,7 @@ test('evolve-cli: exact whitespace/comment clone edit is rejected with NOVELTY_C
workloadIds: ['decode-bs1-4k'],
},
pollWaitMs: 40,
heartbeatIntervalMs: 50,
heartbeatIntervalMs: 250,
requestTimeoutMs: 15_000,
stageATimeoutMs: 45_000,
stageBTimeoutMs: 45_000,
Expand Down
Loading
Loading