devcontour-harness 0.1.0-alpha.25 → 0.1.0-alpha.26

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 (43) hide show
  1. package/README.md +9 -2
  2. package/docs/compatibility.md +2 -0
  3. package/docs/connectors.md +69 -3
  4. package/docs/contracts.md +15 -1
  5. package/docs/release-notes/0.1.0-alpha.26.md +35 -0
  6. package/docs/review-protocol.md +9 -1
  7. package/lib/agents/cli-adapter.d.ts +6 -0
  8. package/lib/agents/cli-adapter.js +12 -2
  9. package/lib/agents/review-probe.d.ts +5 -0
  10. package/lib/agents/review-probe.js +29 -9
  11. package/lib/agents/schemas.d.ts +4 -0
  12. package/lib/agents/schemas.js +3 -1
  13. package/lib/cli.js +9 -5
  14. package/lib/contracts/cli.d.ts +60 -1
  15. package/lib/contracts/cli.js +36 -2
  16. package/lib/contracts/failure.js +1 -1
  17. package/lib/contracts/review.d.ts +69 -0
  18. package/lib/contracts/review.js +29 -14
  19. package/lib/contracts/work.d.ts +6 -0
  20. package/lib/contracts/work.js +13 -12
  21. package/lib/control/review.js +9 -2
  22. package/lib/engine/runner.js +7 -3
  23. package/lib/environment/bounded-read.d.ts +12 -0
  24. package/lib/environment/bounded-read.js +40 -0
  25. package/lib/integrations/connector/commands.d.ts +35 -7
  26. package/lib/integrations/connector/commands.js +52 -7
  27. package/lib/integrations/connector/config.d.ts +37 -0
  28. package/lib/integrations/connector/config.js +37 -5
  29. package/lib/integrations/connector/delivery.js +17 -1
  30. package/lib/integrations/connector/index.d.ts +2 -2
  31. package/lib/integrations/connector/index.js +1 -1
  32. package/lib/integrations/connector/snapshot.d.ts +10 -8
  33. package/lib/integrations/connector/snapshot.js +78 -8
  34. package/lib/integrations/connector/source.d.ts +8 -2
  35. package/lib/integrations/connector/source.js +32 -6
  36. package/lib/integrations/connector/summary.d.ts +6 -0
  37. package/lib/integrations/connector/summary.js +5 -0
  38. package/lib/integrations/connector/testing.js +18 -0
  39. package/lib/integrations/relay-v1/index.js +6 -4
  40. package/lib/integrations/relay-v2/protocol.js +8 -6
  41. package/lib/verification/confirm.js +10 -2
  42. package/lib/verification/gates.js +24 -7
  43. package/package.json +2 -2
@@ -1,9 +1,10 @@
1
1
  import { execFileSync } from 'node:child_process';
2
- import { mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises';
2
+ import { mkdir, mkdtemp, realpath, rm, writeFile } from 'node:fs/promises';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { z } from 'zod';
6
6
  import { HarnessError, idSchema, } from "../contracts/index.js";
7
+ import { OversizedFile, readBounded } from "../environment/bounded-read.js";
7
8
  import { executionEnvironment, runSteps, withEnvironment } from "../environment/lifecycle.js";
8
9
  import { git, hostGitArgs } from "../environment/process.js";
9
10
  import { contractDocuments, obligationOf } from "./checks.js";
@@ -57,6 +58,8 @@ export const caseInputSchema = z.strictObject({
57
58
  });
58
59
  /** Точка после записи версии и до принятия: тест моделирует в ней сбой. */
59
60
  export const caseHooks = { afterRecord: () => undefined };
61
+ /** Файл результата пишет проверяемый код; случай корпуса — не больше 64 КиБ. */
62
+ const CASE_RESULT_LIMIT = 1024 * 1024;
60
63
  const caseResult = z.object({
61
64
  property: z.string(),
62
65
  valid: z.boolean().optional(),
@@ -323,7 +326,12 @@ async function decide(ctx, work, ref, input, source) {
323
326
  runs.push({ property: input.property, error: 'timeout' });
324
327
  break;
325
328
  }
326
- const parsed = caseResult.safeParse(JSON.parse(await readFile(out, 'utf8').catch(() => 'null')));
329
+ const raw = await readBounded(out, CASE_RESULT_LIMIT).catch((error) => {
330
+ if (error instanceof OversizedFile)
331
+ throw error;
332
+ return 'null';
333
+ });
334
+ const parsed = caseResult.safeParse(JSON.parse(raw));
327
335
  runs.push(parsed.success ? parsed.data : { property: input.property, error: 'нет результата' });
328
336
  }
329
337
  });
@@ -145,6 +145,9 @@ export function junitSummary(xml, redact = (value) => value) {
145
145
  throw new Error('JUnit не содержит выполненных testcases');
146
146
  return summary;
147
147
  }
148
+ const ansiEscape = /\u001b\[[0-9;?]*[ -/]*[@-~]/g;
149
+ /** Путь с расширением и координаты, после необязательного префикса `пакет скрипт: `. */
150
+ const compilerError = /^(?:\S+(?: \S+)?: )?[^\s:]+?\.[A-Za-z][A-Za-z0-9]{0,9}(?:\(\d+,\d+\): |:\d+(?::\d+)?(?:: | - ))(?:fatal )?error(?: [A-Z]+\d+)?:/;
148
151
  /**
149
152
  * Короткая выжимка вывода провалившейся проверки.
150
153
  *
@@ -152,7 +155,8 @@ export function junitSummary(xml, redact = (value) => value) {
152
155
  * доступен, а в отказ попадал только «Код выхода 1». Два разных провала одной
153
156
  * проверки выглядели одной причиной — предел одинаковых повторов исчерпывался
154
157
  * на несвязанных ошибках, и подсказка повтора не содержала ничего, кроме кода
155
- * возврата. Берутся последние содержательные строки обоих потоков: ошибку
158
+ * возврата. Берутся последние содержательные строки обоих потоков и первая
159
+ * ошибка компилятора с координатами перед ними: ошибку
156
160
  * одни инструменты пишут в stdout, другие в stderr, и одинаковое
157
161
  * предупреждение в одном потоке не должно закрывать ошибку в другом. Секреты
158
162
  * снимаются тем же redact, что и в логе; объём ограничен.
@@ -161,15 +165,28 @@ function diagnostic(stderr, stdout, redact) {
161
165
  // У каждого потока свой бюджет: общий лимит, заполняемый по очереди,
162
166
  // позволял нескольким длинным строкам одного потока вытеснить ошибку
163
167
  // другого. Redact — до обрезки, иначе префикс секрета остаётся.
168
+ const clip = (line) => (line.length > 140 ? line.slice(0, 140) + '…' : line);
164
169
  const tail = (text) => {
165
- const joined = text
170
+ const lines = text
166
171
  .split('\n')
167
172
  .map((line) => (redact ? redact(line) : line).trim())
168
- .filter(Boolean)
169
- .slice(-4)
170
- .map((line) => (line.length > 140 ? line.slice(0, 140) + '…' : line))
171
- .join(' | ');
172
- return joined.length > 290 ? '…' + joined.slice(-290) : joined;
173
+ .filter(Boolean);
174
+ const last = lines.slice(-4);
175
+ const joined = last.map(clip).join(' | ');
176
+ const ending = joined.length > 290 ? '…' + joined.slice(-290) : joined;
177
+ // Компилятор печатает причину раньше итогов package manager, и хвост её
178
+ // вытесняет. Первая ошибка дописывается к хвосту, а не заменяет его: отпечаток
179
+ // отказа различает провалы по хвосту, а распознавание по строке — эвристика.
180
+ // Цвет снимается до redact, иначе обрезка оставит склеенный им префикс секрета.
181
+ // Проверяется обрезанная строка: это ограничивает разбор и гарантирует, что
182
+ // найденное попадёт в итог.
183
+ const cause = text
184
+ .split('\n')
185
+ .map((line) => line.replace(ansiEscape, ''))
186
+ .map((line) => clip((redact ? redact(line) : line).trim()))
187
+ .find((line) => compilerError.test(line));
188
+ const visible = cause && ending.replace(ansiEscape, '').includes(cause.replace(/…$/, ''));
189
+ return cause && !visible ? cause + ' | ' + ending : ending;
173
190
  };
174
191
  return [tail(stdout), tail(stderr)].filter(Boolean).join(' | ');
175
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devcontour-harness",
3
- "version": "0.1.0-alpha.25",
3
+ "version": "0.1.0-alpha.26",
4
4
  "description": "Headless execution harness: work graph, isolated attempts, gates, independent reviews and accepted results.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -95,7 +95,7 @@
95
95
  "dependencies": {
96
96
  "@anthropic-ai/sandbox-runtime": "0.0.77",
97
97
  "fast-xml-parser": "5.11.1",
98
- "zod": "4.6.5"
98
+ "zod": "4.6.7"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@types/node": "24.13.5",