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

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 (129) hide show
  1. package/README.md +56 -2
  2. package/docs/architecture.md +28 -4
  3. package/docs/contracts.md +294 -51
  4. package/docs/release-notes/0.1.0-alpha.36.md +26 -0
  5. package/docs/release-notes/0.1.0-alpha.37.md +40 -0
  6. package/docs/release-notes/0.1.0-alpha.38.md +31 -0
  7. package/docs/release-notes/0.1.0-alpha.39.md +38 -0
  8. package/docs/release-notes/0.1.0-alpha.40.md +27 -0
  9. package/docs/release-notes/0.1.0-alpha.41.md +49 -0
  10. package/docs/release-notes/0.1.0-alpha.42.md +44 -0
  11. package/docs/standalone.md +20 -0
  12. package/docs/toolchains.md +57 -2
  13. package/docs/upgrade.md +240 -0
  14. package/lib/agents/review-probe.d.ts +3 -1
  15. package/lib/agents/review-probe.js +8 -4
  16. package/lib/agents/schemas.d.ts +84 -2
  17. package/lib/agents/schemas.js +49 -1
  18. package/lib/cli.js +149 -1
  19. package/lib/contracts/cli.d.ts +1495 -170
  20. package/lib/contracts/cli.js +232 -2
  21. package/lib/contracts/diagnosis.d.ts +8 -4
  22. package/lib/contracts/diagnosis.js +3 -0
  23. package/lib/contracts/errors.d.ts +7 -1
  24. package/lib/contracts/errors.js +6 -0
  25. package/lib/contracts/events.d.ts +453 -60
  26. package/lib/contracts/events.js +79 -0
  27. package/lib/contracts/execution.d.ts +270 -50
  28. package/lib/contracts/execution.js +45 -3
  29. package/lib/contracts/failure.d.ts +14 -1
  30. package/lib/contracts/failure.js +9 -1
  31. package/lib/contracts/handoff.d.ts +70 -20
  32. package/lib/contracts/handoff.js +42 -1
  33. package/lib/contracts/index.d.ts +1 -0
  34. package/lib/contracts/index.js +1 -0
  35. package/lib/contracts/input-state.d.ts +13 -0
  36. package/lib/contracts/input-state.js +32 -0
  37. package/lib/contracts/input.d.ts +442 -0
  38. package/lib/contracts/input.js +321 -0
  39. package/lib/contracts/planning.d.ts +2 -0
  40. package/lib/contracts/policy.d.ts +36 -2
  41. package/lib/contracts/policy.js +61 -2
  42. package/lib/contracts/ports.d.ts +54 -0
  43. package/lib/contracts/project.d.ts +127 -0
  44. package/lib/contracts/project.js +99 -0
  45. package/lib/contracts/published.d.ts +604 -92
  46. package/lib/contracts/published.js +4 -1
  47. package/lib/contracts/repair-policy.d.ts +20 -0
  48. package/lib/contracts/repair-policy.js +34 -0
  49. package/lib/contracts/report.d.ts +53 -21
  50. package/lib/contracts/report.js +33 -2
  51. package/lib/contracts/result.d.ts +26 -24
  52. package/lib/contracts/review.d.ts +47 -8
  53. package/lib/contracts/review.js +21 -1
  54. package/lib/control/harness.d.ts +2555 -51
  55. package/lib/control/harness.js +112 -6
  56. package/lib/control/recovery.d.ts +2 -2
  57. package/lib/control/report.js +1 -0
  58. package/lib/control/status.d.ts +30 -22
  59. package/lib/control/status.js +11 -1
  60. package/lib/control/workflow.d.ts +8 -8
  61. package/lib/engine/budget.d.ts +86 -3
  62. package/lib/engine/budget.js +45 -10
  63. package/lib/engine/engine.d.ts +3091 -85
  64. package/lib/engine/engine.js +1229 -106
  65. package/lib/engine/input-policy.d.ts +68 -0
  66. package/lib/engine/input-policy.js +285 -0
  67. package/lib/engine/input-requests.d.ts +64 -0
  68. package/lib/engine/input-requests.js +187 -0
  69. package/lib/engine/joint-runner.js +2 -2
  70. package/lib/engine/measured.d.ts +6 -1
  71. package/lib/engine/measured.js +12 -1
  72. package/lib/engine/prompt.d.ts +4 -2
  73. package/lib/engine/prompt.js +3 -1
  74. package/lib/engine/property-recovery.js +2 -0
  75. package/lib/engine/repair.d.ts +2 -0
  76. package/lib/engine/repair.js +10 -3
  77. package/lib/engine/runner.d.ts +44 -4
  78. package/lib/engine/runner.js +347 -35
  79. package/lib/environment/isolation.d.ts +41 -1
  80. package/lib/environment/isolation.js +167 -5
  81. package/lib/environment/lifecycle.d.ts +54 -2
  82. package/lib/environment/lifecycle.js +96 -4
  83. package/lib/explain/state.d.ts +16 -2
  84. package/lib/explain/state.js +254 -77
  85. package/lib/handoff/markdown.js +10 -0
  86. package/lib/handoff/pack.js +42 -1
  87. package/lib/index.d.ts +10 -0
  88. package/lib/index.js +10 -0
  89. package/lib/init/inspect.d.ts +34 -0
  90. package/lib/init/inspect.js +292 -0
  91. package/lib/init/project.js +14 -31
  92. package/lib/integrations/connector/commands.d.ts +12 -12
  93. package/lib/integrations/connector/config.d.ts +4 -4
  94. package/lib/integrations/connector/delivery.d.ts +1 -1
  95. package/lib/integrations/relay-v2/protocol.d.ts +4 -4
  96. package/lib/profiles/resolve.d.ts +2 -1
  97. package/lib/projections/enums.d.ts +1 -1
  98. package/lib/projections/enums.js +4 -0
  99. package/lib/projections/index.d.ts +1 -0
  100. package/lib/projections/index.js +1 -0
  101. package/lib/projections/input.d.ts +17 -0
  102. package/lib/projections/input.js +28 -0
  103. package/lib/projections/stop.d.ts +40 -1
  104. package/lib/projections/stop.js +87 -4
  105. package/lib/report/compute.d.ts +4 -1
  106. package/lib/report/compute.js +41 -6
  107. package/lib/report/document.js +3 -2
  108. package/lib/storage/document.d.ts +66 -28
  109. package/lib/testing/index.d.ts +1 -1
  110. package/lib/testing/index.js +1 -1
  111. package/lib/testing/store-contract.d.ts +8 -1
  112. package/lib/testing/store-contract.js +194 -1
  113. package/lib/verification/confirm.d.ts +3 -3
  114. package/lib/verification/confirm.js +6 -4
  115. package/lib/verification/corpus.d.ts +9 -9
  116. package/lib/verification/gates-at.js +3 -1
  117. package/lib/verification/gates.d.ts +154 -1
  118. package/lib/verification/gates.js +378 -11
  119. package/package.json +1 -1
  120. package/schemas/execution-document.schema.json +130 -0
  121. package/schemas/execution-policy.schema.json +31 -0
  122. package/schemas/handoff-pack.schema.json +146 -4
  123. package/schemas/input-request.schema.json +665 -0
  124. package/schemas/project-facts.schema.json +393 -0
  125. package/schemas/result-envelope.schema.json +1 -0
  126. package/schemas/run-event.schema.json +625 -0
  127. package/schemas/run-result.schema.json +1 -0
  128. package/schemas/stop-diagnosis.schema.json +5 -1
  129. package/schemas/value-report.schema.json +78 -7
@@ -42,6 +42,88 @@ export declare const implementationOutputSchema: {
42
42
  required: string[];
43
43
  };
44
44
  };
45
+ inputRequest: {
46
+ type: string[];
47
+ additionalProperties: boolean;
48
+ properties: {
49
+ question: {
50
+ type: string;
51
+ };
52
+ options: {
53
+ type: string;
54
+ maxItems: 6;
55
+ items: {
56
+ type: string;
57
+ additionalProperties: boolean;
58
+ properties: {
59
+ id: {
60
+ type: string;
61
+ };
62
+ label: {
63
+ type: string;
64
+ };
65
+ consequence: {
66
+ type: string[];
67
+ };
68
+ };
69
+ required: string[];
70
+ };
71
+ };
72
+ recommended: {
73
+ type: string[];
74
+ };
75
+ severity: {
76
+ type: string;
77
+ minimum: number;
78
+ maximum: number;
79
+ };
80
+ rationale: {
81
+ type: string;
82
+ };
83
+ affects: {
84
+ type: string;
85
+ maxItems: 5;
86
+ items: {
87
+ type: string;
88
+ enum: ("acceptance" | "contract" | "product" | "api" | "migration")[];
89
+ };
90
+ };
91
+ };
92
+ required: string[];
93
+ };
94
+ assumptions: {
95
+ type: string;
96
+ maxItems: 20;
97
+ items: {
98
+ type: string;
99
+ additionalProperties: boolean;
100
+ properties: {
101
+ question: {
102
+ type: string;
103
+ };
104
+ chosen: {
105
+ type: string;
106
+ };
107
+ rationale: {
108
+ type: string;
109
+ };
110
+ severity: {
111
+ type: string;
112
+ minimum: number;
113
+ maximum: number;
114
+ };
115
+ affects: {
116
+ type: string;
117
+ maxItems: 5;
118
+ items: {
119
+ type: string;
120
+ enum: ("acceptance" | "contract" | "product" | "api" | "migration")[];
121
+ };
122
+ };
123
+ };
124
+ required: string[];
125
+ };
126
+ };
45
127
  };
46
128
  required: string[];
47
129
  };
@@ -207,7 +289,7 @@ export declare const reviewOutputSchema: {
207
289
  };
208
290
  status: {
209
291
  type: string;
210
- enum: ("open" | "closed" | "withdrawn")[];
292
+ enum: ("closed" | "open" | "withdrawn")[];
211
293
  };
212
294
  basis: {
213
295
  type: string;
@@ -410,7 +492,7 @@ export declare const alreadySatisfiedReviewOutputSchema: {
410
492
  };
411
493
  status: {
412
494
  type: string;
413
- enum: ("open" | "closed" | "withdrawn")[];
495
+ enum: ("closed" | "open" | "withdrawn")[];
414
496
  };
415
497
  basis: {
416
498
  type: string;
@@ -1,4 +1,5 @@
1
1
  import { FINDING_BASIS_PATTERN, FINDING_ID_PATTERN, REVIEW_ITEMS_LIMIT, findingStatuses, } from "../contracts/review.js";
2
+ import { INPUT_LIMITS, INPUT_SEVERITY_MAX, criticalAreas } from "../contracts/input.js";
2
3
  /**
3
4
  * JSON Schema структурированного ответа для CLI runtime. Codex требует
4
5
  * закрытые объекты, где каждое свойство обязательно (необязательность —
@@ -19,6 +20,51 @@ const discovery = {
19
20
  },
20
21
  required: ['kind', 'title', 'path', 'line', 'observation', 'consequence', 'reproduction'],
21
22
  };
23
+ const areas = {
24
+ type: 'array',
25
+ maxItems: criticalAreas.length,
26
+ items: { type: 'string', enum: [...criticalAreas] },
27
+ };
28
+ const severity = { type: 'integer', minimum: 1, maximum: INPUT_SEVERITY_MAX };
29
+ /** Вопрос исполнителя (`inputQuestionSchema`); `null` — вопроса нет. */
30
+ const inputRequest = {
31
+ type: ['object', 'null'],
32
+ additionalProperties: false,
33
+ properties: {
34
+ question: { type: 'string' },
35
+ options: {
36
+ type: 'array',
37
+ maxItems: INPUT_LIMITS.options,
38
+ items: {
39
+ type: 'object',
40
+ additionalProperties: false,
41
+ properties: {
42
+ id: { type: 'string' },
43
+ label: { type: 'string' },
44
+ consequence: { type: ['string', 'null'] },
45
+ },
46
+ required: ['id', 'label', 'consequence'],
47
+ },
48
+ },
49
+ recommended: { type: ['string', 'null'] },
50
+ severity,
51
+ rationale: { type: 'string' },
52
+ affects: areas,
53
+ },
54
+ required: ['question', 'options', 'recommended', 'severity', 'rationale', 'affects'],
55
+ };
56
+ const assumption = {
57
+ type: 'object',
58
+ additionalProperties: false,
59
+ properties: {
60
+ question: { type: 'string' },
61
+ chosen: { type: 'string' },
62
+ rationale: { type: 'string' },
63
+ severity,
64
+ affects: areas,
65
+ },
66
+ required: ['question', 'chosen', 'rationale', 'severity', 'affects'],
67
+ };
22
68
  export const implementationOutputSchema = {
23
69
  type: 'object',
24
70
  additionalProperties: false,
@@ -26,8 +72,10 @@ export const implementationOutputSchema = {
26
72
  completed: { type: 'boolean' },
27
73
  summary: { type: 'string' },
28
74
  discoveries: { type: 'array', maxItems: 20, items: discovery },
75
+ inputRequest,
76
+ assumptions: { type: 'array', maxItems: INPUT_LIMITS.assumptions, items: assumption },
29
77
  },
30
- required: ['completed', 'summary', 'discoveries'],
78
+ required: ['completed', 'summary', 'discoveries', 'inputRequest', 'assumptions'],
31
79
  };
32
80
  export const reviewOutputSchema = {
33
81
  type: 'object',
package/lib/cli.js CHANGED
@@ -4,7 +4,7 @@ import { existsSync, lstatSync, readFileSync, readdirSync, writeFileSync, mkdirS
4
4
  import { basename, dirname, join, resolve } from 'node:path';
5
5
  import { parseArgs } from 'node:util';
6
6
  import { z } from 'zod';
7
- import { API_VERSION, HarnessError, authorSchema, cliCommands, cliDataSchemas, contractViolation, contextSnapshotSchema, contractDocumentSchema, errorCodes, executionPolicySchema, exitCodeOf, exitCodes, } from "./contracts/index.js";
7
+ import { API_VERSION, HarnessError, authorSchema, cliCommands, cliDataSchemas, contractViolation, contextSnapshotSchema, contractDocumentSchema, digestSchema, errorCodes, executionPolicySchema, exitCodeOf, exitCodes, } from "./contracts/index.js";
8
8
  import { HARNESS_VERSION } from "./package.js";
9
9
  import { validateInputs } from "./validate.js";
10
10
  import { Harness } from "./control/harness.js";
@@ -26,6 +26,7 @@ import { collectReportInput } from "./control/report.js";
26
26
  import { writeReportFile } from "./control/report-file.js";
27
27
  import { valueReport, reportHtml, reportMarkdown } from "./report/index.js";
28
28
  import { handoffMarkdown, handoffPack } from "./handoff/index.js";
29
+ import { inputStateOf } from "./projections/input.js";
29
30
  const usage = `harness ${HARNESS_VERSION}
30
31
 
31
32
  Использование: harness <команда> [параметры]
@@ -223,6 +224,16 @@ const options = {
223
224
  format: { type: 'string' },
224
225
  'no-titles': { type: 'boolean' },
225
226
  intent: { type: 'string', multiple: true },
227
+ request: { type: 'string' },
228
+ text: { type: 'string' },
229
+ option: { type: 'string' },
230
+ kind: { type: 'string' },
231
+ actor: { type: 'string' },
232
+ 'request-version': { type: 'string' },
233
+ 'context-digest': { type: 'string' },
234
+ answer: { type: 'string' },
235
+ target: { type: 'string' },
236
+ successor: { type: 'string' },
226
237
  };
227
238
  /** Новые флаги H1 допустимы только у своих команд; прежние команды их не принимают. */
228
239
  const flagOwners = {
@@ -242,6 +253,24 @@ const flagOwners = {
242
253
  format: ['report', 'handoff'],
243
254
  'no-titles': ['report'],
244
255
  intent: ['handoff'],
256
+ request: [
257
+ 'input-show',
258
+ 'input-answer',
259
+ 'input-context',
260
+ 'input-target',
261
+ 'input-apply',
262
+ 'input-cancel',
263
+ 'input-supersede',
264
+ ],
265
+ text: ['input-answer'],
266
+ option: ['input-answer'],
267
+ kind: ['input-answer'],
268
+ actor: ['input-answer'],
269
+ 'request-version': ['input-answer', 'input-apply', 'input-cancel', 'input-supersede'],
270
+ 'context-digest': ['input-target', 'input-apply'],
271
+ answer: ['input-apply'],
272
+ target: ['input-apply'],
273
+ successor: ['input-supersede'],
245
274
  };
246
275
  /** Явное человеческое представление успешного ответа (`--human`). */
247
276
  const presenters = {
@@ -710,6 +739,125 @@ async function run(argv) {
710
739
  : undefined, b && v.state ? { baseDir: b.baseDir } : undefined),
711
740
  };
712
741
  }
742
+ case 'input-list':
743
+ case 'input-show':
744
+ case 'input-target': {
745
+ const h = open(need('state'), binding(need('state')), 'state');
746
+ try {
747
+ if (command === 'input-show')
748
+ return { command, data: h.inputRequest(need('request')) };
749
+ if (command === 'input-target') {
750
+ const { request, target, problems } = h.proposeTarget(need('request'), parseWith(digestSchema, need('context-digest'), 'context-digest'));
751
+ return {
752
+ command,
753
+ data: { requestId: request.id, ...optional('target', target), problems },
754
+ };
755
+ }
756
+ return {
757
+ command,
758
+ data: {
759
+ requests: h.inputRequests(v.work ? { workId: v.work } : {}).map((r) => ({
760
+ id: r.id,
761
+ workId: r.workId,
762
+ kind: r.kind,
763
+ blocking: r.blocking,
764
+ lifecycle: r.lifecycle,
765
+ ...optional('state', inputStateOf(r)),
766
+ severity: r.effectiveSeverity,
767
+ version: r.version,
768
+ answers: r.answers.length,
769
+ createdAt: r.createdAt,
770
+ })),
771
+ },
772
+ };
773
+ }
774
+ finally {
775
+ h.close();
776
+ }
777
+ }
778
+ case 'input-answer':
779
+ case 'input-context':
780
+ case 'input-apply':
781
+ case 'input-cancel':
782
+ case 'input-supersede': {
783
+ const b = binding(need('state'));
784
+ const h = open(need('state'), b, false);
785
+ const version = () => {
786
+ const n = Number(need('request-version'));
787
+ if (!Number.isSafeInteger(n) || n < 1)
788
+ throw new HarnessError('INVALID_INPUT', '--request-version: целое ≥ 1');
789
+ return n;
790
+ };
791
+ try {
792
+ const id = need('request');
793
+ if (command === 'input-answer') {
794
+ const kind = parseWith(z.enum(['clarification', 'requirement-change']), v.kind ?? 'clarification', 'kind');
795
+ const actor = parseWith(z.enum(['operator', 'lead']), v.actor ?? 'operator', 'actor');
796
+ return {
797
+ command,
798
+ data: h.answerInput(id, {
799
+ text: need('text'),
800
+ ...optional('optionId', v.option),
801
+ kind,
802
+ actor: { kind: actor },
803
+ }, version()),
804
+ };
805
+ }
806
+ if (command === 'input-context') {
807
+ const out = resolve(need('out'));
808
+ const { requestId, answerDigest, digest, snapshot } = h.inputContext(id);
809
+ writeFileSync(out, JSON.stringify(snapshot, null, 2) + '\n');
810
+ return { command, data: { requestId, answerDigest, digest, out } };
811
+ }
812
+ if (command === 'input-apply') {
813
+ const result = h.applyInput(id, {
814
+ answerDigest: parseWith(digestSchema, need('answer'), 'answer'),
815
+ expectedVersion: version(),
816
+ contextDigest: parseWith(digestSchema, need('context-digest'), 'context-digest'),
817
+ targetDigest: parseWith(digestSchema, need('target'), 'target'),
818
+ actor: b.policy.approvalMode,
819
+ ...(v.reset ? { reset: { reason: need('reason') } } : {}),
820
+ });
821
+ return {
822
+ command,
823
+ data: {
824
+ requestId: id,
825
+ applied: result.applied,
826
+ changed: result.changed,
827
+ lifecycle: result.request.lifecycle,
828
+ ...('work' in result && result.work
829
+ ? {
830
+ work: {
831
+ id: result.work.id,
832
+ status: result.work.status,
833
+ attempt: result.work.attempt,
834
+ },
835
+ }
836
+ : {}),
837
+ ...('active' in result && result.active ? { active: result.active } : {}),
838
+ ...('joint' in result && result.joint ? { joint: true } : {}),
839
+ ...('blocker' in result && result.blocker ? { blocker: result.blocker } : {}),
840
+ },
841
+ ...(result.applied ? {} : { code: exitCodes.refused }),
842
+ };
843
+ }
844
+ const closed = command === 'input-cancel'
845
+ ? h.cancelInput(id, { by: 'operator', reason: need('reason') }, version())
846
+ : h.supersedeInput(id, { by: 'operator', reason: need('reason'), successor: need('successor') }, version());
847
+ return {
848
+ command,
849
+ data: {
850
+ requestId: id,
851
+ lifecycle: closed.request.lifecycle,
852
+ version: closed.request.version,
853
+ changed: closed.changed,
854
+ },
855
+ };
856
+ }
857
+ finally {
858
+ h.close();
859
+ }
860
+ }
713
861
  }
714
862
  }
715
863
  const argv = process.argv.slice(2);