oxe-cc 1.16.0 → 1.21.1
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/.github/copilot-instructions.md +177 -177
- package/.github/dependabot.yml +31 -31
- package/.github/workflows/ci.yml +159 -138
- package/.github/workflows/release.yml +107 -106
- package/AGENTS.md +97 -97
- package/CHANGELOG.md +1032 -856
- package/README.md +673 -600
- package/assets/readme-banner.svg +19 -19
- package/bin/banner.txt +13 -13
- package/bin/lib/oxe-agent-install.cjs +650 -650
- package/bin/lib/oxe-artifact-catalog.cjs +376 -376
- package/bin/lib/oxe-azure.cjs +1445 -1445
- package/bin/lib/oxe-budget.cjs +117 -0
- package/bin/lib/oxe-change.cjs +230 -0
- package/bin/lib/oxe-command-registry.cjs +31 -31
- package/bin/lib/oxe-commit-convention.cjs +85 -0
- package/bin/lib/oxe-context-engine.cjs +874 -874
- package/bin/lib/oxe-core-command-handlers.cjs +82 -82
- package/bin/lib/oxe-criterion-coverage.cjs +58 -0
- package/bin/lib/oxe-dashboard.cjs +737 -737
- package/bin/lib/oxe-dossier.cjs +281 -0
- package/bin/lib/oxe-install-resolve.cjs +134 -106
- package/bin/lib/oxe-manifest.cjs +124 -124
- package/bin/lib/oxe-npm-version.cjs +66 -66
- package/bin/lib/oxe-operational.cjs +4484 -2676
- package/bin/lib/oxe-phase-gates.cjs +280 -0
- package/bin/lib/oxe-plan-json.cjs +433 -0
- package/bin/lib/oxe-plugin-cli.cjs +95 -95
- package/bin/lib/oxe-plugins.cjs +432 -432
- package/bin/lib/oxe-process.cjs +56 -56
- package/bin/lib/oxe-program.cjs +205 -0
- package/bin/lib/oxe-project-env.cjs +178 -0
- package/bin/lib/oxe-project-health.cjs +2962 -2846
- package/bin/lib/oxe-rationality.cjs +73 -49
- package/bin/lib/oxe-release.cjs +42 -0
- package/bin/lib/oxe-repo-rules.cjs +108 -0
- package/bin/lib/oxe-runtime-semantics.cjs +514 -514
- package/bin/lib/oxe-scorecard.cjs +164 -0
- package/bin/lib/oxe-security.cjs +289 -289
- package/bin/lib/oxe-spike.cjs +98 -0
- package/bin/lib/oxe-verify-dryrun.cjs +152 -0
- package/bin/lib/oxe-workflows.cjs +145 -145
- package/bin/oxe-cc.js +6281 -5829
- package/docs/INTEGRATION.md +182 -182
- package/docs/QUALITY-GATES.md +46 -46
- package/docs/RELEASE-READINESS.md +87 -86
- package/docs/RUNTIME-SMOKE-MATRIX.md +137 -137
- package/docs/oxespace-1.5/BACKLOG.md +273 -0
- package/docs/oxevoice/BACKLOG.md +244 -0
- package/lib/runtime/compiler/graph-compiler.d.ts +13 -0
- package/lib/runtime/compiler/graph-compiler.js +40 -3
- package/lib/runtime/delivery/promotion-pipeline.js +6 -2
- package/lib/runtime/events/catalog.d.ts +1 -1
- package/lib/runtime/events/catalog.js +11 -0
- package/lib/runtime/executor/adapters/claude-cli.d.ts +63 -0
- package/lib/runtime/executor/adapters/claude-cli.js +250 -0
- package/lib/runtime/executor/adapters/http-openai.d.ts +9 -0
- package/lib/runtime/executor/adapters/http-openai.js +18 -0
- package/lib/runtime/executor/adapters/registry.d.ts +13 -0
- package/lib/runtime/executor/adapters/registry.js +29 -0
- package/lib/runtime/executor/adapters/types.d.ts +21 -0
- package/lib/runtime/executor/adapters/types.js +2 -0
- package/lib/runtime/executor/built-in-tools.d.ts +8 -0
- package/lib/runtime/executor/built-in-tools.js +40 -9
- package/lib/runtime/executor/index.d.ts +12 -2
- package/lib/runtime/executor/index.js +28 -1
- package/lib/runtime/executor/llm-task-executor.d.ts +35 -2
- package/lib/runtime/executor/llm-task-executor.js +97 -21
- package/lib/runtime/executor/node-context.d.ts +83 -0
- package/lib/runtime/executor/node-context.js +116 -0
- package/lib/runtime/executor/node-prompt-builder.d.ts +2 -0
- package/lib/runtime/executor/node-prompt-builder.js +2 -0
- package/lib/runtime/executor/shell-argv.d.ts +30 -0
- package/lib/runtime/executor/shell-argv.js +57 -0
- package/lib/runtime/executor/stream-completion.d.ts +11 -0
- package/lib/runtime/executor/stream-completion.js +10 -1
- package/lib/runtime/index.d.ts +5 -2
- package/lib/runtime/index.js +8 -1
- package/lib/runtime/program/index.d.ts +1 -0
- package/lib/runtime/program/index.js +17 -0
- package/lib/runtime/program/program-model.d.ts +74 -0
- package/lib/runtime/program/program-model.js +195 -0
- package/lib/runtime/projection/projection-engine.d.ts +10 -1
- package/lib/runtime/projection/projection-engine.js +25 -1
- package/lib/runtime/reducers/run-state-reducer.js +5 -0
- package/lib/runtime/scheduler/run-journal.d.ts +19 -1
- package/lib/runtime/scheduler/run-journal.js +40 -1
- package/lib/runtime/scheduler/scheduler.d.ts +30 -0
- package/lib/runtime/scheduler/scheduler.js +195 -19
- package/lib/runtime/verification/contract-exports.d.ts +24 -0
- package/lib/runtime/verification/contract-exports.js +201 -0
- package/lib/runtime/verification/index.d.ts +1 -0
- package/lib/runtime/verification/index.js +1 -0
- package/lib/runtime/verification/test-report-parsers.d.ts +37 -0
- package/lib/runtime/verification/test-report-parsers.js +180 -0
- package/lib/runtime/verification/verification-compiler.d.ts +67 -1
- package/lib/runtime/verification/verification-compiler.js +302 -25
- package/lib/runtime/verification/verification-manifest.d.ts +10 -0
- package/lib/runtime/verification/verification-manifest.js +18 -3
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +9 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +81 -0
- package/lib/sdk/README.md +61 -61
- package/lib/sdk/index.cjs +815 -810
- package/lib/sdk/index.d.ts +982 -982
- package/lib/sdk/index.types.ts +933 -933
- package/oxe/schemas/plan-agents.schema.json +122 -122
- package/oxe/schemas/plan.schema.json +85 -0
- package/oxe/templates/ACTIVE-RUN.template.json +32 -32
- package/oxe/templates/CAPABILITIES.template.md +7 -7
- package/oxe/templates/CAPABILITY.template.md +45 -45
- package/oxe/templates/CHECKPOINT.template.md +37 -37
- package/oxe/templates/CHECKPOINTS.template.md +7 -7
- package/oxe/templates/CODEBASE-DELTA.template.md +33 -33
- package/oxe/templates/CONFIG.md +105 -105
- package/oxe/templates/DISCUSS.template.md +44 -44
- package/oxe/templates/DOCS_BROWNFIELD_LAYOUT.md +55 -55
- package/oxe/templates/EXECUTION-RUNTIME.template.md +68 -68
- package/oxe/templates/FIXTURE-PACK.template.json +23 -23
- package/oxe/templates/FIXTURE-PACK.template.md +11 -11
- package/oxe/templates/GIT_HOOKS_OXE.md +52 -52
- package/oxe/templates/HYPOTHESES.template.md +33 -33
- package/oxe/templates/IMPLEMENTATION-PACK.template.json +42 -42
- package/oxe/templates/IMPLEMENTATION-PACK.template.md +16 -16
- package/oxe/templates/INVESTIGATION.template.md +38 -38
- package/oxe/templates/LESSONS-METRICS.template.json +13 -13
- package/oxe/templates/LESSONS.template.md +43 -43
- package/oxe/templates/MEMORY.template.md +49 -49
- package/oxe/templates/MILESTONES.template.md +17 -17
- package/oxe/templates/NOTES.template.md +16 -16
- package/oxe/templates/OBSERVATIONS.template.md +18 -18
- package/oxe/templates/PLAN-REVIEW.template.md +31 -31
- package/oxe/templates/PLAN.template.md +66 -66
- package/oxe/templates/PLUGINS.md +108 -108
- package/oxe/templates/REFERENCE-ANCHORS.template.md +9 -9
- package/oxe/templates/RESEARCH.template.md +57 -57
- package/oxe/templates/RESUME.template.md +49 -49
- package/oxe/templates/ROADMAP.template.md +44 -44
- package/oxe/templates/SECURITY.template.md +72 -72
- package/oxe/templates/SESSION.template.md +34 -34
- package/oxe/templates/SKILL.template.md +26 -26
- package/oxe/templates/SPEC.template.md +54 -54
- package/oxe/templates/STATE-REFERENCE.md +125 -125
- package/oxe/templates/STATE.md +30 -30
- package/oxe/templates/WORKFLOW_AUTHORING.md +93 -93
- package/oxe/templates/config.template.json +38 -38
- package/oxe/templates/plan-agent-messages-README.template.md +9 -9
- package/oxe/templates/plan-agents.template.json +30 -30
- package/oxe/templates/quick-agents.template.json +24 -24
- package/oxe/workflows/ask.md +96 -96
- package/oxe/workflows/capabilities.md +25 -25
- package/oxe/workflows/checkpoint.md +37 -37
- package/oxe/workflows/compact.md +44 -44
- package/oxe/workflows/dashboard.md +33 -33
- package/oxe/workflows/debug.md +34 -34
- package/oxe/workflows/discuss.md +86 -86
- package/oxe/workflows/execute.md +255 -255
- package/oxe/workflows/forensics.md +48 -48
- package/oxe/workflows/help.md +355 -355
- package/oxe/workflows/loop.md +67 -67
- package/oxe/workflows/milestone.md +95 -95
- package/oxe/workflows/next.md +45 -45
- package/oxe/workflows/obs.md +167 -167
- package/oxe/workflows/oxe.md +150 -149
- package/oxe/workflows/plan-agent.md +143 -143
- package/oxe/workflows/plan.md +525 -523
- package/oxe/workflows/project.md +55 -55
- package/oxe/workflows/quick.md +185 -185
- package/oxe/workflows/references/adaptive-discovery.md +27 -27
- package/oxe/workflows/references/flow-robustness-contract.md +80 -80
- package/oxe/workflows/references/legacy-brownfield.md +136 -136
- package/oxe/workflows/references/plan-agent-chat-protocol.md +99 -99
- package/oxe/workflows/references/plan-json-acceptance-program.md +143 -0
- package/oxe/workflows/references/reasoning-discovery.md +28 -28
- package/oxe/workflows/references/reasoning-execution.md +29 -29
- package/oxe/workflows/references/reasoning-planning.md +32 -32
- package/oxe/workflows/references/reasoning-review.md +29 -29
- package/oxe/workflows/references/reasoning-status.md +24 -24
- package/oxe/workflows/references/robustness-elevation.md +295 -295
- package/oxe/workflows/references/session-path-resolution.md +71 -71
- package/oxe/workflows/research.md +66 -66
- package/oxe/workflows/retro.md +117 -117
- package/oxe/workflows/review-pr.md +53 -53
- package/oxe/workflows/route.md +32 -32
- package/oxe/workflows/security.md +67 -67
- package/oxe/workflows/session.md +213 -213
- package/oxe/workflows/ship.md +142 -142
- package/oxe/workflows/skill.md +44 -44
- package/oxe/workflows/spec.md +569 -566
- package/oxe/workflows/ui-review.md +32 -32
- package/oxe/workflows/ui-spec.md +25 -25
- package/oxe/workflows/update.md +35 -35
- package/oxe/workflows/validate-gaps.md +45 -45
- package/oxe/workflows/verify-audit.md +73 -73
- package/oxe/workflows/verify.md +247 -244
- package/oxe/workflows/workflow-authoring.md +34 -34
- package/oxe/workflows/workstream.md +97 -97
- package/package.json +132 -129
- package/packages/runtime/package.json +18 -18
- package/packages/runtime/src/audit/audit-trail.ts +243 -243
- package/packages/runtime/src/audit/index.ts +2 -2
- package/packages/runtime/src/audit/policy-pack.ts +62 -62
- package/packages/runtime/src/compiler/graph-compiler.ts +336 -285
- package/packages/runtime/src/compiler/index.ts +1 -1
- package/packages/runtime/src/context/context-pack-builder.ts +339 -339
- package/packages/runtime/src/context/context-pack-store.ts +197 -197
- package/packages/runtime/src/context/context-profiles.ts +60 -60
- package/packages/runtime/src/context/index.ts +3 -3
- package/packages/runtime/src/decision/decision-engine.ts +174 -174
- package/packages/runtime/src/decision/decision-memo.ts +211 -211
- package/packages/runtime/src/decision/index.ts +2 -2
- package/packages/runtime/src/delivery/branch-manager.ts +91 -91
- package/packages/runtime/src/delivery/ci-checks.ts +285 -285
- package/packages/runtime/src/delivery/delivery-records.ts +75 -75
- package/packages/runtime/src/delivery/index.ts +5 -5
- package/packages/runtime/src/delivery/pr-manager.ts +112 -112
- package/packages/runtime/src/delivery/promotion-pipeline.ts +342 -334
- package/packages/runtime/src/events/bus.ts +92 -92
- package/packages/runtime/src/events/catalog.ts +45 -34
- package/packages/runtime/src/events/envelope.ts +14 -14
- package/packages/runtime/src/events/index.ts +3 -3
- package/packages/runtime/src/evidence/evidence-store.ts +130 -130
- package/packages/runtime/src/evidence/index.ts +1 -1
- package/packages/runtime/src/executor/adapters/claude-cli.ts +285 -0
- package/packages/runtime/src/executor/adapters/http-openai.ts +16 -0
- package/packages/runtime/src/executor/adapters/registry.ts +33 -0
- package/packages/runtime/src/executor/adapters/types.ts +24 -0
- package/packages/runtime/src/executor/built-in-tools.ts +36 -8
- package/packages/runtime/src/executor/index.ts +12 -2
- package/packages/runtime/src/executor/llm-task-executor.ts +125 -25
- package/packages/runtime/src/executor/node-context.ts +210 -0
- package/packages/runtime/src/executor/node-prompt-builder.ts +5 -0
- package/packages/runtime/src/executor/shell-argv.ts +66 -0
- package/packages/runtime/src/executor/stream-completion.ts +16 -1
- package/packages/runtime/src/gate/gate-manager.ts +289 -289
- package/packages/runtime/src/gate/index.ts +1 -1
- package/packages/runtime/src/index.ts +54 -44
- package/packages/runtime/src/models/attempt.ts +19 -19
- package/packages/runtime/src/models/evidence.ts +21 -21
- package/packages/runtime/src/models/gate-decision.ts +25 -25
- package/packages/runtime/src/models/index.ts +8 -8
- package/packages/runtime/src/models/run.ts +24 -24
- package/packages/runtime/src/models/session.ts +11 -11
- package/packages/runtime/src/models/verification-result.ts +10 -10
- package/packages/runtime/src/models/work-item.ts +25 -25
- package/packages/runtime/src/models/workspace.ts +31 -31
- package/packages/runtime/src/plugins/capability-adapter.ts +313 -313
- package/packages/runtime/src/plugins/capability-matrix.ts +126 -126
- package/packages/runtime/src/plugins/index.ts +5 -5
- package/packages/runtime/src/plugins/plugin-abi.ts +106 -106
- package/packages/runtime/src/plugins/plugin-manifest.ts +118 -118
- package/packages/runtime/src/plugins/plugin-registry.ts +241 -241
- package/packages/runtime/src/policy/index.ts +1 -1
- package/packages/runtime/src/policy/policy-engine.ts +330 -330
- package/packages/runtime/src/program/index.ts +1 -0
- package/packages/runtime/src/program/program-model.ts +233 -0
- package/packages/runtime/src/projection/index.ts +1 -1
- package/packages/runtime/src/projection/projection-engine.ts +361 -328
- package/packages/runtime/src/reducers/debug-reducer.ts +36 -36
- package/packages/runtime/src/reducers/index.ts +2 -2
- package/packages/runtime/src/reducers/run-state-reducer.ts +329 -326
- package/packages/runtime/src/scheduler/agent-registry.ts +132 -132
- package/packages/runtime/src/scheduler/agent-roles.ts +109 -109
- package/packages/runtime/src/scheduler/index.ts +4 -4
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +1017 -1017
- package/packages/runtime/src/scheduler/run-journal.ts +105 -62
- package/packages/runtime/src/scheduler/scheduler.ts +1144 -938
- package/packages/runtime/src/verification/contract-exports.ts +203 -0
- package/packages/runtime/src/verification/index.ts +3 -2
- package/packages/runtime/src/verification/test-report-parsers.ts +198 -0
- package/packages/runtime/src/verification/verification-compiler.ts +766 -438
- package/packages/runtime/src/verification/verification-manifest.ts +281 -256
- package/packages/runtime/src/workspace/index.ts +5 -5
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +126 -126
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +150 -87
- package/packages/runtime/src/workspace/strategies/inplace.ts +38 -38
- package/packages/runtime/src/workspace/workspace-manager.ts +16 -16
- package/packages/runtime/tsconfig.json +23 -23
- package/vscode-extension/.vscodeignore +9 -9
- package/vscode-extension/package.json +193 -193
- package/vscode-extension/src/extension.js +320 -320
- package/vscode-extension/src/shared/contextLoader.js +137 -137
- package/vscode-extension/src/shared/contractBuilder.js +159 -159
- package/vscode-extension/src/shared/stateReader.js +101 -101
- package/docs/oxe-artifact-map.html +0 -1172
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Program = an approved ROADMAP executed phase by phase (1.19). Each phase is a full OXE cycle
|
|
3
|
+
* (plan → execute → verify) and closes through a phase gate: verify completed, regression of the
|
|
4
|
+
* closed phases green, pack contracts ok. Pure state transitions — persistence lives in the CLI.
|
|
5
|
+
*/
|
|
6
|
+
export type PhaseStatus = 'pending' | 'planning' | 'executing' | 'verifying' | 'closed';
|
|
7
|
+
export interface ProgramPhase {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
requirements: string[];
|
|
11
|
+
acceptance: string[];
|
|
12
|
+
scope: string | null;
|
|
13
|
+
status: PhaseStatus;
|
|
14
|
+
plan_ref: string | null;
|
|
15
|
+
run_id: string | null;
|
|
16
|
+
started_at: string | null;
|
|
17
|
+
closed_at: string | null;
|
|
18
|
+
closed_commit: string | null;
|
|
19
|
+
/** `.oxe/program/regression/<id>.json` — frozen executable checks of the phase. */
|
|
20
|
+
regression_ref: string | null;
|
|
21
|
+
/** `.oxe/program/interfaces/<id>.json` — real exports of the contracted files. */
|
|
22
|
+
interfaces_ref: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface ProgramState {
|
|
25
|
+
schema_version: 1;
|
|
26
|
+
roadmap_ref: string | null;
|
|
27
|
+
active_phase: string | null;
|
|
28
|
+
phases: ProgramPhase[];
|
|
29
|
+
created_at: string;
|
|
30
|
+
updated_at: string;
|
|
31
|
+
}
|
|
32
|
+
export interface PhaseGateInput {
|
|
33
|
+
/** Run status after `runtime verify` (`completed` is the only passing value). */
|
|
34
|
+
verify_status: string | null;
|
|
35
|
+
/** Ids of failed regression checks (`reg-<phase>-…`). */
|
|
36
|
+
regression_failed: string[];
|
|
37
|
+
/** Ids of failed `contract` checks of this phase. */
|
|
38
|
+
contract_failed: string[];
|
|
39
|
+
/** Ids of other failed checks. */
|
|
40
|
+
checks_failed: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface PhaseGateResult {
|
|
43
|
+
ok: boolean;
|
|
44
|
+
reasons: string[];
|
|
45
|
+
}
|
|
46
|
+
export declare class ProgramTransitionError extends Error {
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `## Fase N — Título` (or `## Phase N - Title`) blocks with `**Requisitos:**`,
|
|
50
|
+
* `**Critérios de aceite:**` and `**Escopo:**` lines, as in `oxe/templates/ROADMAP.template.md`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function parseRoadmapPhases(markdown: string): Array<Pick<ProgramPhase, 'id' | 'title' | 'requirements' | 'acceptance' | 'scope'>>;
|
|
53
|
+
export declare function createProgram(roadmapMarkdown: string, roadmapRef?: string | null): ProgramState;
|
|
54
|
+
export declare function findPhase(state: ProgramState, id: string): ProgramPhase | null;
|
|
55
|
+
export declare function activePhase(state: ProgramState): ProgramPhase | null;
|
|
56
|
+
/** First phase that is not closed (the one the flow should work on). */
|
|
57
|
+
export declare function nextOpenPhase(state: ProgramState): ProgramPhase | null;
|
|
58
|
+
export declare function closedPhasesBefore(state: ProgramState, id: string): ProgramPhase[];
|
|
59
|
+
export declare function programProgress(state: ProgramState): {
|
|
60
|
+
index: number;
|
|
61
|
+
total: number;
|
|
62
|
+
closed: number;
|
|
63
|
+
phase: ProgramPhase | null;
|
|
64
|
+
};
|
|
65
|
+
/** Phases run in roadmap order: a phase starts only when every earlier phase is closed. */
|
|
66
|
+
export declare function startPhase(state: ProgramState, id?: string | null): ProgramState;
|
|
67
|
+
export declare function setPhaseStatus(state: ProgramState, id: string, status: Exclude<PhaseStatus, 'closed' | 'pending'>, patch?: Partial<Pick<ProgramPhase, 'plan_ref' | 'run_id'>>): ProgramState;
|
|
68
|
+
export declare function evaluatePhaseGate(input: PhaseGateInput): PhaseGateResult;
|
|
69
|
+
export declare function closePhase(state: ProgramState, id: string, gate: PhaseGateInput, record?: Partial<Pick<ProgramPhase, 'closed_commit' | 'regression_ref' | 'interfaces_ref' | 'run_id' | 'plan_ref'>>): {
|
|
70
|
+
state: ProgramState;
|
|
71
|
+
gate: PhaseGateResult;
|
|
72
|
+
};
|
|
73
|
+
/** Acceptance ids a plan for `phase` may reference that are outside the phase (plan lint). */
|
|
74
|
+
export declare function acceptanceOutsidePhase(phase: ProgramPhase, planAcceptance: string[]): string[];
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Program = an approved ROADMAP executed phase by phase (1.19). Each phase is a full OXE cycle
|
|
4
|
+
* (plan → execute → verify) and closes through a phase gate: verify completed, regression of the
|
|
5
|
+
* closed phases green, pack contracts ok. Pure state transitions — persistence lives in the CLI.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ProgramTransitionError = void 0;
|
|
9
|
+
exports.parseRoadmapPhases = parseRoadmapPhases;
|
|
10
|
+
exports.createProgram = createProgram;
|
|
11
|
+
exports.findPhase = findPhase;
|
|
12
|
+
exports.activePhase = activePhase;
|
|
13
|
+
exports.nextOpenPhase = nextOpenPhase;
|
|
14
|
+
exports.closedPhasesBefore = closedPhasesBefore;
|
|
15
|
+
exports.programProgress = programProgress;
|
|
16
|
+
exports.startPhase = startPhase;
|
|
17
|
+
exports.setPhaseStatus = setPhaseStatus;
|
|
18
|
+
exports.evaluatePhaseGate = evaluatePhaseGate;
|
|
19
|
+
exports.closePhase = closePhase;
|
|
20
|
+
exports.acceptanceOutsidePhase = acceptanceOutsidePhase;
|
|
21
|
+
class ProgramTransitionError extends Error {
|
|
22
|
+
}
|
|
23
|
+
exports.ProgramTransitionError = ProgramTransitionError;
|
|
24
|
+
const now = () => new Date().toISOString();
|
|
25
|
+
function idList(text) {
|
|
26
|
+
return [...new Set((String(text || '').match(/\b[A-Z]{1,4}-?\d+[a-z]?\b/g) || []).map((v) => v.trim()))];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* `## Fase N — Título` (or `## Phase N - Title`) blocks with `**Requisitos:**`,
|
|
30
|
+
* `**Critérios de aceite:**` and `**Escopo:**` lines, as in `oxe/templates/ROADMAP.template.md`.
|
|
31
|
+
*/
|
|
32
|
+
function parseRoadmapPhases(markdown) {
|
|
33
|
+
const text = String(markdown || '').replace(/<!--[\s\S]*?-->/g, '');
|
|
34
|
+
const heading = /^##\s+(?:Fase|Phase)\s+(\d+)\s*(?:[—–:-]\s*)?(.*)$/gim;
|
|
35
|
+
const marks = [...text.matchAll(heading)];
|
|
36
|
+
return marks.map((m, i) => {
|
|
37
|
+
const body = text.slice(m.index + m[0].length, i + 1 < marks.length ? marks[i + 1].index : undefined);
|
|
38
|
+
const field = (re) => {
|
|
39
|
+
const hit = re.exec(body);
|
|
40
|
+
return hit ? hit[1].trim() : '';
|
|
41
|
+
};
|
|
42
|
+
const scope = field(/\*\*(?:Escopo|Scope):\*\*\s*(.+)/i);
|
|
43
|
+
return {
|
|
44
|
+
id: `F${Number(m[1])}`,
|
|
45
|
+
title: m[2].trim() || `Fase ${Number(m[1])}`,
|
|
46
|
+
requirements: idList(field(/\*\*(?:Requisitos|Requirements):\*\*\s*(.+)/i)).filter((v) => /^R/.test(v)),
|
|
47
|
+
acceptance: idList(field(/\*\*(?:Crit[ée]rios de aceite|Acceptance(?: criteria)?):\*\*\s*(.+)/i)).filter((v) => /^A/.test(v)),
|
|
48
|
+
scope: scope || null,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function createProgram(roadmapMarkdown, roadmapRef = null) {
|
|
53
|
+
const parsed = parseRoadmapPhases(roadmapMarkdown);
|
|
54
|
+
if (parsed.length === 0)
|
|
55
|
+
throw new ProgramTransitionError('ROADMAP sem fases (`## Fase N — …`)');
|
|
56
|
+
const ids = new Set();
|
|
57
|
+
for (const phase of parsed) {
|
|
58
|
+
if (ids.has(phase.id))
|
|
59
|
+
throw new ProgramTransitionError(`fase duplicada no ROADMAP: ${phase.id}`);
|
|
60
|
+
ids.add(phase.id);
|
|
61
|
+
}
|
|
62
|
+
const ts = now();
|
|
63
|
+
return {
|
|
64
|
+
schema_version: 1,
|
|
65
|
+
roadmap_ref: roadmapRef,
|
|
66
|
+
active_phase: null,
|
|
67
|
+
phases: parsed.map((phase) => ({
|
|
68
|
+
...phase,
|
|
69
|
+
status: 'pending',
|
|
70
|
+
plan_ref: null,
|
|
71
|
+
run_id: null,
|
|
72
|
+
started_at: null,
|
|
73
|
+
closed_at: null,
|
|
74
|
+
closed_commit: null,
|
|
75
|
+
regression_ref: null,
|
|
76
|
+
interfaces_ref: null,
|
|
77
|
+
})),
|
|
78
|
+
created_at: ts,
|
|
79
|
+
updated_at: ts,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function clone(state) {
|
|
83
|
+
return JSON.parse(JSON.stringify(state));
|
|
84
|
+
}
|
|
85
|
+
function findPhase(state, id) {
|
|
86
|
+
const key = String(id || '').trim().toUpperCase().replace(/^(?:FASE|PHASE)\s*/, 'F');
|
|
87
|
+
const normalized = /^\d+$/.test(key) ? `F${Number(key)}` : key;
|
|
88
|
+
return state.phases.find((p) => p.id.toUpperCase() === normalized) ?? null;
|
|
89
|
+
}
|
|
90
|
+
function activePhase(state) {
|
|
91
|
+
return state.active_phase ? findPhase(state, state.active_phase) : null;
|
|
92
|
+
}
|
|
93
|
+
/** First phase that is not closed (the one the flow should work on). */
|
|
94
|
+
function nextOpenPhase(state) {
|
|
95
|
+
return state.phases.find((p) => p.status !== 'closed') ?? null;
|
|
96
|
+
}
|
|
97
|
+
function closedPhasesBefore(state, id) {
|
|
98
|
+
const index = state.phases.findIndex((p) => p.id === id);
|
|
99
|
+
return state.phases.slice(0, index < 0 ? state.phases.length : index).filter((p) => p.status === 'closed');
|
|
100
|
+
}
|
|
101
|
+
function programProgress(state) {
|
|
102
|
+
const phase = activePhase(state) ?? nextOpenPhase(state);
|
|
103
|
+
return {
|
|
104
|
+
index: phase ? state.phases.indexOf(phase) + 1 : state.phases.length,
|
|
105
|
+
total: state.phases.length,
|
|
106
|
+
closed: state.phases.filter((p) => p.status === 'closed').length,
|
|
107
|
+
phase,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Phases run in roadmap order: a phase starts only when every earlier phase is closed. */
|
|
111
|
+
function startPhase(state, id) {
|
|
112
|
+
const next = clone(state);
|
|
113
|
+
const target = id ? findPhase(next, id) : nextOpenPhase(next);
|
|
114
|
+
if (!target)
|
|
115
|
+
throw new ProgramTransitionError(id ? `fase inexistente: ${id}` : 'todas as fases estão fechadas');
|
|
116
|
+
if (target.status === 'closed')
|
|
117
|
+
throw new ProgramTransitionError(`fase ${target.id} já está fechada`);
|
|
118
|
+
const open = next.phases.slice(0, next.phases.indexOf(target)).filter((p) => p.status !== 'closed');
|
|
119
|
+
if (open.length)
|
|
120
|
+
throw new ProgramTransitionError(`feche antes: ${open.map((p) => p.id).join(', ')}`);
|
|
121
|
+
const current = activePhase(next);
|
|
122
|
+
if (current && current.id !== target.id && current.status !== 'closed') {
|
|
123
|
+
throw new ProgramTransitionError(`fase ${current.id} ainda está ativa`);
|
|
124
|
+
}
|
|
125
|
+
if (target.status === 'pending') {
|
|
126
|
+
target.status = 'planning';
|
|
127
|
+
target.started_at = now();
|
|
128
|
+
}
|
|
129
|
+
next.active_phase = target.id;
|
|
130
|
+
next.updated_at = now();
|
|
131
|
+
return next;
|
|
132
|
+
}
|
|
133
|
+
const FORWARD = {
|
|
134
|
+
pending: ['planning'],
|
|
135
|
+
planning: ['executing'],
|
|
136
|
+
executing: ['verifying'],
|
|
137
|
+
// A failed verify sends the phase back to execution (or re-planning) — never straight to closed.
|
|
138
|
+
verifying: ['executing', 'planning'],
|
|
139
|
+
closed: [],
|
|
140
|
+
};
|
|
141
|
+
function setPhaseStatus(state, id, status, patch = {}) {
|
|
142
|
+
const next = clone(state);
|
|
143
|
+
const phase = findPhase(next, id);
|
|
144
|
+
if (!phase)
|
|
145
|
+
throw new ProgramTransitionError(`fase inexistente: ${id}`);
|
|
146
|
+
if (phase.status !== status && !FORWARD[phase.status].includes(status)) {
|
|
147
|
+
throw new ProgramTransitionError(`transição inválida ${phase.id}: ${phase.status} → ${status}`);
|
|
148
|
+
}
|
|
149
|
+
phase.status = status;
|
|
150
|
+
if (patch.plan_ref !== undefined)
|
|
151
|
+
phase.plan_ref = patch.plan_ref;
|
|
152
|
+
if (patch.run_id !== undefined)
|
|
153
|
+
phase.run_id = patch.run_id;
|
|
154
|
+
next.updated_at = now();
|
|
155
|
+
return next;
|
|
156
|
+
}
|
|
157
|
+
function evaluatePhaseGate(input) {
|
|
158
|
+
const reasons = [];
|
|
159
|
+
if (input.verify_status !== 'completed')
|
|
160
|
+
reasons.push(`verify não concluído (status: ${input.verify_status ?? 'ausente'})`);
|
|
161
|
+
if (input.regression_failed.length)
|
|
162
|
+
reasons.push(`regressão de fases anteriores: ${input.regression_failed.join(', ')}`);
|
|
163
|
+
if (input.contract_failed.length)
|
|
164
|
+
reasons.push(`contratos do pack: ${input.contract_failed.join(', ')}`);
|
|
165
|
+
if (input.checks_failed.length)
|
|
166
|
+
reasons.push(`checks falhados: ${input.checks_failed.join(', ')}`);
|
|
167
|
+
return { ok: reasons.length === 0, reasons };
|
|
168
|
+
}
|
|
169
|
+
function closePhase(state, id, gate, record = {}) {
|
|
170
|
+
const phase = findPhase(state, id);
|
|
171
|
+
if (!phase)
|
|
172
|
+
throw new ProgramTransitionError(`fase inexistente: ${id}`);
|
|
173
|
+
if (phase.status === 'closed')
|
|
174
|
+
throw new ProgramTransitionError(`fase ${phase.id} já está fechada`);
|
|
175
|
+
if (phase.status === 'pending')
|
|
176
|
+
throw new ProgramTransitionError(`fase ${phase.id} não foi iniciada`);
|
|
177
|
+
const result = evaluatePhaseGate(gate);
|
|
178
|
+
if (!result.ok)
|
|
179
|
+
return { state, gate: result };
|
|
180
|
+
const next = clone(state);
|
|
181
|
+
const target = findPhase(next, id);
|
|
182
|
+
Object.assign(target, record);
|
|
183
|
+
target.status = 'closed';
|
|
184
|
+
target.closed_at = now();
|
|
185
|
+
next.active_phase = null;
|
|
186
|
+
next.updated_at = now();
|
|
187
|
+
return { state: next, gate: result };
|
|
188
|
+
}
|
|
189
|
+
/** Acceptance ids a plan for `phase` may reference that are outside the phase (plan lint). */
|
|
190
|
+
function acceptanceOutsidePhase(phase, planAcceptance) {
|
|
191
|
+
if (!phase.acceptance.length)
|
|
192
|
+
return [];
|
|
193
|
+
const allowed = new Set(phase.acceptance);
|
|
194
|
+
return [...new Set(planAcceptance)].filter((ref) => !allowed.has(ref));
|
|
195
|
+
}
|
|
@@ -3,6 +3,15 @@ import type { ExecutionGraph } from '../compiler/graph-compiler';
|
|
|
3
3
|
import type { VerificationResult } from '../models/verification-result';
|
|
4
4
|
import type { CheckResult } from '../verification/verification-compiler';
|
|
5
5
|
import type { VerificationManifest, ResidualRiskLedger } from '../verification/verification-manifest';
|
|
6
|
+
/** One `ExecutorUsage` event: an executor attempt's turns, tool calls and cost. */
|
|
7
|
+
export interface ExecutorUsageRow {
|
|
8
|
+
work_item_id: string;
|
|
9
|
+
attempt?: number | null;
|
|
10
|
+
turns?: number | null;
|
|
11
|
+
tool_calls?: number | null;
|
|
12
|
+
cost_usd?: number | null;
|
|
13
|
+
adapter?: string | null;
|
|
14
|
+
}
|
|
6
15
|
export declare class ProjectionEngine {
|
|
7
16
|
projectPlan(state: RunState, graph: ExecutionGraph): string;
|
|
8
17
|
projectVerify(state: RunState, results: VerificationResult[], checkResults?: CheckResult[], manifest?: VerificationManifest | null, riskLedger?: ResidualRiskLedger | null, evidenceCoverage?: {
|
|
@@ -12,7 +21,7 @@ export declare class ProjectionEngine {
|
|
|
12
21
|
coverage_percent: number;
|
|
13
22
|
} | null): string;
|
|
14
23
|
projectState(state: RunState): string;
|
|
15
|
-
projectRunSummary(state: RunState): string;
|
|
24
|
+
projectRunSummary(state: RunState, usage?: ExecutorUsageRow[]): string;
|
|
16
25
|
projectPRSummary(state: RunState, graph: ExecutionGraph): string;
|
|
17
26
|
projectCommitSummary(state: RunState, graph: ExecutionGraph): string;
|
|
18
27
|
projectPromotionSummary(state: RunState, graph: ExecutionGraph): string;
|
|
@@ -176,7 +176,7 @@ class ProjectionEngine {
|
|
|
176
176
|
];
|
|
177
177
|
return lines.join('\n');
|
|
178
178
|
}
|
|
179
|
-
projectRunSummary(state) {
|
|
179
|
+
projectRunSummary(state, usage = []) {
|
|
180
180
|
const run = state.run;
|
|
181
181
|
const completed = [...state.completedWorkItems];
|
|
182
182
|
const failed = [...state.failedWorkItems];
|
|
@@ -205,6 +205,30 @@ class ProjectionEngine {
|
|
|
205
205
|
if (blocked.length > 0) {
|
|
206
206
|
lines.push(`**⊘ Blocked:** ${blocked.join(', ')}`);
|
|
207
207
|
}
|
|
208
|
+
if (usage.length > 0) {
|
|
209
|
+
const byItem = new Map();
|
|
210
|
+
for (const row of usage) {
|
|
211
|
+
const entry = byItem.get(row.work_item_id) ?? { attempts: 0, turns: 0, tools: 0, cost: null };
|
|
212
|
+
entry.attempts += 1;
|
|
213
|
+
entry.turns += row.turns ?? 0;
|
|
214
|
+
entry.tools += row.tool_calls ?? 0;
|
|
215
|
+
if (typeof row.cost_usd === 'number')
|
|
216
|
+
entry.cost = (entry.cost ?? 0) + row.cost_usd;
|
|
217
|
+
byItem.set(row.work_item_id, entry);
|
|
218
|
+
}
|
|
219
|
+
const money = (v) => (v == null ? '—' : `$${v.toFixed(2)}`);
|
|
220
|
+
const total = { attempts: 0, turns: 0, tools: 0, cost: null };
|
|
221
|
+
lines.push('', '### Executor usage', '', '| Task | Attempts | Turns | Tool calls | Cost |', '|---|---|---|---|---|');
|
|
222
|
+
for (const [id, e] of byItem) {
|
|
223
|
+
lines.push(`| ${id} | ${e.attempts} | ${e.turns} | ${e.tools} | ${money(e.cost)} |`);
|
|
224
|
+
total.attempts += e.attempts;
|
|
225
|
+
total.turns += e.turns;
|
|
226
|
+
total.tools += e.tools;
|
|
227
|
+
if (e.cost != null)
|
|
228
|
+
total.cost = (total.cost ?? 0) + e.cost;
|
|
229
|
+
}
|
|
230
|
+
lines.push(`| **Total** | ${total.attempts} | ${total.turns} | ${total.tools} | ${money(total.cost)} |`);
|
|
231
|
+
}
|
|
208
232
|
return lines.join('\n');
|
|
209
233
|
}
|
|
210
234
|
projectPRSummary(state, graph) {
|
|
@@ -52,12 +52,17 @@ const VALID_RUN_TRANSITIONS = {
|
|
|
52
52
|
cancelled: [],
|
|
53
53
|
};
|
|
54
54
|
function assertWorkItemTransition(itemId, from, to, eventType) {
|
|
55
|
+
// Replaying the same event twice (legacy duplicated logs) must be a no-op, not a corrupt log.
|
|
56
|
+
if (from === to)
|
|
57
|
+
return;
|
|
55
58
|
const allowed = VALID_WORK_ITEM_TRANSITIONS[from] ?? [];
|
|
56
59
|
if (!allowed.includes(to)) {
|
|
57
60
|
throw new Error(`[state-machine] Invalid work item transition for "${itemId}": ${from} → ${to} (event: ${eventType})`);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
function assertRunTransition(from, to, eventType) {
|
|
64
|
+
if (from === to)
|
|
65
|
+
return;
|
|
61
66
|
const allowed = VALID_RUN_TRANSITIONS[from] ?? [];
|
|
62
67
|
if (!allowed.includes(to)) {
|
|
63
68
|
throw new Error(`[state-machine] Invalid run transition: ${from} → ${to} (event: ${eventType})`);
|
|
@@ -9,10 +9,28 @@ export interface RunJournal {
|
|
|
9
9
|
blocked_work_items: string[];
|
|
10
10
|
pending_gates: string[];
|
|
11
11
|
replay_cursor: string | null;
|
|
12
|
-
scheduler_state: 'running' | 'paused' | 'cancelled' | 'completed' | 'blocked';
|
|
12
|
+
scheduler_state: 'running' | 'paused' | 'cancelled' | 'completed' | 'blocked' | 'failed' | 'aborted' | 'interrupted';
|
|
13
13
|
partial_result: Omit<RunResult, 'status'> | null;
|
|
14
|
+
/** Lease (1.20c): process that owns a `running` journal and when it last wrote it. */
|
|
15
|
+
owner_pid?: number | null;
|
|
16
|
+
heartbeat_at?: string | null;
|
|
17
|
+
/** Set when recover found the owner dead (OOM, kill) and reclaimed the run. */
|
|
18
|
+
interrupted_at?: string | null;
|
|
14
19
|
}
|
|
15
20
|
export declare function saveJournal(projectRoot: string, runId: string, journal: RunJournal): void;
|
|
16
21
|
export declare function loadJournal(projectRoot: string, runId: string): RunJournal | null;
|
|
17
22
|
export declare function deleteJournal(projectRoot: string, runId: string): void;
|
|
18
23
|
export declare function createJournal(runId: string): RunJournal;
|
|
24
|
+
/** Whether a process id is alive on this machine (signal 0 probes without killing). */
|
|
25
|
+
export declare function isProcessAlive(pid: number | null | undefined): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* A `running` journal whose owner process is gone (killed by OOM, closed terminal) or whose heartbeat is older than
|
|
28
|
+
* `maxAgeMs` is stale: nothing will ever finish it. Journals from before the lease (no owner_pid) count as stale.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isJournalStale(journal: RunJournal, options?: {
|
|
31
|
+
now?: number;
|
|
32
|
+
maxAgeMs?: number;
|
|
33
|
+
isAlive?: (pid: number | null | undefined) => boolean;
|
|
34
|
+
}): boolean;
|
|
35
|
+
/** Reclaims a stale run: `interrupted` is recoverable and keeps the completed/failed/blocked lists. */
|
|
36
|
+
export declare function markInterrupted(journal: RunJournal): RunJournal;
|
|
@@ -7,6 +7,9 @@ exports.saveJournal = saveJournal;
|
|
|
7
7
|
exports.loadJournal = loadJournal;
|
|
8
8
|
exports.deleteJournal = deleteJournal;
|
|
9
9
|
exports.createJournal = createJournal;
|
|
10
|
+
exports.isProcessAlive = isProcessAlive;
|
|
11
|
+
exports.isJournalStale = isJournalStale;
|
|
12
|
+
exports.markInterrupted = markInterrupted;
|
|
10
13
|
const path_1 = __importDefault(require("path"));
|
|
11
14
|
const fs_1 = __importDefault(require("fs"));
|
|
12
15
|
function journalPath(projectRoot, runId) {
|
|
@@ -15,7 +18,10 @@ function journalPath(projectRoot, runId) {
|
|
|
15
18
|
function saveJournal(projectRoot, runId, journal) {
|
|
16
19
|
const p = journalPath(projectRoot, runId);
|
|
17
20
|
fs_1.default.mkdirSync(path_1.default.dirname(p), { recursive: true });
|
|
18
|
-
|
|
21
|
+
const stamped = journal.scheduler_state === 'running'
|
|
22
|
+
? { ...journal, owner_pid: process.pid, heartbeat_at: new Date().toISOString() }
|
|
23
|
+
: journal;
|
|
24
|
+
fs_1.default.writeFileSync(p, JSON.stringify(stamped, null, 2), 'utf8');
|
|
19
25
|
}
|
|
20
26
|
function loadJournal(projectRoot, runId) {
|
|
21
27
|
const p = journalPath(projectRoot, runId);
|
|
@@ -52,3 +58,36 @@ function createJournal(runId) {
|
|
|
52
58
|
partial_result: null,
|
|
53
59
|
};
|
|
54
60
|
}
|
|
61
|
+
/** Whether a process id is alive on this machine (signal 0 probes without killing). */
|
|
62
|
+
function isProcessAlive(pid) {
|
|
63
|
+
if (!pid || !Number.isInteger(pid) || pid <= 0)
|
|
64
|
+
return false;
|
|
65
|
+
try {
|
|
66
|
+
process.kill(pid, 0);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
// EPERM: exists but not ours — still alive.
|
|
71
|
+
return err?.code === 'EPERM';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A `running` journal whose owner process is gone (killed by OOM, closed terminal) or whose heartbeat is older than
|
|
76
|
+
* `maxAgeMs` is stale: nothing will ever finish it. Journals from before the lease (no owner_pid) count as stale.
|
|
77
|
+
*/
|
|
78
|
+
function isJournalStale(journal, options = {}) {
|
|
79
|
+
if (journal.scheduler_state !== 'running')
|
|
80
|
+
return false;
|
|
81
|
+
const alive = options.isAlive ?? isProcessAlive;
|
|
82
|
+
if (!journal.owner_pid || !alive(journal.owner_pid))
|
|
83
|
+
return true;
|
|
84
|
+
if (journal.owner_pid === process.pid)
|
|
85
|
+
return false;
|
|
86
|
+
const beat = journal.heartbeat_at ? Date.parse(journal.heartbeat_at) : NaN;
|
|
87
|
+
const age = (options.now ?? Date.now()) - beat;
|
|
88
|
+
return Number.isFinite(age) && age > (options.maxAgeMs ?? 6 * 60 * 60 * 1000);
|
|
89
|
+
}
|
|
90
|
+
/** Reclaims a stale run: `interrupted` is recoverable and keeps the completed/failed/blocked lists. */
|
|
91
|
+
function markInterrupted(journal) {
|
|
92
|
+
return { ...journal, scheduler_state: 'interrupted', interrupted_at: new Date().toISOString(), owner_pid: null };
|
|
93
|
+
}
|
|
@@ -9,6 +9,7 @@ import type { AuditTrail } from '../audit/audit-trail';
|
|
|
9
9
|
import type { RunQuota } from '../audit/audit-trail';
|
|
10
10
|
import type { RunJournal } from './run-journal';
|
|
11
11
|
import type { FailureClass } from '../models/failure';
|
|
12
|
+
import type { CheckResult } from '../verification/verification-compiler';
|
|
12
13
|
export interface TaskResult {
|
|
13
14
|
success: boolean;
|
|
14
15
|
failure_class: FailureClass;
|
|
@@ -19,8 +20,20 @@ export interface TaskResult {
|
|
|
19
20
|
export interface TaskExecutor {
|
|
20
21
|
execute(node: GraphNode, lease: WorkspaceLease, runId: string, attemptNumber: number, options?: {
|
|
21
22
|
previousError?: string | null;
|
|
23
|
+
maxTurns?: number | null;
|
|
22
24
|
}): Promise<TaskResult>;
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Turn/cost ceiling of a run (1.21, OXB-023), kept by the caller from the executor's usage. The scheduler checks it
|
|
28
|
+
* between attempts — never killing one mid-way — and caps the next attempt to the turns that are left, so the run
|
|
29
|
+
* cannot go past the turn ceiling.
|
|
30
|
+
*/
|
|
31
|
+
export interface RunBudget {
|
|
32
|
+
/** Why no further attempt may start, or null while there is budget. */
|
|
33
|
+
exhausted(): string | null;
|
|
34
|
+
/** Turns still allowed (the next attempt's cap), or null when turns are unlimited. */
|
|
35
|
+
remainingTurns(): number | null;
|
|
36
|
+
}
|
|
24
37
|
export interface SchedulerOptions {
|
|
25
38
|
maxRunDurationMs?: number;
|
|
26
39
|
staleProgressMs?: number;
|
|
@@ -36,6 +49,7 @@ export interface SchedulerContext {
|
|
|
36
49
|
pluginRegistry?: PluginRegistry;
|
|
37
50
|
auditTrail?: AuditTrail;
|
|
38
51
|
quota?: RunQuota;
|
|
52
|
+
budget?: RunBudget;
|
|
39
53
|
policyActor?: string;
|
|
40
54
|
onEvent?: (event: OxeEvent) => void;
|
|
41
55
|
options?: SchedulerOptions;
|
|
@@ -67,6 +81,8 @@ export declare class Scheduler {
|
|
|
67
81
|
private isConcurrentSafe;
|
|
68
82
|
private runWave;
|
|
69
83
|
private runNode;
|
|
84
|
+
/** Abort keeps the progress made so far: an aborted run is recoverable, not a blank slate. */
|
|
85
|
+
private abortRun;
|
|
70
86
|
pause(): void;
|
|
71
87
|
resume(): void;
|
|
72
88
|
cancel(): void;
|
|
@@ -75,9 +91,23 @@ export declare class Scheduler {
|
|
|
75
91
|
private executeNode;
|
|
76
92
|
private verifyNode;
|
|
77
93
|
private evaluatePolicyForNode;
|
|
94
|
+
/** An approval already granted for this node in this run must not be requested again on re-execution. */
|
|
95
|
+
private hasApprovedGate;
|
|
78
96
|
private requestGateForNode;
|
|
97
|
+
/**
|
|
98
|
+
* A node delivered by another path (`verify_only`) or waiting on external work (`external_dependency`): no agent.
|
|
99
|
+
* verify_only runs only the node's verify — green completes it; red (or no verify) leaves it waiting. A node with an
|
|
100
|
+
* external dependency and no verify_only waits without a gate, so the rest of the run (and the next preflight) goes on.
|
|
101
|
+
*/
|
|
102
|
+
private runExternalNode;
|
|
79
103
|
private blockNode;
|
|
80
104
|
private consumeQuotaForNode;
|
|
81
105
|
private consumeRetryQuota;
|
|
82
106
|
private emit;
|
|
83
107
|
}
|
|
108
|
+
/** Last `n` non-empty lines of a text. */
|
|
109
|
+
export declare function tailLines(text: string, n: number): string;
|
|
110
|
+
/** What the next attempt needs to know about a failed task verify (1.20c informed retry). */
|
|
111
|
+
export declare function describeVerifyFailure(command: string | null | undefined, check: CheckResult | undefined, gaps?: string[]): string;
|
|
112
|
+
/** Normalized failure fingerprint: timings, timestamps, hashes and temp paths removed. */
|
|
113
|
+
export declare function verifyFailureSignature(check: CheckResult | undefined): string | null;
|