devcontour-harness 0.1.0-alpha.34 → 0.1.0-alpha.35

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 (57) hide show
  1. package/README.md +8 -2
  2. package/docs/contracts.md +54 -8
  3. package/docs/release-notes/0.1.0-alpha.35.md +27 -0
  4. package/docs/upgrade.md +35 -0
  5. package/lib/agents/cli-adapter.d.ts +10 -1
  6. package/lib/agents/cli-adapter.js +38 -7
  7. package/lib/agents/usage.d.ts +9 -0
  8. package/lib/agents/usage.js +22 -1
  9. package/lib/contracts/cli.d.ts +49 -1
  10. package/lib/contracts/cli.js +1 -0
  11. package/lib/contracts/diagnosis.d.ts +3 -1
  12. package/lib/contracts/diagnosis.js +1 -0
  13. package/lib/contracts/errors.d.ts +3 -1
  14. package/lib/contracts/errors.js +2 -0
  15. package/lib/contracts/events.d.ts +15 -0
  16. package/lib/contracts/execution.d.ts +32 -1
  17. package/lib/contracts/execution.js +19 -0
  18. package/lib/contracts/failure.d.ts +7 -3
  19. package/lib/contracts/failure.js +6 -2
  20. package/lib/contracts/handoff.d.ts +9 -0
  21. package/lib/contracts/planning.d.ts +2 -0
  22. package/lib/contracts/ports.d.ts +10 -2
  23. package/lib/contracts/published.d.ts +28 -0
  24. package/lib/contracts/repair-policy.d.ts +10 -1
  25. package/lib/contracts/repair-policy.js +18 -0
  26. package/lib/contracts/report.d.ts +2 -0
  27. package/lib/contracts/result.d.ts +2 -0
  28. package/lib/control/harness.d.ts +10 -10
  29. package/lib/control/recovery.d.ts +1 -1
  30. package/lib/control/status.d.ts +8 -8
  31. package/lib/engine/classify.js +1 -1
  32. package/lib/engine/engine.d.ts +9 -7
  33. package/lib/engine/engine.js +3 -0
  34. package/lib/engine/failure.d.ts +1 -1
  35. package/lib/engine/failure.js +1 -1
  36. package/lib/engine/prompt.js +11 -1
  37. package/lib/engine/property-recovery.js +2 -0
  38. package/lib/engine/repair.js +4 -2
  39. package/lib/engine/reuse.js +2 -0
  40. package/lib/engine/runner.js +9 -0
  41. package/lib/explain/state.d.ts +1 -1
  42. package/lib/explain/state.js +10 -4
  43. package/lib/index.d.ts +1 -1
  44. package/lib/index.js +1 -1
  45. package/lib/projections/stop.d.ts +3 -1
  46. package/lib/projections/stop.js +30 -2
  47. package/lib/report/compute.js +1 -0
  48. package/lib/report/document.js +1 -1
  49. package/lib/storage/document.d.ts +8 -6
  50. package/package.json +1 -1
  51. package/schemas/execution-document.schema.json +11 -0
  52. package/schemas/handoff-pack.schema.json +9 -0
  53. package/schemas/result-envelope.schema.json +1 -0
  54. package/schemas/run-event.schema.json +3 -0
  55. package/schemas/run-result.schema.json +1 -0
  56. package/schemas/stop-diagnosis.schema.json +2 -0
  57. package/schemas/value-report.schema.json +1 -0
@@ -766,11 +766,11 @@ export declare class Harness {
766
766
  reason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
767
767
  paused: boolean;
768
768
  } | {
769
- code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
770
- cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
769
+ code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "CONTEXT_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
770
+ cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
771
771
  actor?: import("../index.ts").Actor | undefined;
772
772
  action?: "none" | "wait" | "retry" | "review-plan" | "diagnose-failure" | "reset-attempts" | "raise-budget" | "replan-dependents" | "recovery-decision" | "user-decision" | "resume-queue" | "fix-environment" | "fix-access" | undefined;
773
- failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
773
+ failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
774
774
  operation?: string | undefined;
775
775
  since?: string | undefined;
776
776
  detail?: string;
@@ -847,7 +847,7 @@ export declare class Harness {
847
847
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
848
848
  pausedAt?: string | undefined;
849
849
  pauseOperation?: string | undefined;
850
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
850
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
851
851
  waits?: {
852
852
  kind: "base-check" | "context-lock";
853
853
  detail: string;
@@ -884,11 +884,11 @@ export declare class Harness {
884
884
  reason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
885
885
  paused: boolean;
886
886
  } | {
887
- code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
888
- cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
887
+ code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "CONTEXT_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
888
+ cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
889
889
  actor?: import("../index.ts").Actor | undefined;
890
890
  action?: "none" | "wait" | "retry" | "review-plan" | "diagnose-failure" | "reset-attempts" | "raise-budget" | "replan-dependents" | "recovery-decision" | "user-decision" | "resume-queue" | "fix-environment" | "fix-access" | undefined;
891
- failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
891
+ failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
892
892
  operation?: string | undefined;
893
893
  since?: string | undefined;
894
894
  detail?: string;
@@ -944,7 +944,7 @@ export declare class Harness {
944
944
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
945
945
  pausedAt?: string | undefined;
946
946
  pauseOperation?: string | undefined;
947
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
947
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
948
948
  waits?: {
949
949
  kind: "base-check" | "context-lock";
950
950
  detail: string;
@@ -1158,7 +1158,7 @@ export declare class Harness {
1158
1158
  count: number;
1159
1159
  pausedMs: number;
1160
1160
  open: number;
1161
- failures: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[];
1161
+ failures: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[];
1162
1162
  }[];
1163
1163
  escalations: number;
1164
1164
  };
@@ -1552,7 +1552,7 @@ export declare class Harness {
1552
1552
  integration?: string | undefined;
1553
1553
  };
1554
1554
  stopReason: {
1555
- code: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL";
1555
+ code: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "CONTEXT_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL";
1556
1556
  message: string;
1557
1557
  };
1558
1558
  apiVersion: "devcontour-harness/v1alpha1";
@@ -205,7 +205,7 @@ export declare function recoveryBrief(view: ExecutionView, work: WorkState, poli
205
205
  attempts: {
206
206
  run: string;
207
207
  attempt: number;
208
- failureKind: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
208
+ failureKind: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
209
209
  error: string | undefined;
210
210
  findings: {
211
211
  severity: string;
@@ -32,11 +32,11 @@ export declare function statusOf(source: StatusSource, graphId?: string, options
32
32
  reason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
33
33
  paused: boolean;
34
34
  } | {
35
- code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
36
- cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
35
+ code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "CONTEXT_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
36
+ cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
37
37
  actor?: import("../projections/enums.ts").Actor | undefined;
38
38
  action?: "none" | "wait" | "retry" | "review-plan" | "diagnose-failure" | "reset-attempts" | "raise-budget" | "replan-dependents" | "recovery-decision" | "user-decision" | "resume-queue" | "fix-environment" | "fix-access" | undefined;
39
- failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
39
+ failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
40
40
  operation?: string | undefined;
41
41
  since?: string | undefined;
42
42
  detail?: string;
@@ -113,7 +113,7 @@ export declare function statusOf(source: StatusSource, graphId?: string, options
113
113
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
114
114
  pausedAt?: string | undefined;
115
115
  pauseOperation?: string | undefined;
116
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
116
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
117
117
  waits?: {
118
118
  kind: "base-check" | "context-lock";
119
119
  detail: string;
@@ -150,11 +150,11 @@ export declare function statusOf(source: StatusSource, graphId?: string, options
150
150
  reason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
151
151
  paused: boolean;
152
152
  } | {
153
- code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
154
- cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
153
+ code?: "INVALID_INPUT" | "UNSUPPORTED_COMMAND" | "UNSUPPORTED_VERSION" | "GRAPH_CYCLE" | "GRAPH_UNKNOWN_DEPENDENCY" | "GRAPH_DUPLICATE_ID" | "GATE_UNKNOWN" | "GATE_GROUP_CYCLE" | "REVIEWER_SAME_VENDOR" | "REVIEWER_MISSING" | "RESPONSE_TOO_LARGE" | "APPROVAL_STALE" | "APPROVAL_REQUIRED" | "LEASE_STALE" | "CONTROLLER_BUSY" | "PAUSED" | "NOT_READY" | "SCOPE_VIOLATION" | "GATE_FAILED" | "REVIEW_REJECTED" | "BUDGET_EXHAUSTED" | "BUDGET_UNKNOWN" | "ATTEMPTS_EXHAUSTED" | "CONTEXT_EXHAUSTED" | "REVISION_CONFLICT" | "CANCELLED" | "NOT_FOUND" | "PATH_CONFLICT" | "STATE_VERSION_UNSUPPORTED" | "RUNTIME_UNAVAILABLE" | "REVIEW_PROTOCOL_INVALID" | "SANDBOX_UNAVAILABLE" | "GIT_FAILED" | "STORAGE_FAILED" | "DELIVERY_FAILED" | "INTERNAL" | undefined;
154
+ cause?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | "runtime-missing" | "controller-busy" | "operator-pause" | "approval-required" | "not-ready" | undefined;
155
155
  actor?: import("../projections/enums.ts").Actor | undefined;
156
156
  action?: "none" | "wait" | "retry" | "review-plan" | "diagnose-failure" | "reset-attempts" | "raise-budget" | "replan-dependents" | "recovery-decision" | "user-decision" | "resume-queue" | "fix-environment" | "fix-access" | undefined;
157
- failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
157
+ failures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
158
158
  operation?: string | undefined;
159
159
  since?: string | undefined;
160
160
  detail?: string;
@@ -210,7 +210,7 @@ export declare function statusOf(source: StatusSource, graphId?: string, options
210
210
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
211
211
  pausedAt?: string | undefined;
212
212
  pauseOperation?: string | undefined;
213
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
213
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
214
214
  waits?: {
215
215
  kind: "base-check" | "context-lock";
216
216
  detail: string;
@@ -70,6 +70,6 @@ export function environmentCauseOf(error, message, kind) {
70
70
  */
71
71
  export function withSuffix(failure, suffix) {
72
72
  return failure instanceof TaskFailure
73
- ? new TaskFailure(failure.kind, `${failure.message}; ${suffix}`, failure.properties, failure.diagnosis)
73
+ ? new TaskFailure(failure.kind, `${failure.message}; ${suffix}`, failure.properties, failure.diagnosis, failure.contextLimit)
74
74
  : new Error(`${failure.message}; ${suffix}`, { cause: failure });
75
75
  }
@@ -1,4 +1,4 @@
1
- import { type ReproductionRecord, type AttemptState, type RunEventPayload, type CancelActor, type EnvironmentCause, type RetryActor, type Author, type CallRecord, type ContractDocument, type EvidenceRecord, type ExecutionHost, type ExecutionPolicy, type ExecutionTransaction, type ExecutionView, type FailureKind, type GraphState, type JointVerification, type JointVerificationState, type NotPromise, type Prerequisite, type PropertyRecovery, type ReviewRecord, type TechnicalApproval, type TransactionKind, type WorkGraph, type WorkState } from '../contracts/index.ts';
1
+ import { type ReproductionRecord, type AttemptState, type RunEventPayload, type CancelActor, type ContextLimit, type EnvironmentCause, type RetryActor, type Author, type CallRecord, type ContractDocument, type EvidenceRecord, type ExecutionHost, type ExecutionPolicy, type ExecutionTransaction, type ExecutionView, type FailureKind, type GraphState, type JointVerification, type JointVerificationState, type NotPromise, type Prerequisite, type PropertyRecovery, type ReviewRecord, type TechnicalApproval, type TransactionKind, type WorkGraph, type WorkState } from '../contracts/index.ts';
2
2
  import { type BudgetContext, type CallMeta } from './budget.ts';
3
3
  /** Префикс причины неудавшегося продления: первая причина не затирается следствиями. */
4
4
  export declare const HEARTBEAT_FAILED = "\u041F\u0440\u043E\u0434\u043B\u0435\u043D\u0438\u0435 \u0432\u043B\u0430\u0434\u0435\u043D\u0438\u044F \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C";
@@ -255,7 +255,7 @@ export declare class Engine {
255
255
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
256
256
  pausedAt?: string | undefined;
257
257
  pauseOperation?: string | undefined;
258
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
258
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
259
259
  waits?: {
260
260
  kind: "base-check" | "context-lock";
261
261
  detail: string;
@@ -291,7 +291,7 @@ export declare class Engine {
291
291
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
292
292
  pausedAt?: string | undefined;
293
293
  pauseOperation?: string | undefined;
294
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
294
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
295
295
  waits?: {
296
296
  kind: "base-check" | "context-lock";
297
297
  detail: string;
@@ -321,7 +321,7 @@ export declare class Engine {
321
321
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
322
322
  pausedAt?: string | undefined;
323
323
  pauseOperation?: string | undefined;
324
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
324
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
325
325
  waits?: {
326
326
  kind: "base-check" | "context-lock";
327
327
  detail: string;
@@ -715,6 +715,8 @@ export declare class Engine {
715
715
  * без неё — по классу отказа.
716
716
  */
717
717
  cause?: EnvironmentCause;
718
+ /** Предел окна контекста — пишется только у отказа `context-exhausted`. */
719
+ contextLimit?: ContextLimit;
718
720
  }): {
719
721
  recovery?: {
720
722
  id: string;
@@ -723,7 +725,7 @@ export declare class Engine {
723
725
  properties?: string[] | undefined;
724
726
  workId: string;
725
727
  runId: string;
726
- kind: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead";
728
+ kind: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead";
727
729
  blocked: boolean;
728
730
  /** Работа возвращена в очередь (штатная остановка); иначе — обычный отказ. */
729
731
  interrupted: boolean;
@@ -1465,7 +1467,7 @@ export declare class Engine {
1465
1467
  activeRunId?: string | undefined;
1466
1468
  resultSha?: string | undefined;
1467
1469
  failure?: string | undefined;
1468
- failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
1470
+ failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
1469
1471
  failureFingerprint?: string | undefined;
1470
1472
  approvedAt?: string | undefined;
1471
1473
  approvedDigest?: string | undefined;
@@ -1625,7 +1627,7 @@ export declare class Engine {
1625
1627
  activeRunId?: string | undefined;
1626
1628
  resultSha?: string | undefined;
1627
1629
  failure?: string | undefined;
1628
- failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
1630
+ failureKind?: "gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead" | undefined;
1629
1631
  failureFingerprint?: string | undefined;
1630
1632
  approvedAt?: string | undefined;
1631
1633
  approvedDigest?: string | undefined;
@@ -1477,6 +1477,9 @@ export class Engine {
1477
1477
  error: shown,
1478
1478
  ...(blocked ? { blocked: true } : {}),
1479
1479
  failureKind: kind,
1480
+ ...(kind === 'context-exhausted' && options.contextLimit
1481
+ ? { contextLimit: options.contextLimit }
1482
+ : {}),
1480
1483
  failureFingerprint: fingerprint,
1481
1484
  finishedAt: iso(this.now()),
1482
1485
  ...(bound.length ? { properties: bound } : {}),
@@ -1 +1 @@
1
- export { TaskFailure, failureFingerprint, failureKinds, repairPolicy, MAX_NEUTRAL_FAILURES, type FailureKind, type RepairRule, } from '../contracts/index.ts';
1
+ export { TaskFailure, failureFingerprint, failureKinds, repairPolicy, repairRepeats, lastContextLimit, MAX_NEUTRAL_FAILURES, type FailureKind, type RepairRule, } from '../contracts/index.ts';
@@ -1,3 +1,3 @@
1
1
  // Таксономия отказов — часть договора (`contracts/failure.ts`): её читают и
2
2
  // хосты, в том числе в браузере, без загрузки исполнения.
3
- export { TaskFailure, failureFingerprint, failureKinds, repairPolicy, MAX_NEUTRAL_FAILURES, } from "../contracts/index.js";
3
+ export { TaskFailure, failureFingerprint, failureKinds, repairPolicy, repairRepeats, lastContextLimit, MAX_NEUTRAL_FAILURES, } from "../contracts/index.js";
@@ -119,9 +119,19 @@ export function prompt(input) {
119
119
  findingsText(input.findings, !!review),
120
120
  !review && attempt.continuedFrom?.applied
121
121
  ? attempt.continuedFrom.kind === 'unfinished'
122
- ? `The previous attempt stopped before finishing (${attempt.continuedFrom.reason === 'timeout' ? 'ran out of time' : attempt.continuedFrom.reason}). Its unfinished, unverified changes are already applied in this worktree as uncommitted edits (${attempt.continuedFrom.files.join(', ')}). Continue from them: check what is done and what is broken, finish the work and make the gates pass. Treat them as a draft, not as reviewed work.`
122
+ ? `The previous attempt stopped before finishing (${attempt.continuedFrom.reason === 'timeout' ? 'ran out of time' : attempt.continuedFrom.reason === 'context-exhausted' ? 'ran out of the model context window' : attempt.continuedFrom.reason}). Its unfinished, unverified changes are already applied in this worktree as uncommitted edits (${attempt.continuedFrom.files.join(', ')}). Continue from them: check what is done and what is broken, finish the work and make the gates pass. Treat them as a draft, not as reviewed work.`
123
123
  : `The previous attempt produced a candidate that failed (${attempt.continuedFrom.reason === 'review' ? 'rejected by review' : attempt.continuedFrom.reason}); see its error and findings above. Its changes are already applied in this worktree as uncommitted edits (${attempt.continuedFrom.files.join(', ')}). Fix what failed on top of them; if the failure shows the approach itself is wrong, replace it rather than patching around it. The gates and a new independent review decide again.`
124
124
  : '',
125
+ // Повтор writer после нехватки окна контекста: прошлый способ работы не
126
+ // помещался. Reviewer той же попытки подсказку не получает; о самой
127
+ // нехватке уже сказал абзац черновика, если черновик наложен.
128
+ !review &&
129
+ input.history.filter((a) => a.id !== attempt.id).at(-1)?.failureKind === 'context-exhausted'
130
+ ? (attempt.continuedFrom?.applied && attempt.continuedFrom.reason === 'context-exhausted'
131
+ ? ''
132
+ : 'The previous attempt ran out of the model context window. ') +
133
+ 'Keep your context small this time: read only the files and line ranges you need, do not print whole large files or long command output, and do not re-read what you already have.'
134
+ : '',
125
135
  !review && attempt.continuedFrom?.applied && attempt.continuedFrom.respecified
126
136
  ? 'The specification or its contracts changed after that attempt: check the applied changes against the current approved specification and contracts above, not against the old ones.'
127
137
  : '',
@@ -32,6 +32,8 @@ const neutral = [
32
32
  'environment',
33
33
  'timeout',
34
34
  'stalled',
35
+ // Нехватка окна контекста говорит о размере задачи, а не о свойстве.
36
+ 'context-exhausted',
35
37
  'stale-base',
36
38
  'merge',
37
39
  'cancelled',
@@ -1,4 +1,5 @@
1
1
  import { MAX_NEUTRAL_FAILURES, repairPolicy } from "./failure.js";
2
+ import { lastContextLimit, repairRepeats } from "../contracts/repair-policy.js";
2
3
  import { RECOVERY_THRESHOLD, isNeutral } from "./property-recovery.js";
3
4
  const normalized = (c) => c.trim().toLowerCase().replace(/\s+/g, ' ');
4
5
  /** Что отклонившее ревью назвало в попытке: пары, необъявленные свойства и классы входов. */
@@ -144,7 +145,8 @@ export function repairDecision(view, works, options) {
144
145
  const identical = fingerprint
145
146
  ? view.attempts(work.id).filter((a) => a.failureFingerprint === fingerprint).length
146
147
  : 0;
147
- if (!fingerprint || identical > rule.repeats)
148
+ const repeats = repairRepeats(kind, lastContextLimit(view.attempts(work.id)));
149
+ if (!fingerprint || identical > repeats)
148
150
  return {
149
151
  action: 'stop',
150
152
  workId: work.id,
@@ -159,6 +161,6 @@ export function repairDecision(view, works, options) {
159
161
  kind,
160
162
  fingerprint,
161
163
  blocksQueue: rule.blocksQueue ?? false,
162
- reason: `${work.id}: ${kind}, повтор ${identical} из ${rule.repeats}.${detail}`,
164
+ reason: `${work.id}: ${kind}, повтор ${identical} из ${repeats}.${detail}`,
163
165
  };
164
166
  }
@@ -13,6 +13,8 @@ export const reusableFailures = [
13
13
  'environment',
14
14
  'timeout',
15
15
  'stalled',
16
+ // Нехватка окна контекста (обычно у reviewer большого diff) о коде не говорит.
17
+ 'context-exhausted',
16
18
  // Ответ reviewer вне протокола о коде кандидата ничего не говорит.
17
19
  'review-protocol',
18
20
  ];
@@ -556,6 +556,12 @@ export class Runner {
556
556
  };
557
557
  if (response.status === 'failed') {
558
558
  const message = `${adapter.runtime}: runtime завершился отказом${response.diagnostics.reason ? ': ' + response.diagnostics.reason : ''}`;
559
+ // Класс — по признаку адаптера, до разбора текста: числа токенов в
560
+ // причине совпадали бы с признаками отказа провайдера («401», «429»).
561
+ // Текст постоянный, предел — данными: отпечаток один при любом пределе
562
+ // и любых числах токенов; текст runtime — в журнале вызова.
563
+ if (response.diagnostics.contextExhausted)
564
+ throw new TaskFailure('context-exhausted', `${adapter.runtime}: не хватило окна контекста модели`, undefined, undefined, response.diagnostics.contextExhausted);
559
565
  throw new TaskFailure(classifyFailure(undefined, message) === 'unknown'
560
566
  ? review
561
567
  ? 'review'
@@ -1101,6 +1107,9 @@ export class Runner {
1101
1107
  ? { properties: error.properties }
1102
1108
  : {}),
1103
1109
  kind,
1110
+ ...(!stalled && error instanceof TaskFailure && error.contextLimit
1111
+ ? { contextLimit: error.contextLimit }
1112
+ : {}),
1104
1113
  cause: environmentCauseOf(stalled ? undefined : error, message, kind),
1105
1114
  blocked: (error instanceof BlockedError || kind === 'provider-auth') && !attempt.candidateSha,
1106
1115
  ...(heartbeatCause ? { heartbeatCause } : {}),
@@ -40,7 +40,7 @@ export declare function nextRunControl(h: {
40
40
  pauseReason?: "runtime" | "operator" | "shutdown" | "base-check" | "reconfigure" | undefined;
41
41
  pausedAt?: string | undefined;
42
42
  pauseOperation?: string | undefined;
43
- pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
43
+ pauseFailures?: ("gate" | "unknown" | "review" | "cancelled" | "environment" | "timeout" | "provider-auth" | "stalled" | "context-exhausted" | "stale-base" | "empty-result" | "unfinished" | "scope-violation" | "review-protocol" | "merge" | "budget" | "needs-lead")[] | undefined;
44
44
  waits?: {
45
45
  kind: "base-check" | "context-lock";
46
46
  detail: string;
@@ -1,5 +1,5 @@
1
1
  import { HarnessError } from "../contracts/errors.js";
2
- import { MAX_NEUTRAL_FAILURES, repairPolicy } from "../contracts/repair-policy.js";
2
+ import { MAX_NEUTRAL_FAILURES, lastContextLimit, repairPolicy, repairRepeats, } from "../contracts/repair-policy.js";
3
3
  import { acceptanceGap, repairDecision } from "../engine/repair.js";
4
4
  /**
5
5
  * Control таким, каким его увидит следующий run этого процесса: run снимает
@@ -178,6 +178,9 @@ export function stopInputsOf(h, options) {
178
178
  status: work.status,
179
179
  attempt: work.attempt,
180
180
  ...(work.failureKind ? { failureKind: work.failureKind } : {}),
181
+ ...(work.failureKind === 'context-exhausted' && lastContextLimit(attempts)
182
+ ? { contextLimit: lastContextLimit(attempts) }
183
+ : {}),
181
184
  ...(work.failure !== undefined ? { failure: work.failure } : {}),
182
185
  ...(work.hold
183
186
  ? { hold: { operation: work.hold.operation, reason: work.hold.reason } }
@@ -207,7 +210,9 @@ export function stopInputsOf(h, options) {
207
210
  },
208
211
  maxAttempts: options.maxAttempts,
209
212
  repair: {
210
- sameFailureRepairs: fingerprint ? identical - 1 : repairPolicy[kind].repeats,
213
+ sameFailureRepairs: fingerprint
214
+ ? identical - 1
215
+ : repairRepeats(kind, lastContextLimit(attempts)),
211
216
  groupRepairsUsed: job?.repairs ?? 0,
212
217
  groupRepairBudget: job ? options.repairBudget : 0,
213
218
  ...(outlook ? { outlook } : {}),
@@ -339,11 +344,12 @@ function outlookOf(v, graphId, repairsUsed, options, control, budgetHeld) {
339
344
  const ahead = episodes.length ? 'wait' : 'retry';
340
345
  for (const [i, w] of plain.entries()) {
341
346
  const rule = repairPolicy[w.failureKind ?? 'unknown'];
347
+ const repeats = repairRepeats(w.failureKind ?? 'unknown', lastContextLimit(v.attempts(w.id)));
342
348
  const identical = w.failureFingerprint
343
349
  ? v.attempts(w.id).filter((a) => a.failureFingerprint === w.failureFingerprint).length
344
- : rule.repeats + 1;
350
+ : repeats + 1;
345
351
  const retry = rule.action === 'retry' &&
346
- identical - 1 < rule.repeats &&
352
+ identical - 1 < repeats &&
347
353
  !acceptanceGap(v, w) &&
348
354
  (w.neutralFailures ?? 0) < MAX_NEUTRAL_FAILURES &&
349
355
  w.attempt < options.maxAttempts &&
package/lib/index.d.ts CHANGED
@@ -79,7 +79,7 @@ export { checkoutCacheBase, checkoutPath, chooseCheckoutRoot, type CheckoutPlace
79
79
  export { closeIfBasisChanged } from './engine/property-recovery.ts';
80
80
  export { analyzeRecovery, applyCases, recoveryBrief, recoveryOutputSchema, recoveryResultSchema, } from './control/recovery.ts';
81
81
  export { BlockedError, classifyFailure, providerRefusal } from './engine/classify.ts';
82
- export { TaskFailure, failureFingerprint, repairPolicy, MAX_NEUTRAL_FAILURES, type RepairRule, } from './engine/failure.ts';
82
+ export { TaskFailure, failureFingerprint, repairPolicy, repairRepeats, lastContextLimit, MAX_NEUTRAL_FAILURES, type RepairRule, } from './engine/failure.ts';
83
83
  export * from './projections/index.ts';
84
84
  export * from './report/index.ts';
85
85
  export { collectReportInput } from './control/report.ts';
package/lib/index.js CHANGED
@@ -83,7 +83,7 @@ export { analyzeRecovery, applyCases, recoveryBrief, recoveryOutputSchema, recov
83
83
  // Классы отказов и правила отказов: хост бросает их из своих хуков и
84
84
  // читает класс отказа попытки теми же правилами, что и движок.
85
85
  export { BlockedError, classifyFailure, providerRefusal } from "./engine/classify.js";
86
- export { TaskFailure, failureFingerprint, repairPolicy, MAX_NEUTRAL_FAILURES, } from "./engine/failure.js";
86
+ export { TaskFailure, failureFingerprint, repairPolicy, repairRepeats, lastContextLimit, MAX_NEUTRAL_FAILURES, } from "./engine/failure.js";
87
87
  export * from "./projections/index.js";
88
88
  export * from "./report/index.js";
89
89
  export { collectReportInput } from "./control/report.js";
@@ -25,7 +25,7 @@ export declare function queuePause(control: {
25
25
  pauseReason?: PauseReason;
26
26
  pauseFailures?: readonly FailureKind[];
27
27
  }): QueuePause | undefined;
28
- export declare const stopCauses: readonly ["provider-auth", "environment", "timeout", "stalled", "stale-base", "empty-result", "unfinished", "scope-violation", "gate", "review", "review-protocol", "merge", "cancelled", "budget", "needs-lead", "unknown", "runtime-missing", "controller-busy", "operator-pause", "approval-required", "not-ready"];
28
+ export declare const stopCauses: readonly ["provider-auth", "environment", "timeout", "stalled", "context-exhausted", "stale-base", "empty-result", "unfinished", "scope-violation", "gate", "review", "review-protocol", "merge", "cancelled", "budget", "needs-lead", "unknown", "runtime-missing", "controller-busy", "operator-pause", "approval-required", "not-ready"];
29
29
  export type StopCause = (typeof stopCauses)[number];
30
30
  export declare const stopPhases: readonly ["preflight", "claim", "implementation", "gates", "review", "integration", "delivery"];
31
31
  export type StopPhase = (typeof stopPhases)[number];
@@ -41,6 +41,8 @@ export type StopInput = {
41
41
  status: WorkStatus;
42
42
  attempt: number;
43
43
  failureKind?: FailureKind;
44
+ /** Предел окна контекста последнего отказа `context-exhausted`. */
45
+ contextLimit?: 'prompt-too-long' | 'blocking-limit';
44
46
  failure?: string;
45
47
  hold?: {
46
48
  operation: string;
@@ -1,5 +1,5 @@
1
1
  import { errorCodes } from "../contracts/errors.js";
2
- import { repairPolicy } from "../contracts/repair-policy.js";
2
+ import { repairPolicy, repairRepeats } from "../contracts/repair-policy.js";
3
3
  import { CLIP_DIAGNOSTIC, clipText } from "./clip.js";
4
4
  /**
5
5
  * Код остановки по классу отказа. Это та же таблица, которой RunResult
@@ -23,6 +23,8 @@ export function stopCodeOf(kind) {
23
23
  return 'BUDGET_EXHAUSTED';
24
24
  case 'cancelled':
25
25
  return 'CANCELLED';
26
+ case 'context-exhausted':
27
+ return 'CONTEXT_EXHAUSTED';
26
28
  case 'provider-auth':
27
29
  case 'environment':
28
30
  case 'timeout':
@@ -65,6 +67,7 @@ export const stopCauses = [
65
67
  'environment',
66
68
  'timeout',
67
69
  'stalled',
70
+ 'context-exhausted',
68
71
  'stale-base',
69
72
  'empty-result',
70
73
  'unfinished',
@@ -98,6 +101,7 @@ const causeText = {
98
101
  environment: 'Окружение не дало исполнителю работать (сеть, TLS/DNS, процесс runtime).',
99
102
  timeout: 'Попытка исчерпала отведённое время.',
100
103
  stalled: 'Процесс попытки жив, но не двигался дольше порога: нет вывода, расхода процессора и смены стадий.',
104
+ 'context-exhausted': 'Исполнителю не хватило окна контекста модели: задача или её контекст не помещаются в одну попытку.',
101
105
  'stale-base': 'База прогонов отстала от рабочей ветки.',
102
106
  'empty-result': 'Исполнитель отчитался о выполнении, не изменив ни одного файла.',
103
107
  unfinished: 'Исполнитель не доделал работу и сообщил об этом.',
@@ -122,6 +126,7 @@ const failurePhase = {
122
126
  environment: 'implementation',
123
127
  timeout: 'implementation',
124
128
  stalled: 'implementation',
129
+ 'context-exhausted': 'implementation',
125
130
  unknown: 'implementation',
126
131
  'empty-result': 'implementation',
127
132
  unfinished: 'implementation',
@@ -159,7 +164,7 @@ function retryPlannedOf(input) {
159
164
  return false;
160
165
  const rule = repairPolicy[work.failureKind ?? 'unknown'];
161
166
  return (rule.action === 'retry' &&
162
- repair.sameFailureRepairs < rule.repeats &&
167
+ repair.sameFailureRepairs < repairRepeats(work.failureKind ?? 'unknown', work.contextLimit) &&
163
168
  work.attempt < maxAttempts &&
164
169
  repair.groupRepairsUsed < repair.groupRepairBudget);
165
170
  }
@@ -367,6 +372,21 @@ function workOutcome(input, retry) {
367
372
  case 'cancelled':
368
373
  // Поручение со статусом failed и классом cancelled: отмена не повторяется.
369
374
  return cancelledOutcome(work.openDependents, phase, true);
375
+ case 'context-exhausted':
376
+ return {
377
+ code: stopCodeOf(kind),
378
+ cause: kind,
379
+ phase,
380
+ actor: 'lead',
381
+ action: 'diagnose-failure',
382
+ // Повтор упоминается, только если он был: первый отказ вне задания
383
+ // графа тоже приходит сюда, без повтора.
384
+ note: work.contextLimit === 'prompt-too-long'
385
+ ? 'Окно контекста модели превышено уже первым запросом, повтор только удлинит его: разделите поручение или сократите контекст (меньше файлов и вывода в подсказке, уже область).'
386
+ : input.repair.sameFailureRepairs > 0
387
+ ? 'Окна контекста модели не хватило и на повторе: разделите поручение или сократите контекст (меньше файлов и вывода в подсказке, уже область).'
388
+ : 'Окна контекста модели не хватило: повторите с меньшим контекстом, разделите поручение или сократите контекст (меньше файлов и вывода в подсказке, уже область).',
389
+ };
370
390
  default:
371
391
  return {
372
392
  code: stopCodeOf(kind),
@@ -522,6 +542,14 @@ function errorOutcome(code) {
522
542
  return { code, cause: 'budget', phase: 'claim', actor: 'user', action: 'raise-budget' };
523
543
  case 'ATTEMPTS_EXHAUSTED':
524
544
  return { code, cause: 'unknown', phase: 'claim', actor: 'user', action: 'reset-attempts' };
545
+ case 'CONTEXT_EXHAUSTED':
546
+ return {
547
+ code,
548
+ cause: 'context-exhausted',
549
+ phase: 'implementation',
550
+ actor: 'lead',
551
+ action: 'diagnose-failure',
552
+ };
525
553
  case 'RUNTIME_UNAVAILABLE':
526
554
  return {
527
555
  code,
@@ -104,6 +104,7 @@ const bucketOfKind = {
104
104
  'scope-violation': 'defect',
105
105
  'empty-result': 'incomplete',
106
106
  unfinished: 'incomplete',
107
+ 'context-exhausted': 'incomplete',
107
108
  'needs-lead': 'incomplete',
108
109
  'stale-base': 'integration',
109
110
  merge: 'integration',
@@ -19,7 +19,7 @@ const actionsLine = (items) => {
19
19
  };
20
20
  const bucketLabels = {
21
21
  defect: 'defect (check, review, scope)',
22
- incomplete: 'incomplete (empty, unfinished, needs lead)',
22
+ incomplete: 'incomplete (empty, unfinished, needs lead, context exhausted)',
23
23
  integration: 'integration (stale base, merge)',
24
24
  environment: 'environment (sandbox, network, provider, lease)',
25
25
  'time-limit': 'time limit',