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

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 (97) hide show
  1. package/README.md +43 -16
  2. package/docs/architecture.md +12 -0
  3. package/docs/compatibility.md +21 -18
  4. package/docs/contracts.md +270 -12
  5. package/docs/release-notes/0.1.0-alpha.31.md +44 -0
  6. package/docs/release-notes/0.1.0-alpha.32.md +33 -0
  7. package/docs/release-notes/0.1.0-alpha.33.md +29 -0
  8. package/docs/release-notes/0.1.0-alpha.34.md +32 -0
  9. package/docs/upgrade.md +181 -0
  10. package/lib/agents/cli-adapter.js +1 -0
  11. package/lib/cli.js +25 -3
  12. package/lib/contracts/cli.d.ts +1381 -18
  13. package/lib/contracts/cli.js +43 -1
  14. package/lib/contracts/diagnosis.d.ts +2 -1
  15. package/lib/contracts/diagnosis.js +1 -0
  16. package/lib/contracts/events.d.ts +760 -5
  17. package/lib/contracts/events.js +109 -3
  18. package/lib/contracts/execution.d.ts +112 -1
  19. package/lib/contracts/execution.js +38 -0
  20. package/lib/contracts/failure.d.ts +6 -1
  21. package/lib/contracts/failure.js +5 -1
  22. package/lib/contracts/handoff.d.ts +702 -0
  23. package/lib/contracts/handoff.js +305 -0
  24. package/lib/contracts/index.d.ts +1 -0
  25. package/lib/contracts/index.js +1 -0
  26. package/lib/contracts/policy.d.ts +27 -1
  27. package/lib/contracts/policy.js +38 -2
  28. package/lib/contracts/published.d.ts +1016 -3
  29. package/lib/contracts/published.js +2 -0
  30. package/lib/contracts/repair-policy.js +5 -0
  31. package/lib/contracts/report.d.ts +118 -2
  32. package/lib/contracts/report.js +61 -3
  33. package/lib/control/base-move.d.ts +7 -2
  34. package/lib/control/base-move.js +14 -1
  35. package/lib/control/harness.d.ts +81 -19
  36. package/lib/control/harness.js +8 -93
  37. package/lib/control/recovery.d.ts +1 -1
  38. package/lib/control/status.d.ts +235 -0
  39. package/lib/control/status.js +101 -0
  40. package/lib/engine/budget.d.ts +78 -0
  41. package/lib/engine/budget.js +13 -2
  42. package/lib/engine/classify.d.ts +14 -1
  43. package/lib/engine/classify.js +34 -0
  44. package/lib/engine/engine.d.ts +31 -11
  45. package/lib/engine/engine.js +99 -5
  46. package/lib/engine/joint-runner.d.ts +6 -0
  47. package/lib/engine/joint-runner.js +20 -4
  48. package/lib/engine/property-recovery.js +1 -0
  49. package/lib/engine/reuse.js +1 -0
  50. package/lib/engine/runner.d.ts +8 -0
  51. package/lib/engine/runner.js +120 -16
  52. package/lib/engine/stall-sweep.d.ts +137 -0
  53. package/lib/engine/stall-sweep.js +393 -0
  54. package/lib/environment/activity.d.ts +34 -0
  55. package/lib/environment/activity.js +55 -0
  56. package/lib/environment/isolation.d.ts +67 -3
  57. package/lib/environment/isolation.js +148 -5
  58. package/lib/environment/lifecycle.js +2 -1
  59. package/lib/environment/process.d.ts +7 -1
  60. package/lib/environment/process.js +14 -0
  61. package/lib/environment/redaction.d.ts +2 -0
  62. package/lib/environment/redaction.js +19 -0
  63. package/lib/explain/state.d.ts +26 -5
  64. package/lib/explain/state.js +41 -0
  65. package/lib/handoff/index.d.ts +2 -0
  66. package/lib/handoff/index.js +3 -0
  67. package/lib/handoff/markdown.d.ts +6 -0
  68. package/lib/handoff/markdown.js +155 -0
  69. package/lib/handoff/pack.d.ts +79 -0
  70. package/lib/handoff/pack.js +531 -0
  71. package/lib/index.d.ts +19 -3
  72. package/lib/index.js +18 -1
  73. package/lib/integrations/connector/redact.d.ts +2 -13
  74. package/lib/integrations/connector/redact.js +2 -21
  75. package/lib/integrations/connector/testing.js +1 -1
  76. package/lib/projections/attempt.d.ts +28 -0
  77. package/lib/projections/attempt.js +14 -0
  78. package/lib/projections/next.d.ts +3 -1
  79. package/lib/projections/next.js +4 -1
  80. package/lib/projections/stop.d.ts +22 -1
  81. package/lib/projections/stop.js +73 -15
  82. package/lib/report/compute.js +229 -21
  83. package/lib/report/document.js +31 -7
  84. package/lib/storage/document.d.ts +28 -6
  85. package/lib/storage/sqlite.d.ts +2 -0
  86. package/lib/storage/sqlite.js +9 -1
  87. package/lib/verification/gates-at.d.ts +11 -1
  88. package/lib/verification/gates-at.js +28 -2
  89. package/lib/verification/gates.d.ts +3 -1
  90. package/lib/verification/gates.js +25 -4
  91. package/package.json +1 -1
  92. package/schemas/execution-document.schema.json +68 -0
  93. package/schemas/execution-policy.schema.json +32 -0
  94. package/schemas/handoff-pack.schema.json +1430 -0
  95. package/schemas/run-event.schema.json +679 -0
  96. package/schemas/stop-diagnosis.schema.json +1 -0
  97. package/schemas/value-report.schema.json +236 -3
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { API_VERSION, STATE_VERSION } from "./version.js";
3
3
  import { digestSchema, gitShaSchema, idSchema, isoTimeSchema, runtimeNameSchema, targetRefSchema, } from "./primitives.js";
4
4
  import { HarnessError, errorCodes } from "./errors.js";
5
- import { controlStateSchema, controllerLeaseSchema, failureKindSchema, pauseReasons, workStatusSchema, } from "./execution.js";
5
+ import { controlStateSchema, controllerLeaseSchema, failureKindSchema, pauseReasons, workStatusSchema, activitySchema, livenessStateSchema, stallActionSchema, } from "./execution.js";
6
6
  import { readRunEventSchema } from "./events.js";
7
7
  import { deliveryStateSchema, resultEnvelopeSchema } from "./result.js";
8
8
  import { reviewRecordSchema } from "./review.js";
@@ -14,6 +14,7 @@ import { planCheckDataSchema, planRequestDataSchema } from "./planning.js";
14
14
  import { toolchainReportSchema } from "./toolchain.js";
15
15
  import { operationCatalogSchema } from "./catalog.js";
16
16
  import { reportDataSchema } from "./report.js";
17
+ import { handoffPackSchema } from "./handoff.js";
17
18
  const state = {
18
19
  name: '--state',
19
20
  value: 'dir',
@@ -417,6 +418,29 @@ export const cliCommands = {
417
418
  ],
418
419
  refusals: ['NOT_FOUND', 'PATH_CONFLICT'],
419
420
  },
421
+ handoff: {
422
+ description: 'Пакет передачи контекста для новой сессии ведущего агента из хранилища: активная работа и стадия, решения и остановки, незавершённые попытки, последние провалы, бюджеты, следующий шаг; только чтение',
423
+ writes: false,
424
+ idempotency: 'Только чтение; агент добавляет только намерения (--intent)',
425
+ args: [
426
+ state,
427
+ { name: '--graph', value: 'id', required: false, description: 'Только этот граф' },
428
+ {
429
+ name: '--intent',
430
+ value: 'text',
431
+ required: false,
432
+ multiple: true,
433
+ description: 'Намерение агента (до 20, каждое до 1000 знаков); единственный текст не из хранилища',
434
+ },
435
+ {
436
+ name: '--format',
437
+ value: 'text',
438
+ required: false,
439
+ description: 'json (по умолчанию, конверт HandoffPack) или md (Markdown без конверта)',
440
+ },
441
+ ],
442
+ refusals: ['NOT_FOUND'],
443
+ },
420
444
  'plan-request': {
421
445
  description: 'Собрать read-only запрос планирования из постановки и фактов проекта (роли, gates, репозитории, контекст, ресурсы, контракты, требования) для ведущего агента; модель не вызывается, ничего не пишется',
422
446
  writes: false,
@@ -619,6 +643,17 @@ export const attemptViewSchema = z.strictObject({
619
643
  failed: z.number().int().min(0),
620
644
  remaining: z.number().int().min(0),
621
645
  }),
646
+ /** Живость по обходу controller; `idleMs` — только у `quiet` и `stalled`. */
647
+ liveness: z
648
+ .strictObject({
649
+ state: livenessStateSchema,
650
+ since: isoTimeSchema,
651
+ lastMovementAt: isoTimeSchema,
652
+ idleMs: z.number().int().min(0).optional(),
653
+ activity: activitySchema.optional(),
654
+ action: stallActionSchema.optional(),
655
+ })
656
+ .optional(),
622
657
  });
623
658
  /**
624
659
  * Почему выдача стоит (`status --detail`): причина паузы (`queueStop`), кто и
@@ -658,6 +693,12 @@ export const statusDataSchema = z.strictObject({
658
693
  status: workStatusSchema,
659
694
  attempt: z.number().int().min(0),
660
695
  activeRunId: z.string().optional(),
696
+ /**
697
+ * Активная попытка без движения по обходу controller: `quiet` или
698
+ * `stalled` (с `status --detail` — подробности в `detail.attempts`).
699
+ * Нет поля — движется или не оценивалась.
700
+ */
701
+ liveness: z.enum(['quiet', 'stalled']).optional(),
661
702
  resultSha: gitShaSchema.optional(),
662
703
  /** Почему поручение сейчас не выдаётся; пусто — может быть выдано. */
663
704
  blockers: z.array(blocker),
@@ -1046,6 +1087,7 @@ export const cliDataSchemas = {
1046
1087
  init: initDataSchema,
1047
1088
  explain: explainDataSchema,
1048
1089
  report: reportDataSchema,
1090
+ handoff: handoffPackSchema,
1049
1091
  'plan-request': planRequestDataSchema,
1050
1092
  'plan-check': planCheckDataSchema,
1051
1093
  capabilities: operationCatalogSchema,
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export declare const diagnosisActors: readonly ["controller", "lead", "user"];
3
3
  export declare const diagnosisActions: readonly ["none", "wait", "review-plan", "retry", "diagnose-failure", "reset-attempts", "raise-budget", "replan-dependents", "recovery-decision", "user-decision", "resume-queue", "fix-environment", "fix-access"];
4
- export declare const diagnosisCauses: readonly ["provider-auth", "environment", "timeout", "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"];
4
+ export declare const diagnosisCauses: 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"];
5
5
  export declare const diagnosisPhases: readonly ["preflight", "claim", "implementation", "gates", "review", "integration", "delivery"];
6
6
  /** Объяснение остановки: код, причина, фаза, кто действует и что допустимо. */
7
7
  export declare const stopDiagnosisSchema: z.ZodObject<{
@@ -50,6 +50,7 @@ export declare const stopDiagnosisSchema: z.ZodObject<{
50
50
  environment: "environment";
51
51
  timeout: "timeout";
52
52
  "provider-auth": "provider-auth";
53
+ stalled: "stalled";
53
54
  "stale-base": "stale-base";
54
55
  "empty-result": "empty-result";
55
56
  unfinished: "unfinished";
@@ -22,6 +22,7 @@ export const diagnosisCauses = [
22
22
  'provider-auth',
23
23
  'environment',
24
24
  'timeout',
25
+ 'stalled',
25
26
  'stale-base',
26
27
  'empty-result',
27
28
  'unfinished',