devcontour-harness 0.1.0-alpha.18 → 0.1.0-alpha.20

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 (56) hide show
  1. package/README.md +20 -2
  2. package/docs/architecture.md +48 -0
  3. package/docs/contracts.md +3 -0
  4. package/docs/quickstart.md +1 -1
  5. package/docs/release-notes/0.1.0-alpha.19.md +96 -0
  6. package/docs/release-notes/0.1.0-alpha.20.md +42 -0
  7. package/docs/upgrade.md +17 -16
  8. package/lib/agents/review-probe.js +2 -1
  9. package/lib/cli.js +7 -1
  10. package/lib/contracts/cli.d.ts +30 -2
  11. package/lib/contracts/events.d.ts +21 -0
  12. package/lib/contracts/events.js +7 -0
  13. package/lib/contracts/execution.d.ts +24 -3
  14. package/lib/contracts/execution.js +14 -2
  15. package/lib/contracts/planning.js +2 -2
  16. package/lib/contracts/policy.d.ts +1 -1
  17. package/lib/contracts/ports.d.ts +6 -0
  18. package/lib/contracts/primitives.d.ts +13 -0
  19. package/lib/contracts/primitives.js +15 -0
  20. package/lib/contracts/profiles.js +2 -2
  21. package/lib/contracts/published.d.ts +23 -2
  22. package/lib/contracts/review.d.ts +2 -2
  23. package/lib/contracts/review.js +2 -2
  24. package/lib/contracts/work.js +3 -3
  25. package/lib/control/base-move.js +2 -2
  26. package/lib/control/harness.d.ts +1 -1
  27. package/lib/control/harness.js +7 -2
  28. package/lib/control/workflow.js +6 -0
  29. package/lib/engine/budget.d.ts +1 -1
  30. package/lib/engine/engine.d.ts +14 -2
  31. package/lib/engine/engine.js +40 -1
  32. package/lib/engine/runner.d.ts +11 -1
  33. package/lib/engine/runner.js +82 -11
  34. package/lib/environment/git-trust.d.ts +36 -0
  35. package/lib/environment/git-trust.js +174 -0
  36. package/lib/environment/isolation.d.ts +103 -1
  37. package/lib/environment/isolation.js +340 -5
  38. package/lib/environment/live-calls.js +3 -2
  39. package/lib/environment/os-tools.d.ts +15 -0
  40. package/lib/environment/os-tools.js +35 -0
  41. package/lib/environment/process.d.ts +5 -0
  42. package/lib/environment/process.js +43 -6
  43. package/lib/index.d.ts +2 -0
  44. package/lib/index.js +4 -0
  45. package/lib/integrations/connector/config.js +2 -2
  46. package/lib/storage/document.d.ts +10 -2
  47. package/lib/verification/confirm.js +2 -2
  48. package/lib/verification/gates.d.ts +12 -1
  49. package/lib/verification/gates.js +81 -8
  50. package/lib/verification/requirements.js +6 -1
  51. package/package.json +1 -1
  52. package/schemas/execution-document.schema.json +27 -5
  53. package/schemas/plan-draft.schema.json +2 -2
  54. package/schemas/run-event.schema.json +22 -0
  55. package/schemas/work-graph.schema.json +2 -2
  56. package/schemas/work-order.schema.json +2 -2
@@ -276,6 +276,13 @@ export declare const evidenceRecordSchema: z.ZodObject<{
276
276
  digest: z.ZodString;
277
277
  summary: z.ZodString;
278
278
  consumer: z.ZodOptional<z.ZodString>;
279
+ recheck: z.ZodOptional<z.ZodObject<{
280
+ of: z.ZodString;
281
+ outcome: z.ZodEnum<{
282
+ flaky: "flaky";
283
+ confirmed: "confirmed";
284
+ }>;
285
+ }, z.core.$strict>>;
279
286
  inspection: z.ZodOptional<z.ZodObject<{
280
287
  mode: z.ZodEnum<{
281
288
  commands: "commands";
@@ -367,9 +374,9 @@ export declare const evidenceRecordSchema: z.ZodObject<{
367
374
  issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
368
375
  path: z.ZodString;
369
376
  reason: z.ZodEnum<{
377
+ schema: "schema";
370
378
  unknown: "unknown";
371
379
  missing: "missing";
372
- schema: "schema";
373
380
  duplicate: "duplicate";
374
381
  "not-open": "not-open";
375
382
  "approved-with-blocking": "approved-with-blocking";
@@ -837,6 +844,13 @@ export declare const attemptStateSchema: z.ZodObject<{
837
844
  digest: z.ZodString;
838
845
  summary: z.ZodString;
839
846
  consumer: z.ZodOptional<z.ZodString>;
847
+ recheck: z.ZodOptional<z.ZodObject<{
848
+ of: z.ZodString;
849
+ outcome: z.ZodEnum<{
850
+ flaky: "flaky";
851
+ confirmed: "confirmed";
852
+ }>;
853
+ }, z.core.$strict>>;
840
854
  inspection: z.ZodOptional<z.ZodObject<{
841
855
  mode: z.ZodEnum<{
842
856
  commands: "commands";
@@ -928,9 +942,9 @@ export declare const attemptStateSchema: z.ZodObject<{
928
942
  issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
929
943
  path: z.ZodString;
930
944
  reason: z.ZodEnum<{
945
+ schema: "schema";
931
946
  unknown: "unknown";
932
947
  missing: "missing";
933
- schema: "schema";
934
948
  duplicate: "duplicate";
935
949
  "not-open": "not-open";
936
950
  "approved-with-blocking": "approved-with-blocking";
@@ -3131,6 +3145,13 @@ export declare const executionDocumentSchema: z.ZodObject<{
3131
3145
  digest: z.ZodString;
3132
3146
  summary: z.ZodString;
3133
3147
  consumer: z.ZodOptional<z.ZodString>;
3148
+ recheck: z.ZodOptional<z.ZodObject<{
3149
+ of: z.ZodString;
3150
+ outcome: z.ZodEnum<{
3151
+ flaky: "flaky";
3152
+ confirmed: "confirmed";
3153
+ }>;
3154
+ }, z.core.$strict>>;
3134
3155
  inspection: z.ZodOptional<z.ZodObject<{
3135
3156
  mode: z.ZodEnum<{
3136
3157
  commands: "commands";
@@ -3222,9 +3243,9 @@ export declare const executionDocumentSchema: z.ZodObject<{
3222
3243
  issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
3223
3244
  path: z.ZodString;
3224
3245
  reason: z.ZodEnum<{
3246
+ schema: "schema";
3225
3247
  unknown: "unknown";
3226
3248
  missing: "missing";
3227
- schema: "schema";
3228
3249
  duplicate: "duplicate";
3229
3250
  "not-open": "not-open";
3230
3251
  "approved-with-blocking": "approved-with-blocking";
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { STATE_VERSION } from "./version.js";
3
- import { digestSchema, gitShaSchema, idSchema, isoTimeSchema, relativePathSchema, runtimeNameSchema, trimmedText, } from "./primitives.js";
3
+ import { digestSchema, gitShaSchema, idSchema, isoTimeSchema, relativePathSchema, runtimeNameSchema, trimmedText, gateScopeSchema, } from "./primitives.js";
4
4
  import { workGraphSchema, workOrderSchema } from "./work.js";
5
5
  import { contextPinSchema, contextSnapshotSchema } from "./context.js";
6
6
  import { deliveryStateSchema, jointActiveSchema, jointFailedSchema, jointPassedSchema, } from "./result.js";
@@ -241,6 +241,17 @@ export const evidenceRecordSchema = z.strictObject({
241
241
  summary: z.string(),
242
242
  /** Проверка потребителя: компонент, в дереве которого она выполнена. */
243
243
  consumer: idSchema.optional(),
244
+ /**
245
+ * Повтор провала gate интеграции на том же SHA: `of` — ID повторённой
246
+ * записи; `flaky` — повтор прошёл (первый провал вызван средой), `confirmed`
247
+ * — провал подтвердился.
248
+ */
249
+ recheck: z
250
+ .strictObject({
251
+ of: z.string().min(1).max(200),
252
+ outcome: z.enum(['flaky', 'confirmed']),
253
+ })
254
+ .optional(),
244
255
  inspection: reviewInspectionSchema.optional(),
245
256
  findings: z.array(evidenceFindingSchema).optional(),
246
257
  /** Раунд ревью кода: область истории, вызов, протокол, переходы (docs/review-protocol.md). */
@@ -262,7 +273,7 @@ export const evidenceRecordSchema = z.strictObject({
262
273
  */
263
274
  alreadySatisfied: z
264
275
  .strictObject({
265
- gates: z.array(z.string().min(1).max(200)).min(1).max(20),
276
+ gates: gateScopeSchema(z.string().min(1).max(200)).min(1),
266
277
  evidence: z.string().min(1).max(4000),
267
278
  /** Механическое основание, найденное controller (`alreadySatisfiedVerdict`). */
268
279
  basis: z
@@ -875,6 +886,7 @@ export const workflowJobSchema = z.strictObject({
875
886
  owner: z.string().optional(),
876
887
  inputDigest: digestSchema,
877
888
  stage: z.number().int().min(0),
889
+ /** Попытки текущей стадии; у завершённого задания — все израсходованные попытки стадий. */
878
890
  attempts: z.number().int().min(0),
879
891
  status: z.enum(['queued', 'running', 'failed', 'stale', 'completed']),
880
892
  repairs: z.number().int().min(0).optional(),
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { errorCodes, HarnessError } from "./errors.js";
3
- import { digestSchema, gateRefSchema, idSchema, relativePathPattern, roleIdSchema, } from "./primitives.js";
3
+ import { digestSchema, gateRefSchema, idSchema, relativePathPattern, roleIdSchema, gateScopeSchema, } from "./primitives.js";
4
4
  import { consumerSchema, propertyIdSchema, workGraphSchema } from "./work.js";
5
5
  /**
6
6
  * Draft плана: то, что ведущий агент (или хост) предлагает до проверки и
@@ -35,7 +35,7 @@ export const planDraftTaskShape = {
35
35
  relatedRepositories: z.array(idSchema).optional(),
36
36
  contextPacks: z.array(idSchema).max(30).optional(),
37
37
  writePaths: z.array(draftPathSchema).min(1).max(100).optional(),
38
- gates: z.array(gateRefSchema).max(20).optional(),
38
+ gates: gateScopeSchema(gateRefSchema).optional(),
39
39
  properties: z.array(propertyIdSchema).max(30).optional(),
40
40
  resources: z.array(idSchema).max(20).optional(),
41
41
  repositoryId: z.string().default('main'),
@@ -986,8 +986,8 @@ export declare const executionPolicySchema: z.ZodObject<{
986
986
  timeMs: z.ZodNumber;
987
987
  }, z.core.$strict>]>>;
988
988
  onUnknown: z.ZodDefault<z.ZodEnum<{
989
- stop: "stop";
990
989
  continue: "continue";
990
+ stop: "stop";
991
991
  }>>;
992
992
  }, z.core.$strict>>;
993
993
  prices: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -16,6 +16,12 @@ export interface ExecutionView {
16
16
  works(graphId?: string): WorkState[];
17
17
  attempt(id: string): AttemptState | undefined;
18
18
  attempts(workId?: string): AttemptState[];
19
+ /**
20
+ * Только активные попытки. Необязательный быстрый путь: такт очереди ищет
21
+ * истёкшие среди активных, и адаптеру с длинной историей не нужно строить
22
+ * все прежние попытки. Без метода — `attempts()` с фильтром по статусу.
23
+ */
24
+ activeAttempts?(): AttemptState[];
19
25
  verification(id: string): JointVerificationState | undefined;
20
26
  verifications(): JointVerificationState[];
21
27
  /**
@@ -3,6 +3,19 @@ import { z } from 'zod';
3
3
  export declare const idSchema: z.ZodString;
4
4
  /** Ссылка на gate или на именованную группу gates (`@имя`). */
5
5
  export declare const gateRefSchema: z.ZodString;
6
+ /**
7
+ * Предел ссылок на gates в одной области (задача, поручение, потребитель,
8
+ * основание ревью). Он равен пределу gates профиля стека: область задачи
9
+ * может назвать весь профиль, и включение каждого gate в задачу выполнимо
10
+ * одной задачей.
11
+ */
12
+ export declare const GATE_SCOPE_LIMIT = 100;
13
+ /** Превышение предела области gates — понятный отказ с величиной и исправлением. */
14
+ export declare const gateScopeTooBig: (issue: {
15
+ input?: unknown;
16
+ }) => string;
17
+ /** Ссылки на gates одной области: не больше `GATE_SCOPE_LIMIT`. */
18
+ export declare const gateScopeSchema: <T extends z.ZodType<string>>(item: T) => z.ZodArray<T>;
6
19
  export declare const roleIdSchema: z.ZodString;
7
20
  /** Полный SHA объекта Git (SHA-1 или SHA-256). */
8
21
  export declare const gitShaSchema: z.ZodString;
@@ -5,6 +5,21 @@ export const idSchema = z
5
5
  .regex(/^[A-Za-z0-9_-]{1,80}$/, 'Ожидается ID [A-Za-z0-9_-]{1,80}');
6
6
  /** Ссылка на gate или на именованную группу gates (`@имя`). */
7
7
  export const gateRefSchema = z.string().regex(/^@?[A-Za-z0-9_-]{1,80}$/);
8
+ /**
9
+ * Предел ссылок на gates в одной области (задача, поручение, потребитель,
10
+ * основание ревью). Он равен пределу gates профиля стека: область задачи
11
+ * может назвать весь профиль, и включение каждого gate в задачу выполнимо
12
+ * одной задачей.
13
+ */
14
+ export const GATE_SCOPE_LIMIT = 100;
15
+ /** Превышение предела области gates — понятный отказ с величиной и исправлением. */
16
+ export const gateScopeTooBig = (issue) => {
17
+ const actual = Array.isArray(issue.input) ? issue.input.length : GATE_SCOPE_LIMIT + 1;
18
+ return (`область gates: ${actual} при пределе ${GATE_SCOPE_LIMIT}, лишних ${actual - GATE_SCOPE_LIMIT}. ` +
19
+ 'Назовите группу gates (@имя) или уберите повторы');
20
+ };
21
+ /** Ссылки на gates одной области: не больше `GATE_SCOPE_LIMIT`. */
22
+ export const gateScopeSchema = (item) => z.array(item).max(GATE_SCOPE_LIMIT, { error: gateScopeTooBig });
8
23
  export const roleIdSchema = z
9
24
  .string()
10
25
  .regex(/^[a-z][a-z0-9-]{1,30}$/, 'Идентификатор роли: строчные латинские буквы, цифры и дефис');
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { idSchema, relativePathSchema, roleIdSchema } from "./primitives.js";
2
+ import { GATE_SCOPE_LIMIT, idSchema, relativePathSchema, roleIdSchema } from "./primitives.js";
3
3
  import { environmentSchema, gateSchema, lifecycleSchema, stepSchema } from "./policy.js";
4
4
  import { toolchainSchema } from "./toolchain.js";
5
5
  /**
@@ -62,7 +62,7 @@ export const stackProfileSchema = z.strictObject({
62
62
  /** Встроенный ID или относительный `./file.json` внутри репозитория. */
63
63
  extends: z.array(z.string().min(1)).max(PROFILE_DEPTH_LIMIT).default([]),
64
64
  capabilities: z.array(z.string().min(1).max(100)).max(100).default([]),
65
- gates: z.array(profileGateSchema).max(100).default([]),
65
+ gates: z.array(profileGateSchema).max(GATE_SCOPE_LIMIT).default([]),
66
66
  prepare: z.array(stepSchema).max(100).default([]),
67
67
  environment: environmentSchema.optional(),
68
68
  lifecycle: lifecycleSchema.optional(),
@@ -628,8 +628,8 @@ export declare const publishedSchemas: {
628
628
  timeMs: z.ZodNumber;
629
629
  }, z.core.$strict>]>>;
630
630
  onUnknown: z.ZodDefault<z.ZodEnum<{
631
- stop: "stop";
632
631
  continue: "continue";
632
+ stop: "stop";
633
633
  }>>;
634
634
  }, z.core.$strict>>;
635
635
  prices: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -1700,6 +1700,13 @@ export declare const publishedSchemas: {
1700
1700
  passed: z.ZodBoolean;
1701
1701
  evidenceId: z.ZodString;
1702
1702
  consumer: z.ZodOptional<z.ZodString>;
1703
+ recheck: z.ZodOptional<z.ZodObject<{
1704
+ of: z.ZodString;
1705
+ outcome: z.ZodEnum<{
1706
+ flaky: "flaky";
1707
+ confirmed: "confirmed";
1708
+ }>;
1709
+ }, z.core.$strict>>;
1703
1710
  }, z.core.$strict> | z.ZodObject<{
1704
1711
  phase: z.ZodEnum<{
1705
1712
  candidate: "candidate";
@@ -1955,6 +1962,13 @@ export declare const publishedSchemas: {
1955
1962
  passed: z.ZodBoolean;
1956
1963
  evidenceId: z.ZodString;
1957
1964
  consumer: z.ZodOptional<z.ZodString>;
1965
+ recheck: z.ZodOptional<z.ZodObject<{
1966
+ of: z.ZodString;
1967
+ outcome: z.ZodEnum<{
1968
+ flaky: "flaky";
1969
+ confirmed: "confirmed";
1970
+ }>;
1971
+ }, z.core.$strict>>;
1958
1972
  }, z.core.$strict> | z.ZodObject<{
1959
1973
  phase: z.ZodEnum<{
1960
1974
  candidate: "candidate";
@@ -2857,6 +2871,13 @@ export declare const publishedSchemas: {
2857
2871
  digest: z.ZodString;
2858
2872
  summary: z.ZodString;
2859
2873
  consumer: z.ZodOptional<z.ZodString>;
2874
+ recheck: z.ZodOptional<z.ZodObject<{
2875
+ of: z.ZodString;
2876
+ outcome: z.ZodEnum<{
2877
+ flaky: "flaky";
2878
+ confirmed: "confirmed";
2879
+ }>;
2880
+ }, z.core.$strict>>;
2860
2881
  inspection: z.ZodOptional<z.ZodObject<{
2861
2882
  mode: z.ZodEnum<{
2862
2883
  commands: "commands";
@@ -2948,9 +2969,9 @@ export declare const publishedSchemas: {
2948
2969
  issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
2949
2970
  path: z.ZodString;
2950
2971
  reason: z.ZodEnum<{
2972
+ schema: "schema";
2951
2973
  unknown: "unknown";
2952
2974
  missing: "missing";
2953
- schema: "schema";
2954
2975
  duplicate: "duplicate";
2955
2976
  "not-open": "not-open";
2956
2977
  "approved-with-blocking": "approved-with-blocking";
@@ -239,9 +239,9 @@ export type ProtocolIssueReason = (typeof protocolIssueReasons)[number];
239
239
  export declare const protocolIssueSchema: z.ZodObject<{
240
240
  path: z.ZodString;
241
241
  reason: z.ZodEnum<{
242
+ schema: "schema";
242
243
  unknown: "unknown";
243
244
  missing: "missing";
244
- schema: "schema";
245
245
  duplicate: "duplicate";
246
246
  "not-open": "not-open";
247
247
  "approved-with-blocking": "approved-with-blocking";
@@ -269,9 +269,9 @@ export declare const reviewRoundSchema: z.ZodObject<{
269
269
  issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
270
270
  path: z.ZodString;
271
271
  reason: z.ZodEnum<{
272
+ schema: "schema";
272
273
  unknown: "unknown";
273
274
  missing: "missing";
274
- schema: "schema";
275
275
  duplicate: "duplicate";
276
276
  "not-open": "not-open";
277
277
  "approved-with-blocking": "approved-with-blocking";
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { authorSchema, digestSchema, idSchema, isoTimeSchema, relativePathSchema, runtimeNameSchema, } from "./primitives.js";
2
+ import { authorSchema, digestSchema, idSchema, isoTimeSchema, relativePathSchema, runtimeNameSchema, gateScopeSchema, } from "./primitives.js";
3
3
  import { digestOf } from "./digest.js";
4
4
  /**
5
5
  * Ответы исполнителей. Runtime возвращает сырой текст/JSON (`RuntimeResponse.output`
@@ -71,7 +71,7 @@ export const findingTransitionSchema = z.strictObject({
71
71
  */
72
72
  /** Основание «приёмка уже выполнена»: названные gates и что их evidence показывает. */
73
73
  export const alreadySatisfiedSchema = z.strictObject({
74
- gates: z.array(z.string().min(1).max(200)).min(1).max(20),
74
+ gates: gateScopeSchema(z.string().min(1).max(200)).min(1),
75
75
  evidence: z.string().min(1).max(4000),
76
76
  });
77
77
  export const reviewResultSchema = z.object({
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { API_VERSION } from "./version.js";
3
- import { digestSchema, gateRefSchema, gitShaSchema, idSchema, relativePathSchema, roleIdSchema, trimmedText, } from "./primitives.js";
3
+ import { digestSchema, gateRefSchema, gitShaSchema, idSchema, relativePathSchema, roleIdSchema, trimmedText, gateScopeSchema, } from "./primitives.js";
4
4
  import { digestOf } from "./digest.js";
5
5
  /**
6
6
  * Откуда пришло поручение: коннектор, ключ записи в нём и её редакция.
@@ -31,7 +31,7 @@ export const contractRefSchema = z.strictObject({ id: idSchema, digest: digestSc
31
31
  /** Проверка потребителя: компонент и его gates против integration результата. */
32
32
  export const consumerSchema = z.strictObject({
33
33
  repositoryId: idSchema,
34
- gates: z.array(gateRefSchema).min(1).max(20),
34
+ gates: gateScopeSchema(gateRefSchema).min(1),
35
35
  });
36
36
  /**
37
37
  * Исполняемое поручение. Это снимок постановки, а не редактируемая задача:
@@ -63,7 +63,7 @@ export const workOrderSchema = z.strictObject({
63
63
  }),
64
64
  dependsOn: z.array(idSchema).max(100).default([]),
65
65
  /** Область доказательства: подмножество gates/групп политики. Нет поля — все gates репозитория. */
66
- gates: z.array(gateRefSchema).max(20).optional(),
66
+ gates: gateScopeSchema(gateRefSchema).optional(),
67
67
  consumers: z.array(consumerSchema).max(10).optional(),
68
68
  /** Свойства договора проверки, которые поручение подтверждает сейчас. */
69
69
  properties: z.array(propertyIdSchema).max(30).optional(),
@@ -1,6 +1,6 @@
1
1
  import { execFileSync } from 'node:child_process';
2
2
  import { isAbsolute, join, resolve } from 'node:path';
3
- import { git } from "../environment/process.js";
3
+ import { git, hostGitArgs } from "../environment/process.js";
4
4
  /**
5
5
  * Сдвиг ref внутри транзакции проверки владения операцией: проверка и
6
6
  * `git update-ref` неразделимы — отмена или перехват операции либо видны
@@ -11,7 +11,7 @@ import { git } from "../environment/process.js";
11
11
  export function fencedRefMove(store, fence, timeoutMs = fencedRefMove.timeoutMs) {
12
12
  return (repoPath, target, to, from) => store.transact('base.moved', (tx) => {
13
13
  fence(tx);
14
- execFileSync('git', ['-c', 'core.hooksPath=/dev/null', 'update-ref', target, to, from], {
14
+ execFileSync('git', hostGitArgs(repoPath, ['update-ref', target, to, from]), {
15
15
  cwd: repoPath,
16
16
  timeout: timeoutMs,
17
17
  stdio: 'pipe',
@@ -681,7 +681,7 @@ export declare class Harness {
681
681
  private repair;
682
682
  status(graphId?: string): {
683
683
  budgets: {
684
- onUnknown: "stop" | "continue";
684
+ onUnknown: "continue" | "stop";
685
685
  budgets: {
686
686
  reason?: string | undefined;
687
687
  scope: import("../engine/budget.ts").BudgetScope;
@@ -16,7 +16,7 @@ import { WorkflowQueue } from "./workflow.js";
16
16
  import { technicalReview } from "./review.js";
17
17
  import { policySourceChanged } from "./provenance.js";
18
18
  import { JointRunner } from "../engine/joint-runner.js";
19
- import { git } from "../environment/process.js";
19
+ import { git, hostGitArgs } from "../environment/process.js";
20
20
  import { analyzeRecovery, applyCases } from "./recovery.js";
21
21
  import { declarationProblems, referenceNote } from "../verification/checks.js";
22
22
  import { spikeOf, spikesOf } from "../verification/spike.js";
@@ -341,7 +341,12 @@ export class Harness {
341
341
  return false;
342
342
  try {
343
343
  // Синхронная проверка: предпосылка доступна в целевой ветке.
344
- execFileSync('git', ['merge-base', '--is-ancestor', p.resultSha, repo.targetRef], {
344
+ execFileSync('git', hostGitArgs(this.repoPath(repo.path), [
345
+ 'merge-base',
346
+ '--is-ancestor',
347
+ p.resultSha,
348
+ repo.targetRef,
349
+ ]), {
345
350
  cwd: this.repoPath(repo.path),
346
351
  stdio: 'ignore',
347
352
  });
@@ -217,6 +217,12 @@ export class WorkflowQueue {
217
217
  next.status = next.stage >= stages ? 'completed' : 'queued';
218
218
  if (next.status === 'completed')
219
219
  next.finishedAt = iso(this.now());
220
+ // Счётчик попыток — бюджет текущей стадии, и следующая стадия начинает
221
+ // его с нуля. У завершённого задания следующей стадии нет: счётчик
222
+ // показывает, сколько попыток стадий задание израсходовало всего (захваты
223
+ // `running` в истории; захват стадии, ответившей «жду», из неё снят).
224
+ if (next.status === 'completed')
225
+ next.attempts = next.history.filter((h) => h.event === 'running').length;
220
226
  delete next.token;
221
227
  delete next.leaseUntil;
222
228
  delete next.error;
@@ -322,7 +322,7 @@ export declare function budgetView(b: BudgetStatus): {
322
322
  };
323
323
  /** Бюджеты установки: общий, группы с незавершённой работой, незавершённые поручения. */
324
324
  export declare function budgetOverview(c: BudgetContext, view: ExecutionView, records?: CallRecord[]): {
325
- onUnknown: "stop" | "continue";
325
+ onUnknown: "continue" | "stop";
326
326
  budgets: {
327
327
  reason?: string | undefined;
328
328
  scope: BudgetScope;
@@ -34,6 +34,14 @@ export interface EngineOptions {
34
34
  export type Phase = 'running' | 'verifying' | 'reviewing' | 'integrating';
35
35
  /** Поручение исчерпало предел незасчитанных отказов: повтор — только со сбросом. */
36
36
  export declare const neutralExhausted: (w: Pick<WorkState, "neutralFailures">) => boolean;
37
+ /**
38
+ * Провал, названный свойством или случаем корпуса, — найденный контрпример, а
39
+ * не сбой среды: генеративная проверка недетерминирована, и удачный повтор
40
+ * не отменяет найденного входа. Такой провал не повторяется.
41
+ */
42
+ export declare function namesFailingCases(e: Pick<EvidenceRecord, 'property'>): boolean;
43
+ /** Активные попытки снимка: быстрый путь адаптера или фильтр всех. */
44
+ export declare function activeOf(v: ExecutionView): AttemptState[];
37
45
  export declare class Engine {
38
46
  readonly host: ExecutionHost;
39
47
  readonly policy: ExecutionPolicy;
@@ -372,7 +380,7 @@ export declare class Engine {
372
380
  pinLegacyCalls(): number;
373
381
  /** Обзор бюджетов для статуса; `undefined` — бюджеты не заданы. */
374
382
  budgets(): {
375
- onUnknown: "stop" | "continue";
383
+ onUnknown: "continue" | "stop";
376
384
  budgets: {
377
385
  reason?: string | undefined;
378
386
  scope: import("./budget.ts").BudgetScope;
@@ -492,6 +500,10 @@ export declare class Engine {
492
500
  digest: string;
493
501
  summary: string;
494
502
  consumer?: string | undefined;
503
+ recheck?: {
504
+ of: string;
505
+ outcome: "flaky" | "confirmed";
506
+ } | undefined;
495
507
  inspection?: {
496
508
  mode: "commands" | "diff-only";
497
509
  source: "codex-events" | "unavailable" | "controller-probes" | "runtime-and-controller";
@@ -546,7 +558,7 @@ export declare class Engine {
546
558
  expected: string[];
547
559
  issues?: {
548
560
  path: string;
549
- reason: "unknown" | "missing" | "schema" | "duplicate" | "not-open" | "approved-with-blocking";
561
+ reason: "schema" | "unknown" | "missing" | "duplicate" | "not-open" | "approved-with-blocking";
550
562
  message: string;
551
563
  }[] | undefined;
552
564
  transitions?: {
@@ -33,6 +33,21 @@ const contentDigest = (order) => digestOf({ ...order, source: { connector: order
33
33
  const uncounted = (kind, blocked) => blocked || kind === 'environment' || kind === 'provider-auth';
34
34
  /** Поручение исчерпало предел незасчитанных отказов: повтор — только со сбросом. */
35
35
  export const neutralExhausted = (w) => (w.neutralFailures ?? 0) >= MAX_NEUTRAL_FAILURES;
36
+ /**
37
+ * Провал, названный свойством или случаем корпуса, — найденный контрпример, а
38
+ * не сбой среды: генеративная проверка недетерминирована, и удачный повтор
39
+ * не отменяет найденного входа. Такой провал не повторяется.
40
+ */
41
+ export function namesFailingCases(e) {
42
+ const report = e.property?.report;
43
+ return (!!report &&
44
+ (report.properties.some((p) => p.status === 'failed') ||
45
+ (report.corpus?.failed.length ?? 0) > 0));
46
+ }
47
+ /** Активные попытки снимка: быстрый путь адаптера или фильтр всех. */
48
+ export function activeOf(v) {
49
+ return v.activeAttempts ? v.activeAttempts() : v.attempts().filter((a) => a.status === 'active');
50
+ }
36
51
  export class Engine {
37
52
  host;
38
53
  policy;
@@ -1136,6 +1151,25 @@ export class Engine {
1136
1151
  // доказывала бы его (и названный testcase).
1137
1152
  if ((evidence.kind === 'review') !== (evidence.gate === 'independent-review'))
1138
1153
  throw new HarnessError('INVALID_INPUT', `Evidence вида ${evidence.kind} не может относиться к gate ${evidence.gate}`);
1154
+ // Повтор ссылается на провал того же gate этой попытки на том же SHA, и
1155
+ // попытка повторяет не больше одного провала.
1156
+ if (evidence.recheck) {
1157
+ const of = evidence.recheck.of;
1158
+ const first = a.evidence.find((e) => e.id === of);
1159
+ if (evidence.kind !== 'test' ||
1160
+ !first ||
1161
+ first.passed ||
1162
+ first.kind !== 'test' ||
1163
+ first.gate !== evidence.gate ||
1164
+ first.phase !== evidence.phase ||
1165
+ first.sha !== evidence.sha ||
1166
+ first.consumer !== evidence.consumer ||
1167
+ namesFailingCases(first) ||
1168
+ a.evidence.some((e) => e.recheck))
1169
+ throw new HarnessError('INVALID_INPUT', 'Повтор gate не относится к провалу этой попытки');
1170
+ if (evidence.recheck.outcome !== (evidence.passed ? 'flaky' : 'confirmed'))
1171
+ throw new HarnessError('INVALID_INPUT', 'Исход повтора gate не согласован с записью');
1172
+ }
1139
1173
  const record = {
1140
1174
  ...evidence,
1141
1175
  ...(a.checks ? { checks: a.checks.effective } : {}),
@@ -1170,6 +1204,7 @@ export class Engine {
1170
1204
  passed: record.passed,
1171
1205
  evidenceId: record.id,
1172
1206
  ...(record.consumer ? { consumer: record.consumer } : {}),
1207
+ ...(record.recheck ? { recheck: record.recheck } : {}),
1173
1208
  },
1174
1209
  });
1175
1210
  return record;
@@ -2215,9 +2250,13 @@ export class Engine {
2215
2250
  * момент в будущем, когда снимает всё владение восстановленной копии.
2216
2251
  */
2217
2252
  expire(at = this.now()) {
2253
+ // Такт очереди вызывает истечение постоянно: без истёкших попыток
2254
+ // транзакции записи (и её снимка состояния) нет.
2255
+ if (!this.read((v) => activeOf(v).some((a) => a.leaseUntil <= at)))
2256
+ return [];
2218
2257
  return this.tx('runs.expired', (tx) => {
2219
2258
  const ids = [];
2220
- for (const a of tx.attempts())
2259
+ for (const a of activeOf(tx))
2221
2260
  if (a.status === 'active' && a.leaseUntil <= at) {
2222
2261
  const error = (a.error?.startsWith(HEARTBEAT_FAILED) ? a.error + '. ' : '') +
2223
2262
  'Истёк срок владения. Повторите явно.';
@@ -1,6 +1,6 @@
1
1
  import { type ImplementationResult, type AttemptState, type ContextSnapshot, type ExecutionPolicy, type RuntimeAdapter, type RuntimeName, type WorkState } from '../contracts/index.ts';
2
2
  import { type FailureKind } from './failure.ts';
3
- import type { Engine } from './engine.ts';
3
+ import { type Engine } from './engine.ts';
4
4
  import { CorpusStore } from '../verification/corpus.ts';
5
5
  type Repo = ExecutionPolicy['repositories'][number];
6
6
  export interface RunnerOptions {
@@ -197,6 +197,16 @@ export declare class Runner {
197
197
  receipts: string[];
198
198
  }>;
199
199
  private gate;
200
+ /**
201
+ * Gate интеграции с одним повтором на кандидата. Провал собственного gate на
202
+ * integration, когда тот же gate прошёл на кандидате, часто вызван средой
203
+ * (бюджет времени под конкуренцией за CPU), а не кодом; без повтора такой
204
+ * провал оплачивался новой реализацией. Повтор — тот же gate на том же
205
+ * integration SHA, один раз за интеграцию кандидата; обе записи остаются,
206
+ * у повтора — `recheck` со ссылкой на первую и исходом (`flaky` — повтор
207
+ * прошёл, `confirmed` — провал подтвердился и засчитывается как прежде).
208
+ */
209
+ private integrationGate;
200
210
  private runOneGate;
201
211
  /**
202
212
  * Ожидаемая проверка генеративного gate. Проверка потребителя исполняет