@humain/humain-code-contracts 0.4.14 → 0.4.17

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.
@@ -6,11 +6,23 @@ export { FlowProfileRefSchema, type FlowProfileRefV1 } from "./flow-common.ts";
6
6
  * semantic content, though: a path-like string can match an Id or model pattern. Producers must put only catalog
7
7
  * provider/model identifiers in those fields (see docs/flow-contracts.md, trust boundaries).
8
8
  */
9
- export declare const FLOW_EVENT_KINDS: readonly ["run_started", "size_decided", "escalated", "route_bound", "fallback", "attempt", "request_usage", "verdict", "budget", "control", "message", "run_settled", "warning"];
9
+ export declare const FLOW_EVENT_KINDS: readonly ["run_started", "size_decided", "escalated", "route_bound", "fallback", "attempt", "request_usage", "verdict", "budget", "control", "message", "run_settled", "warning", "worker_gate", "implementation_ready", "verification_started", "repair_proposed", "repair_started", "repair_finished", "repair_skipped", "verification_settled"];
10
10
  export type FlowEventKind = (typeof FLOW_EVENT_KINDS)[number];
11
11
  /** Content-free warning reasons. `preexisting_check_failures`: checks already failed identically before the run changed anything. */
12
12
  export declare const FLOW_WARNING_REASONS: readonly ["preexisting_check_failures"];
13
13
  export type FlowWarningReason = (typeof FLOW_WARNING_REASONS)[number];
14
+ /** Content-free worker gate reasons. `not_delegated`: a lead exited successfully without any nested subagent call. */
15
+ export declare const FLOW_WORKER_GATE_REASONS: readonly ["not_delegated"];
16
+ export type FlowWorkerGateReason = (typeof FLOW_WORKER_GATE_REASONS)[number];
17
+ /** Per-check attribution of a verify-after check result (emitted only for runs admitted with `verification: "after"`). */
18
+ export declare const FLOW_CHECK_ATTRIBUTIONS: readonly ["passed", "real", "pre_existing", "flaky", "deadline_limited", "unavailable"];
19
+ export type FlowCheckAttribution = (typeof FLOW_CHECK_ATTRIBUTIONS)[number];
20
+ export declare const FLOW_VERIFICATION_VERDICTS: readonly ["verified", "verified_with_preexisting", "checks_failing", "verification_unavailable"];
21
+ export type FlowVerificationVerdict = (typeof FLOW_VERIFICATION_VERDICTS)[number];
22
+ export declare const FLOW_VERIFICATION_REASONS: readonly ["no_checks", "could_not_run", "deadline", "workspace_changed", "superseded", "cancelled", "crash"];
23
+ export type FlowVerificationReason = (typeof FLOW_VERIFICATION_REASONS)[number];
24
+ export declare const FLOW_REPAIR_SKIP_REASONS: readonly ["user_edited", "host_denied", "grant_timeout", "no_progress", "deadline", "exhausted", "not_repairable"];
25
+ export type FlowRepairSkipReason = (typeof FLOW_REPAIR_SKIP_REASONS)[number];
14
26
  export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
15
27
  readonly schema: Type.TLiteral<"humain-flow-event">;
16
28
  readonly schemaVersion: Type.TLiteral<1>;
@@ -48,7 +60,8 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
48
60
  readonly kind: Type.TLiteral<"size_decided">;
49
61
  readonly payload: Type.TObject<{
50
62
  readonly size: Type.TUnion<[Type.TLiteral<"small">, Type.TLiteral<"medium">, Type.TLiteral<"large">]>;
51
- readonly source: Type.TUnion<[Type.TLiteral<"rules">, Type.TLiteral<"triage">, Type.TLiteral<"override">]>;
63
+ readonly source: Type.TUnion<[Type.TLiteral<"rules">, Type.TLiteral<"signals">, Type.TLiteral<"triage">, Type.TLiteral<"override">]>;
64
+ readonly basis: Type.TOptional<Type.TUnion<[Type.TLiteral<"prompt">, Type.TLiteral<"original_request">]>>;
52
65
  readonly ruleScore: Type.TNumber;
53
66
  readonly thresholds: Type.TObject<{
54
67
  readonly mediumAt: Type.TNumber;
@@ -72,7 +85,7 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
72
85
  readonly payload: Type.TObject<{
73
86
  readonly from: Type.TUnion<[Type.TLiteral<"small">, Type.TLiteral<"medium">, Type.TLiteral<"large">]>;
74
87
  readonly to: Type.TUnion<[Type.TLiteral<"small">, Type.TLiteral<"medium">, Type.TLiteral<"large">]>;
75
- readonly reasonClass: Type.TUnion<[Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"blocked">]>, Type.TLiteral<"size_underestimated">]>;
88
+ readonly reasonClass: Type.TUnion<[Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"unsupported_configuration">, Type.TLiteral<"blocked">, Type.TLiteral<"review_findings">]>, Type.TLiteral<"size_underestimated">]>;
76
89
  }>;
77
90
  }>, Type.TObject<{
78
91
  readonly schema: Type.TLiteral<"humain-flow-event">;
@@ -124,7 +137,7 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
124
137
  readonly provider: Type.TString;
125
138
  readonly model: Type.TString;
126
139
  }>;
127
- readonly reasonClass: Type.TUnion<[Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"blocked">]>, Type.TLiteral<"size_underestimated">]>;
140
+ readonly reasonClass: Type.TUnion<[Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"unsupported_configuration">, Type.TLiteral<"blocked">, Type.TLiteral<"review_findings">]>, Type.TLiteral<"size_underestimated">]>;
128
141
  }>;
129
142
  }>, Type.TObject<{
130
143
  readonly schema: Type.TLiteral<"humain-flow-event">;
@@ -145,7 +158,7 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
145
158
  readonly role: Type.TUnion<[Type.TLiteral<"scout">, Type.TLiteral<"worker">, Type.TLiteral<"implementer">, Type.TLiteral<"lead">, Type.TLiteral<"lead_large">, Type.TLiteral<"architect">, Type.TLiteral<"reviewer">, Type.TLiteral<"security_reviewer">, Type.TLiteral<"qa">, Type.TLiteral<"triage">]>;
146
159
  readonly attempt: Type.TInteger;
147
160
  readonly state: Type.TUnion<[Type.TLiteral<"started">, Type.TLiteral<"succeeded">, Type.TLiteral<"failed">, Type.TLiteral<"retried">, Type.TLiteral<"cancelled">]>;
148
- readonly failureClass: Type.TOptional<Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"blocked">]>>;
161
+ readonly failureClass: Type.TOptional<Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"unsupported_configuration">, Type.TLiteral<"blocked">, Type.TLiteral<"review_findings">]>>;
149
162
  }>;
150
163
  }>, Type.TObject<{
151
164
  readonly schema: Type.TLiteral<"humain-flow-event">;
@@ -197,6 +210,8 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
197
210
  readonly verdict: Type.TUnion<[Type.TLiteral<"pass">, Type.TLiteral<"fail">, Type.TLiteral<"blocked">]>;
198
211
  readonly findingsCount: Type.TInteger;
199
212
  readonly checkId: Type.TOptional<Type.TString>;
213
+ readonly round: Type.TOptional<Type.TInteger>;
214
+ readonly attribution: Type.TOptional<Type.TUnion<[Type.TLiteral<"passed">, Type.TLiteral<"real">, Type.TLiteral<"pre_existing">, Type.TLiteral<"flaky">, Type.TLiteral<"deadline_limited">, Type.TLiteral<"unavailable">]>>;
200
215
  }>;
201
216
  }>, Type.TObject<{
202
217
  readonly schema: Type.TLiteral<"humain-flow-event">;
@@ -275,7 +290,7 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
275
290
  readonly kind: Type.TLiteral<"run_settled">;
276
291
  readonly payload: Type.TObject<{
277
292
  readonly outcome: Type.TUnion<[Type.TLiteral<"succeeded">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">, Type.TLiteral<"budget_stopped">, Type.TLiteral<"interrupted">]>;
278
- readonly failureClass: Type.TOptional<Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"blocked">]>>;
293
+ readonly failureClass: Type.TOptional<Type.TUnion<[Type.TLiteral<"provider_error">, Type.TLiteral<"provider_unreachable">, Type.TLiteral<"rate_limit">, Type.TLiteral<"timeout">, Type.TLiteral<"check_failed">, Type.TLiteral<"review_rejected">, Type.TLiteral<"qa_failed">, Type.TLiteral<"budget_stop">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">, Type.TLiteral<"unsafe_scope">, Type.TLiteral<"stalled">, Type.TLiteral<"config_invalid">, Type.TLiteral<"internal">, Type.TLiteral<"review_verdict_missing">, Type.TLiteral<"verification_unavailable">, Type.TLiteral<"unsupported_configuration">, Type.TLiteral<"blocked">, Type.TLiteral<"review_findings">]>>;
279
294
  readonly settledCleanly: Type.TBoolean;
280
295
  readonly retryOffer: Type.TArray<Type.TUnion<[Type.TLiteral<"flow">, Type.TLiteral<"direct">]>>;
281
296
  readonly totals: Type.TObject<{
@@ -340,6 +355,11 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
340
355
  readonly requests: Type.TInteger;
341
356
  }>>;
342
357
  }>;
358
+ readonly checkCache: Type.TOptional<Type.TObject<{
359
+ readonly hits: Type.TInteger;
360
+ readonly misses: Type.TInteger;
361
+ readonly savedMs: Type.TInteger;
362
+ }>>;
343
363
  }>;
344
364
  }>, Type.TObject<{
345
365
  readonly schema: Type.TLiteral<"humain-flow-event">;
@@ -359,6 +379,168 @@ export declare const FlowEventV1Schema: Type.TUnion<[Type.TObject<{
359
379
  readonly reason: Type.TUnion<[Type.TLiteral<"preexisting_check_failures">]>;
360
380
  readonly checkIds: Type.TArray<Type.TString>;
361
381
  }>;
382
+ }>, Type.TObject<{
383
+ readonly schema: Type.TLiteral<"humain-flow-event">;
384
+ readonly schemaVersion: Type.TLiteral<1>;
385
+ readonly eventId: Type.TString;
386
+ readonly runId: Type.TString;
387
+ readonly seq: Type.TInteger;
388
+ readonly ts: Type.TRefine<Type.TString>;
389
+ readonly profile: Type.TObject<{
390
+ readonly id: Type.TString;
391
+ readonly version: Type.TInteger;
392
+ readonly digest: Type.TString;
393
+ }>;
394
+ readonly causes: Type.TArray<Type.TString>;
395
+ readonly kind: Type.TLiteral<"worker_gate">;
396
+ readonly payload: Type.TObject<{
397
+ readonly taskId: Type.TString;
398
+ readonly reason: Type.TUnion<[Type.TLiteral<"not_delegated">]>;
399
+ }>;
400
+ }>, Type.TObject<{
401
+ readonly schema: Type.TLiteral<"humain-flow-event">;
402
+ readonly schemaVersion: Type.TLiteral<1>;
403
+ readonly eventId: Type.TString;
404
+ readonly runId: Type.TString;
405
+ readonly seq: Type.TInteger;
406
+ readonly ts: Type.TRefine<Type.TString>;
407
+ readonly profile: Type.TObject<{
408
+ readonly id: Type.TString;
409
+ readonly version: Type.TInteger;
410
+ readonly digest: Type.TString;
411
+ }>;
412
+ readonly causes: Type.TArray<Type.TString>;
413
+ readonly kind: Type.TLiteral<"implementation_ready">;
414
+ readonly payload: Type.TObject<{
415
+ readonly taskId: Type.TString;
416
+ readonly round: Type.TInteger;
417
+ readonly treeDigest: Type.TString;
418
+ readonly filesChangedCount: Type.TInteger;
419
+ }>;
420
+ }>, Type.TObject<{
421
+ readonly schema: Type.TLiteral<"humain-flow-event">;
422
+ readonly schemaVersion: Type.TLiteral<1>;
423
+ readonly eventId: Type.TString;
424
+ readonly runId: Type.TString;
425
+ readonly seq: Type.TInteger;
426
+ readonly ts: Type.TRefine<Type.TString>;
427
+ readonly profile: Type.TObject<{
428
+ readonly id: Type.TString;
429
+ readonly version: Type.TInteger;
430
+ readonly digest: Type.TString;
431
+ }>;
432
+ readonly causes: Type.TArray<Type.TString>;
433
+ readonly kind: Type.TLiteral<"verification_started">;
434
+ readonly payload: Type.TObject<{
435
+ readonly round: Type.TInteger;
436
+ readonly checksCount: Type.TInteger;
437
+ readonly scope: Type.TUnion<[Type.TLiteral<"scoped">, Type.TLiteral<"full">]>;
438
+ readonly budgetMs: Type.TInteger;
439
+ readonly cachedBaselines: Type.TInteger;
440
+ }>;
441
+ }>, Type.TObject<{
442
+ readonly schema: Type.TLiteral<"humain-flow-event">;
443
+ readonly schemaVersion: Type.TLiteral<1>;
444
+ readonly eventId: Type.TString;
445
+ readonly runId: Type.TString;
446
+ readonly seq: Type.TInteger;
447
+ readonly ts: Type.TRefine<Type.TString>;
448
+ readonly profile: Type.TObject<{
449
+ readonly id: Type.TString;
450
+ readonly version: Type.TInteger;
451
+ readonly digest: Type.TString;
452
+ }>;
453
+ readonly causes: Type.TArray<Type.TString>;
454
+ readonly kind: Type.TLiteral<"repair_proposed">;
455
+ readonly payload: Type.TObject<{
456
+ readonly round: Type.TInteger;
457
+ readonly checkIds: Type.TArray<Type.TString>;
458
+ readonly treeDigest: Type.TString;
459
+ }>;
460
+ }>, Type.TObject<{
461
+ readonly schema: Type.TLiteral<"humain-flow-event">;
462
+ readonly schemaVersion: Type.TLiteral<1>;
463
+ readonly eventId: Type.TString;
464
+ readonly runId: Type.TString;
465
+ readonly seq: Type.TInteger;
466
+ readonly ts: Type.TRefine<Type.TString>;
467
+ readonly profile: Type.TObject<{
468
+ readonly id: Type.TString;
469
+ readonly version: Type.TInteger;
470
+ readonly digest: Type.TString;
471
+ }>;
472
+ readonly causes: Type.TArray<Type.TString>;
473
+ readonly kind: Type.TLiteral<"repair_started">;
474
+ readonly payload: Type.TObject<{
475
+ readonly round: Type.TInteger;
476
+ readonly taskId: Type.TString;
477
+ readonly trigger: Type.TUnion<[Type.TLiteral<"auto">]>;
478
+ }>;
479
+ }>, Type.TObject<{
480
+ readonly schema: Type.TLiteral<"humain-flow-event">;
481
+ readonly schemaVersion: Type.TLiteral<1>;
482
+ readonly eventId: Type.TString;
483
+ readonly runId: Type.TString;
484
+ readonly seq: Type.TInteger;
485
+ readonly ts: Type.TRefine<Type.TString>;
486
+ readonly profile: Type.TObject<{
487
+ readonly id: Type.TString;
488
+ readonly version: Type.TInteger;
489
+ readonly digest: Type.TString;
490
+ }>;
491
+ readonly causes: Type.TArray<Type.TString>;
492
+ readonly kind: Type.TLiteral<"repair_finished">;
493
+ readonly payload: Type.TObject<{
494
+ readonly round: Type.TInteger;
495
+ readonly state: Type.TUnion<[Type.TLiteral<"kept">, Type.TLiteral<"reverted">, Type.TLiteral<"failed">, Type.TLiteral<"cancelled">]>;
496
+ readonly treeDigest: Type.TString;
497
+ }>;
498
+ }>, Type.TObject<{
499
+ readonly schema: Type.TLiteral<"humain-flow-event">;
500
+ readonly schemaVersion: Type.TLiteral<1>;
501
+ readonly eventId: Type.TString;
502
+ readonly runId: Type.TString;
503
+ readonly seq: Type.TInteger;
504
+ readonly ts: Type.TRefine<Type.TString>;
505
+ readonly profile: Type.TObject<{
506
+ readonly id: Type.TString;
507
+ readonly version: Type.TInteger;
508
+ readonly digest: Type.TString;
509
+ }>;
510
+ readonly causes: Type.TArray<Type.TString>;
511
+ readonly kind: Type.TLiteral<"repair_skipped">;
512
+ readonly payload: Type.TObject<{
513
+ readonly round: Type.TInteger;
514
+ readonly reason: Type.TUnion<[Type.TLiteral<"user_edited">, Type.TLiteral<"host_denied">, Type.TLiteral<"grant_timeout">, Type.TLiteral<"no_progress">, Type.TLiteral<"deadline">, Type.TLiteral<"exhausted">, Type.TLiteral<"not_repairable">]>;
515
+ }>;
516
+ }>, Type.TObject<{
517
+ readonly schema: Type.TLiteral<"humain-flow-event">;
518
+ readonly schemaVersion: Type.TLiteral<1>;
519
+ readonly eventId: Type.TString;
520
+ readonly runId: Type.TString;
521
+ readonly seq: Type.TInteger;
522
+ readonly ts: Type.TRefine<Type.TString>;
523
+ readonly profile: Type.TObject<{
524
+ readonly id: Type.TString;
525
+ readonly version: Type.TInteger;
526
+ readonly digest: Type.TString;
527
+ }>;
528
+ readonly causes: Type.TArray<Type.TString>;
529
+ readonly kind: Type.TLiteral<"verification_settled">;
530
+ readonly payload: Type.TObject<{
531
+ readonly verdict: Type.TUnion<[Type.TLiteral<"verified">, Type.TLiteral<"verified_with_preexisting">, Type.TLiteral<"checks_failing">, Type.TLiteral<"verification_unavailable">]>;
532
+ readonly reason: Type.TOptional<Type.TUnion<[Type.TLiteral<"no_checks">, Type.TLiteral<"could_not_run">, Type.TLiteral<"deadline">, Type.TLiteral<"workspace_changed">, Type.TLiteral<"superseded">, Type.TLiteral<"cancelled">, Type.TLiteral<"crash">]>>;
533
+ readonly counts: Type.TObject<{
534
+ readonly passed: Type.TInteger;
535
+ readonly real: Type.TInteger;
536
+ readonly preExisting: Type.TInteger;
537
+ readonly flaky: Type.TInteger;
538
+ readonly deadlineLimited: Type.TInteger;
539
+ readonly unavailable: Type.TInteger;
540
+ }>;
541
+ readonly repairRounds: Type.TInteger;
542
+ readonly readyToVerdictMs: Type.TInteger;
543
+ }>;
362
544
  }>]>;
363
545
  export type FlowEventV1 = Static<typeof FlowEventV1Schema>;
364
546
  /** Validates a plain-data snapshot of `input` and returns the snapshot (never the caller's object). */
@@ -1 +1 @@
1
- {"version":3,"file":"flow-events.d.ts","sourceRoot":"","sources":["../src/flow-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,IAAI,EAAE,MAAM,SAAS,CAAC;AAqB1D,OAAO,EAA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ker_gate",
25
+ "implementation_ready",
26
+ "verification_started",
27
+ "repair_proposed",
28
+ "repair_started",
29
+ "repair_finished",
30
+ "repair_skipped",
31
+ "verification_settled",
24
32
  ];
25
33
  /** Content-free warning reasons. `preexisting_check_failures`: checks already failed identically before the run changed anything. */
26
34
  export const FLOW_WARNING_REASONS = ["preexisting_check_failures"];
35
+ /** Content-free worker gate reasons. `not_delegated`: a lead exited successfully without any nested subagent call. */
36
+ export const FLOW_WORKER_GATE_REASONS = ["not_delegated"];
37
+ /** Per-check attribution of a verify-after check result (emitted only for runs admitted with `verification: "after"`). */
38
+ export const FLOW_CHECK_ATTRIBUTIONS = [
39
+ "passed",
40
+ "real",
41
+ "pre_existing",
42
+ "flaky",
43
+ "deadline_limited",
44
+ "unavailable",
45
+ ];
46
+ export const FLOW_VERIFICATION_VERDICTS = [
47
+ "verified",
48
+ "verified_with_preexisting",
49
+ "checks_failing",
50
+ "verification_unavailable",
51
+ ];
52
+ export const FLOW_VERIFICATION_REASONS = [
53
+ "no_checks",
54
+ "could_not_run",
55
+ "deadline",
56
+ "workspace_changed",
57
+ "superseded",
58
+ "cancelled",
59
+ "crash",
60
+ ];
61
+ export const FLOW_REPAIR_SKIP_REASONS = [
62
+ "user_edited",
63
+ "host_denied",
64
+ "grant_timeout",
65
+ "no_progress",
66
+ "deadline",
67
+ "exhausted",
68
+ "not_repairable",
69
+ ];
27
70
  const Mode = lit("auto", "direct");
71
+ const Round = Type.Integer({ minimum: 0, maximum: 4 });
72
+ const RepairRound = Type.Integer({ minimum: 1, maximum: 4 });
28
73
  const Effort = lit("low", "medium", "high");
29
74
  const EventModelRefSchema = StrictObject({ provider: FlowIdSchema, model: Type.String({ pattern: FLOW_ID_PATTERN }) });
30
75
  const event = (kind, payload) => StrictObject({
@@ -55,7 +100,8 @@ export const FlowEventV1Schema = Type.Union([
55
100
  })),
56
101
  event("size_decided", StrictObject({
57
102
  size: FlowSizeSchema,
58
- source: lit("rules", "triage", "override"),
103
+ source: lit("rules", "signals", "triage", "override"),
104
+ basis: Type.Optional(lit("prompt", "original_request")),
59
105
  ruleScore: Type.Number({ minimum: 0, maximum: 1_000_000 }),
60
106
  thresholds: StrictObject({
61
107
  mediumAt: Type.Number({ minimum: 0, maximum: 1_000_000 }),
@@ -104,6 +150,9 @@ export const FlowEventV1Schema = Type.Union([
104
150
  verdict: lit("pass", "fail", "blocked"),
105
151
  findingsCount: FlowCountSchema,
106
152
  checkId: Type.Optional(FlowIdSchema),
153
+ // verify-after only: the check round and its attribution, emitted once the check is attributed.
154
+ round: Type.Optional(Round),
155
+ attribution: Type.Optional(lit(...FLOW_CHECK_ATTRIBUTIONS)),
107
156
  })),
108
157
  event("budget", StrictObject({
109
158
  spentMicrousd: FlowMicrousdSchema,
@@ -131,12 +180,57 @@ export const FlowEventV1Schema = Type.Union([
131
180
  // Subset of the two retry modes offered to the user; unique, order-free (full offer = both).
132
181
  retryOffer: Type.Array(lit("flow", "direct"), { maxItems: 2, uniqueItems: true }),
133
182
  totals: partialByRole(RoleTotals),
183
+ // Baseline check cache counts (pristine-tree results reused across runs); counts only, never check identities.
184
+ checkCache: Type.Optional(StrictObject({ hits: FlowCountSchema, misses: FlowCountSchema, savedMs: FlowCountSchema })),
134
185
  })),
135
186
  event("warning", StrictObject({
136
187
  reason: lit(...FLOW_WARNING_REASONS),
137
188
  // Opaque check ids (the same ids `verdict.checkId` uses), never check names or commands.
138
189
  checkIds: Type.Array(FlowIdSchema, { minItems: 1, maxItems: 16, uniqueItems: true }),
139
190
  })),
191
+ // Warn-only worker gate: the run continues; `taskId` is the lead's opaque attempt task id.
192
+ event("worker_gate", StrictObject({ taskId: FlowIdSchema, reason: lit(...FLOW_WORKER_GATE_REASONS) })),
193
+ // verify-after kinds: emitted only for runs whose admission or profile requests `verification: "after"`.
194
+ // `treeDigest` is sha256 of the candidate tree identity, never a path.
195
+ event("implementation_ready", StrictObject({
196
+ taskId: FlowIdSchema,
197
+ round: Round,
198
+ treeDigest: FlowDigestSchema,
199
+ filesChangedCount: FlowCountSchema,
200
+ })),
201
+ event("verification_started", StrictObject({
202
+ round: Round,
203
+ checksCount: FlowCountSchema,
204
+ scope: lit("scoped", "full"),
205
+ budgetMs: FlowCountSchema,
206
+ cachedBaselines: FlowCountSchema,
207
+ })),
208
+ event("repair_proposed", StrictObject({
209
+ round: RepairRound,
210
+ checkIds: Type.Array(FlowIdSchema, { minItems: 1, maxItems: 16, uniqueItems: true }),
211
+ treeDigest: FlowDigestSchema,
212
+ })),
213
+ event("repair_started", StrictObject({ round: RepairRound, taskId: FlowIdSchema, trigger: lit("auto") })),
214
+ event("repair_finished", StrictObject({
215
+ round: RepairRound,
216
+ state: lit("kept", "reverted", "failed", "cancelled"),
217
+ treeDigest: FlowDigestSchema,
218
+ })),
219
+ event("repair_skipped", StrictObject({ round: RepairRound, reason: lit(...FLOW_REPAIR_SKIP_REASONS) })),
220
+ event("verification_settled", StrictObject({
221
+ verdict: lit(...FLOW_VERIFICATION_VERDICTS),
222
+ reason: Type.Optional(lit(...FLOW_VERIFICATION_REASONS)),
223
+ counts: StrictObject({
224
+ passed: FlowCountSchema,
225
+ real: FlowCountSchema,
226
+ preExisting: FlowCountSchema,
227
+ flaky: FlowCountSchema,
228
+ deadlineLimited: FlowCountSchema,
229
+ unavailable: FlowCountSchema,
230
+ }),
231
+ repairRounds: Round,
232
+ readyToVerdictMs: FlowCountSchema,
233
+ })),
140
234
  ]);
141
235
  const Validator = compileFlow(FlowEventV1Schema);
142
236
  /** `request_usage.costMicrousd` is null exactly when `costBasis` is "unknown"; never 0 for unknown. */
@@ -1 +1 @@
1
- {"version":3,"file":"flow-events.js","sourceRoot":"","sources":["../src/flow-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,IAAI,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EACN,WAAW,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,oBAA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,\n\tFlowFailureClassSchema,\n\tFlowIdSchema,\n\tFlowMicrousdSchema,\n\tFlowPositiveIntSchema,\n\tFlowProfileRefSchema,\n\tFlowReasonClassSchema,\n\tFlowRoleSchema,\n\tFlowSizeSchema,\n\tFlowTimestampSchema,\n\tlit,\n\tparseFlowData,\n\tpartialByRole,\n\tStrictObject,\n} from \"./flow-common.ts\";\n\nexport { FlowProfileRefSchema, type FlowProfileRefV1 } from \"./flow-common.ts\";\n\n/**\n * Privacy rule: every string in an event is an Id, a Digest, an enum literal, or an ISO timestamp.\n * There is no free-text field, so prompts, messages and model output have no place to go. Syntax checks cannot tell\n * semantic content, though: a path-like string can match an Id or model pattern. Producers must put only catalog\n * provider/model identifiers in those fields (see docs/flow-contracts.md, trust boundaries).\n */\n\nexport const FLOW_EVENT_KINDS = [\n\t\"run_started\",\n\t\"size_decided\",\n\t\"escalated\",\n\t\"route_bound\",\n\t\"fallback\",\n\t\"attempt\",\n\t\"request_usage\",\n\t\"verdict\",\n\t\"budget\",\n\t\"control\",\n\t\"message\",\n\t\"run_settled\",\n\t\"warning\",\n] as const;\nexport type FlowEventKind = (typeof FLOW_EVENT_KINDS)[number];\n\n/** Content-free warning reasons. `preexisting_check_failures`: checks already failed identically before the run changed anything. */\nexport const FLOW_WARNING_REASONS = [\"preexisting_check_failures\"] as const;\nexport type FlowWarningReason = (typeof FLOW_WARNING_REASONS)[number];\n\nconst Mode = lit(\"auto\", \"direct\");\nconst Effort = lit(\"low\", \"medium\", \"high\");\nconst EventModelRefSchema = StrictObject({ provider: FlowIdSchema, model: Type.String({ pattern: FLOW_ID_PATTERN }) });\n\nconst event = <const K extends string, P extends TSchema>(kind: K, payload: P) =>\n\tStrictObject({\n\t\tschema: Type.Literal(\"humain-flow-event\"),\n\t\tschemaVersion: Type.Literal(1),\n\t\teventId: FlowIdSchema,\n\t\trunId: FlowIdSchema,\n\t\tseq: FlowPositiveIntSchema,\n\t\tts: FlowTimestampSchema,\n\t\tprofile: FlowProfileRefSchema,\n\t\tcauses: Type.Array(FlowIdSchema, { maxItems: 16 }),\n\t\tkind: Type.Literal(kind),\n\t\tpayload,\n\t});\n\nconst RoleTotals = StrictObject({\n\ttokens: FlowCountSchema,\n\tcostMicrousd: FlowMicrousdSchema,\n\tdurationMs: FlowCountSchema,\n\trequests: FlowCountSchema,\n});\n\nexport const FlowEventV1Schema = Type.Union([\n\tevent(\n\t\t\"run_started\",\n\t\tStrictObject({\n\t\t\tmode: Mode,\n\t\t\tsurface: lit(\"cli\", \"web\"),\n\t\t\tadmissionDigest: FlowDigestSchema,\n\t\t\tinputsCount: FlowCountSchema,\n\t\t\tgoalSha256: FlowDigestSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"size_decided\",\n\t\tStrictObject({\n\t\t\tsize: FlowSizeSchema,\n\t\t\tsource: lit(\"rules\", \"triage\", \"override\"),\n\t\t\truleScore: Type.Number({ minimum: 0, maximum: 1_000_000 }),\n\t\t\tthresholds: StrictObject({\n\t\t\t\tmediumAt: Type.Number({ minimum: 0, maximum: 1_000_000 }),\n\t\t\t\tlargeAt: Type.Number({ minimum: 0, maximum: 1_000_000 }),\n\t\t\t}),\n\t\t}),\n\t),\n\tevent(\"escalated\", StrictObject({ from: FlowSizeSchema, to: FlowSizeSchema, reasonClass: FlowReasonClassSchema })),\n\tevent(\n\t\t\"route_bound\",\n\t\tStrictObject({\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tmodel: EventModelRefSchema,\n\t\t\teffort: Effort,\n\t\t\tbinding: lit(\"primary\", \"backup\", \"lead_selected\"),\n\t\t\tbackupIndex: Type.Integer({ minimum: 0, maximum: 7 }),\n\t\t}),\n\t),\n\tevent(\n\t\t\"fallback\",\n\t\tStrictObject({\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tfrom: EventModelRefSchema,\n\t\t\tto: EventModelRefSchema,\n\t\t\treasonClass: FlowReasonClassSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"attempt\",\n\t\tStrictObject({\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tattempt: FlowPositiveIntSchema,\n\t\t\tstate: lit(\"started\", \"succeeded\", \"failed\", \"retried\", \"cancelled\"),\n\t\t\tfailureClass: Type.Optional(FlowFailureClassSchema),\n\t\t}),\n\t),\n\tevent(\n\t\t\"request_usage\",\n\t\tStrictObject({\n\t\t\trequestId: FlowIdSchema,\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tmodel: EventModelRefSchema,\n\t\t\tinputTokens: FlowCountSchema,\n\t\t\toutputTokens: FlowCountSchema,\n\t\t\tcacheReadTokens: FlowCountSchema,\n\t\t\tcacheWriteTokens: FlowCountSchema,\n\t\t\tcostMicrousd: Type.Union([FlowMicrousdSchema, Type.Null()]),\n\t\t\tcostBasis: lit(\"reported\", \"estimated\", \"unknown\"),\n\t\t\tdurationMs: FlowCountSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"verdict\",\n\t\tStrictObject({\n\t\t\tstage: lit(\"check\", \"review\", \"qa\"),\n\t\t\ttaskId: FlowIdSchema,\n\t\t\tverdict: lit(\"pass\", \"fail\", \"blocked\"),\n\t\t\tfindingsCount: FlowCountSchema,\n\t\t\tcheckId: Type.Optional(FlowIdSchema),\n\t\t}),\n\t),\n\tevent(\n\t\t\"budget\",\n\t\tStrictObject({\n\t\t\tspentMicrousd: FlowMicrousdSchema,\n\t\t\tcapMicrousd: FlowMicrousdSchema,\n\t\t\tpct: Type.Number({ minimum: 0, maximum: 100 }),\n\t\t\tstate: lit(\"ok\", \"warn\", \"stop\"),\n\t\t}),\n\t),\n\tevent(\n\t\t\"control\",\n\t\tStrictObject({\n\t\t\taction: lit(\"pause\", \"resume\", \"cancel\", \"message\", \"status\"),\n\t\t\tcommandId: FlowIdSchema,\n\t\t\tstate: lit(\"accepted\", \"applied\", \"rejected\"),\n\t\t\tlatencyMs: FlowCountSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"message\",\n\t\tStrictObject({\n\t\t\tmessageId: FlowIdSchema,\n\t\t\tdisposition: lit(\"live\", \"queued\", \"rejected\"),\n\t\t\ttargetRole: FlowRoleSchema,\n\t\t\ttextSha256: FlowDigestSchema,\n\t\t\ttextLength: Type.Integer({ minimum: 1, maximum: 16_000 }),\n\t\t}),\n\t),\n\tevent(\n\t\t\"run_settled\",\n\t\tStrictObject({\n\t\t\toutcome: lit(\"succeeded\", \"failed\", \"cancelled\", \"budget_stopped\", \"interrupted\"),\n\t\t\tfailureClass: Type.Optional(FlowFailureClassSchema),\n\t\t\tsettledCleanly: Type.Boolean(),\n\t\t\t// Subset of the two retry modes offered to the user; unique, order-free (full offer = both).\n\t\t\tretryOffer: Type.Array(lit(\"flow\", \"direct\"), { maxItems: 2, uniqueItems: true }),\n\t\t\ttotals: partialByRole(RoleTotals),\n\t\t}),\n\t),\n\tevent(\n\t\t\"warning\",\n\t\tStrictObject({\n\t\t\treason: lit(...FLOW_WARNING_REASONS),\n\t\t\t// Opaque check ids (the same ids `verdict.checkId` uses), never check names or commands.\n\t\t\tcheckIds: Type.Array(FlowIdSchema, { minItems: 1, maxItems: 16, uniqueItems: true }),\n\t\t}),\n\t),\n]);\nexport type FlowEventV1 = Static<typeof FlowEventV1Schema>;\n\nconst Validator = compileFlow(FlowEventV1Schema);\n\n/** `request_usage.costMicrousd` is null exactly when `costBasis` is \"unknown\"; never 0 for unknown. */\nfunction crossFieldsValid(doc: FlowEventV1): boolean {\n\tif (doc.kind === \"request_usage\")\n\t\treturn (doc.payload.costMicrousd === null) === (doc.payload.costBasis === \"unknown\");\n\treturn true;\n}\n\nfunction isEvent(value: unknown): value is FlowEventV1 {\n\treturn Validator.Check(value) && crossFieldsValid(value);\n}\n\n/** Validates a plain-data snapshot of `input` and returns the snapshot (never the caller's object). */\nexport function parseFlowEventV1(input: unknown): FlowEventV1 {\n\treturn parseFlowData(\"event_invalid\", input, isEvent);\n}\n"]}
1
+ {"version":3,"file":"flow-events.js","sourceRoot":"","sources":["../src/flow-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,IAAI,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EACN,WAAW,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,GAAG,EACH,aAAa,EACb,aAAa,EACb,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAyB,MAAM,kBAAkB,CAAC;AAE/E;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,aAAa;IACb,cAAc;IACd,WAAW;IACX,aAAa;IACb,UAAU;IACV,SAAS;IACT,eAAe;IACf,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS;IACT,aAAa;IACb,SAAS;IACT,aAAa;IACb,sBAAsB;IACtB,sBAAsB;IACtB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,sBAAsB;CACb,CAAC;AAGX,qIAAqI;AACrI,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,4BAA4B,CAAU,CAAC;AAE5E,sHAAsH;AACtH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,eAAe,CAAU,CAAC;AAGnE,0HAA0H;AAC1H,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,QAAQ;IACR,MAAM;IACN,cAAc;IACd,OAAO;IACP,kBAAkB;IAClB,aAAa;CACJ,CAAC;AAEX,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACzC,UAAU;IACV,2BAA2B;IAC3B,gBAAgB;IAChB,0BAA0B;CACjB,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,WAAW;IACX,eAAe;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eAAe;YAC5B,KAAK,EAAE,eAAe;YACtB,eAAe,EAAE,eAAe;YAChC,WAAW,EAAE,eAAe;SAC5B,CAAC;QACF,YAAY,EAAE,KAAK;QACnB,gBAAgB,EAAE,eAAe;KACjC,CAAC,CACF;CACD,CAAC,CAAC;AAGH,MAAM,SAAS,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAEjD,uGAAuG;AACvG,SAAS,gBAAgB,CAAC,GAAgB;IACzC,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe;QAC/B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IACtF,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC9B,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC9C,OAAO,aAAa,CAAC,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { type Static, type TSchema, Type } from \"typebox\";\nimport {\n\tcompileFlow,\n\tFLOW_ID_PATTERN,\n\tFlowCountSchema,\n\tFlowDigestSchema,\n\tFlowFailureClassSchema,\n\tFlowIdSchema,\n\tFlowMicrousdSchema,\n\tFlowPositiveIntSchema,\n\tFlowProfileRefSchema,\n\tFlowReasonClassSchema,\n\tFlowRoleSchema,\n\tFlowSizeSchema,\n\tFlowTimestampSchema,\n\tlit,\n\tparseFlowData,\n\tpartialByRole,\n\tStrictObject,\n} from \"./flow-common.ts\";\n\nexport { FlowProfileRefSchema, type FlowProfileRefV1 } from \"./flow-common.ts\";\n\n/**\n * Privacy rule: every string in an event is an Id, a Digest, an enum literal, or an ISO timestamp.\n * There is no free-text field, so prompts, messages and model output have no place to go. Syntax checks cannot tell\n * semantic content, though: a path-like string can match an Id or model pattern. Producers must put only catalog\n * provider/model identifiers in those fields (see docs/flow-contracts.md, trust boundaries).\n */\n\nexport const FLOW_EVENT_KINDS = [\n\t\"run_started\",\n\t\"size_decided\",\n\t\"escalated\",\n\t\"route_bound\",\n\t\"fallback\",\n\t\"attempt\",\n\t\"request_usage\",\n\t\"verdict\",\n\t\"budget\",\n\t\"control\",\n\t\"message\",\n\t\"run_settled\",\n\t\"warning\",\n\t\"worker_gate\",\n\t\"implementation_ready\",\n\t\"verification_started\",\n\t\"repair_proposed\",\n\t\"repair_started\",\n\t\"repair_finished\",\n\t\"repair_skipped\",\n\t\"verification_settled\",\n] as const;\nexport type FlowEventKind = (typeof FLOW_EVENT_KINDS)[number];\n\n/** Content-free warning reasons. `preexisting_check_failures`: checks already failed identically before the run changed anything. */\nexport const FLOW_WARNING_REASONS = [\"preexisting_check_failures\"] as const;\nexport type FlowWarningReason = (typeof FLOW_WARNING_REASONS)[number];\n/** Content-free worker gate reasons. `not_delegated`: a lead exited successfully without any nested subagent call. */\nexport const FLOW_WORKER_GATE_REASONS = [\"not_delegated\"] as const;\nexport type FlowWorkerGateReason = (typeof FLOW_WORKER_GATE_REASONS)[number];\n\n/** Per-check attribution of a verify-after check result (emitted only for runs admitted with `verification: \"after\"`). */\nexport const FLOW_CHECK_ATTRIBUTIONS = [\n\t\"passed\",\n\t\"real\",\n\t\"pre_existing\",\n\t\"flaky\",\n\t\"deadline_limited\",\n\t\"unavailable\",\n] as const;\nexport type FlowCheckAttribution = (typeof FLOW_CHECK_ATTRIBUTIONS)[number];\nexport const FLOW_VERIFICATION_VERDICTS = [\n\t\"verified\",\n\t\"verified_with_preexisting\",\n\t\"checks_failing\",\n\t\"verification_unavailable\",\n] as const;\nexport type FlowVerificationVerdict = (typeof FLOW_VERIFICATION_VERDICTS)[number];\nexport const FLOW_VERIFICATION_REASONS = [\n\t\"no_checks\",\n\t\"could_not_run\",\n\t\"deadline\",\n\t\"workspace_changed\",\n\t\"superseded\",\n\t\"cancelled\",\n\t\"crash\",\n] as const;\nexport type FlowVerificationReason = (typeof FLOW_VERIFICATION_REASONS)[number];\nexport const FLOW_REPAIR_SKIP_REASONS = [\n\t\"user_edited\",\n\t\"host_denied\",\n\t\"grant_timeout\",\n\t\"no_progress\",\n\t\"deadline\",\n\t\"exhausted\",\n\t\"not_repairable\",\n] as const;\nexport type FlowRepairSkipReason = (typeof FLOW_REPAIR_SKIP_REASONS)[number];\n\nconst Mode = lit(\"auto\", \"direct\");\nconst Round = Type.Integer({ minimum: 0, maximum: 4 });\nconst RepairRound = Type.Integer({ minimum: 1, maximum: 4 });\nconst Effort = lit(\"low\", \"medium\", \"high\");\nconst EventModelRefSchema = StrictObject({ provider: FlowIdSchema, model: Type.String({ pattern: FLOW_ID_PATTERN }) });\n\nconst event = <const K extends string, P extends TSchema>(kind: K, payload: P) =>\n\tStrictObject({\n\t\tschema: Type.Literal(\"humain-flow-event\"),\n\t\tschemaVersion: Type.Literal(1),\n\t\teventId: FlowIdSchema,\n\t\trunId: FlowIdSchema,\n\t\tseq: FlowPositiveIntSchema,\n\t\tts: FlowTimestampSchema,\n\t\tprofile: FlowProfileRefSchema,\n\t\tcauses: Type.Array(FlowIdSchema, { maxItems: 16 }),\n\t\tkind: Type.Literal(kind),\n\t\tpayload,\n\t});\n\nconst RoleTotals = StrictObject({\n\ttokens: FlowCountSchema,\n\tcostMicrousd: FlowMicrousdSchema,\n\tdurationMs: FlowCountSchema,\n\trequests: FlowCountSchema,\n});\n\nexport const FlowEventV1Schema = Type.Union([\n\tevent(\n\t\t\"run_started\",\n\t\tStrictObject({\n\t\t\tmode: Mode,\n\t\t\tsurface: lit(\"cli\", \"web\"),\n\t\t\tadmissionDigest: FlowDigestSchema,\n\t\t\tinputsCount: FlowCountSchema,\n\t\t\tgoalSha256: FlowDigestSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"size_decided\",\n\t\tStrictObject({\n\t\t\tsize: FlowSizeSchema,\n\t\t\tsource: lit(\"rules\", \"signals\", \"triage\", \"override\"),\n\t\t\tbasis: Type.Optional(lit(\"prompt\", \"original_request\")),\n\t\t\truleScore: Type.Number({ minimum: 0, maximum: 1_000_000 }),\n\t\t\tthresholds: StrictObject({\n\t\t\t\tmediumAt: Type.Number({ minimum: 0, maximum: 1_000_000 }),\n\t\t\t\tlargeAt: Type.Number({ minimum: 0, maximum: 1_000_000 }),\n\t\t\t}),\n\t\t}),\n\t),\n\tevent(\"escalated\", StrictObject({ from: FlowSizeSchema, to: FlowSizeSchema, reasonClass: FlowReasonClassSchema })),\n\tevent(\n\t\t\"route_bound\",\n\t\tStrictObject({\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tmodel: EventModelRefSchema,\n\t\t\teffort: Effort,\n\t\t\tbinding: lit(\"primary\", \"backup\", \"lead_selected\"),\n\t\t\tbackupIndex: Type.Integer({ minimum: 0, maximum: 7 }),\n\t\t}),\n\t),\n\tevent(\n\t\t\"fallback\",\n\t\tStrictObject({\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tfrom: EventModelRefSchema,\n\t\t\tto: EventModelRefSchema,\n\t\t\treasonClass: FlowReasonClassSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"attempt\",\n\t\tStrictObject({\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tattempt: FlowPositiveIntSchema,\n\t\t\tstate: lit(\"started\", \"succeeded\", \"failed\", \"retried\", \"cancelled\"),\n\t\t\tfailureClass: Type.Optional(FlowFailureClassSchema),\n\t\t}),\n\t),\n\tevent(\n\t\t\"request_usage\",\n\t\tStrictObject({\n\t\t\trequestId: FlowIdSchema,\n\t\t\ttaskId: FlowIdSchema,\n\t\t\trole: FlowRoleSchema,\n\t\t\tmodel: EventModelRefSchema,\n\t\t\tinputTokens: FlowCountSchema,\n\t\t\toutputTokens: FlowCountSchema,\n\t\t\tcacheReadTokens: FlowCountSchema,\n\t\t\tcacheWriteTokens: FlowCountSchema,\n\t\t\tcostMicrousd: Type.Union([FlowMicrousdSchema, Type.Null()]),\n\t\t\tcostBasis: lit(\"reported\", \"estimated\", \"unknown\"),\n\t\t\tdurationMs: FlowCountSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"verdict\",\n\t\tStrictObject({\n\t\t\tstage: lit(\"check\", \"review\", \"qa\"),\n\t\t\ttaskId: FlowIdSchema,\n\t\t\tverdict: lit(\"pass\", \"fail\", \"blocked\"),\n\t\t\tfindingsCount: FlowCountSchema,\n\t\t\tcheckId: Type.Optional(FlowIdSchema),\n\t\t\t// verify-after only: the check round and its attribution, emitted once the check is attributed.\n\t\t\tround: Type.Optional(Round),\n\t\t\tattribution: Type.Optional(lit(...FLOW_CHECK_ATTRIBUTIONS)),\n\t\t}),\n\t),\n\tevent(\n\t\t\"budget\",\n\t\tStrictObject({\n\t\t\tspentMicrousd: FlowMicrousdSchema,\n\t\t\tcapMicrousd: FlowMicrousdSchema,\n\t\t\tpct: Type.Number({ minimum: 0, maximum: 100 }),\n\t\t\tstate: lit(\"ok\", \"warn\", \"stop\"),\n\t\t}),\n\t),\n\tevent(\n\t\t\"control\",\n\t\tStrictObject({\n\t\t\taction: lit(\"pause\", \"resume\", \"cancel\", \"message\", \"status\"),\n\t\t\tcommandId: FlowIdSchema,\n\t\t\tstate: lit(\"accepted\", \"applied\", \"rejected\"),\n\t\t\tlatencyMs: FlowCountSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"message\",\n\t\tStrictObject({\n\t\t\tmessageId: FlowIdSchema,\n\t\t\tdisposition: lit(\"live\", \"queued\", \"rejected\"),\n\t\t\ttargetRole: FlowRoleSchema,\n\t\t\ttextSha256: FlowDigestSchema,\n\t\t\ttextLength: Type.Integer({ minimum: 1, maximum: 16_000 }),\n\t\t}),\n\t),\n\tevent(\n\t\t\"run_settled\",\n\t\tStrictObject({\n\t\t\toutcome: lit(\"succeeded\", \"failed\", \"cancelled\", \"budget_stopped\", \"interrupted\"),\n\t\t\tfailureClass: Type.Optional(FlowFailureClassSchema),\n\t\t\tsettledCleanly: Type.Boolean(),\n\t\t\t// Subset of the two retry modes offered to the user; unique, order-free (full offer = both).\n\t\t\tretryOffer: Type.Array(lit(\"flow\", \"direct\"), { maxItems: 2, uniqueItems: true }),\n\t\t\ttotals: partialByRole(RoleTotals),\n\t\t\t// Baseline check cache counts (pristine-tree results reused across runs); counts only, never check identities.\n\t\t\tcheckCache: Type.Optional(\n\t\t\t\tStrictObject({ hits: FlowCountSchema, misses: FlowCountSchema, savedMs: FlowCountSchema }),\n\t\t\t),\n\t\t}),\n\t),\n\tevent(\n\t\t\"warning\",\n\t\tStrictObject({\n\t\t\treason: lit(...FLOW_WARNING_REASONS),\n\t\t\t// Opaque check ids (the same ids `verdict.checkId` uses), never check names or commands.\n\t\t\tcheckIds: Type.Array(FlowIdSchema, { minItems: 1, maxItems: 16, uniqueItems: true }),\n\t\t}),\n\t),\n\t// Warn-only worker gate: the run continues; `taskId` is the lead's opaque attempt task id.\n\tevent(\"worker_gate\", StrictObject({ taskId: FlowIdSchema, reason: lit(...FLOW_WORKER_GATE_REASONS) })),\n\t// verify-after kinds: emitted only for runs whose admission or profile requests `verification: \"after\"`.\n\t// `treeDigest` is sha256 of the candidate tree identity, never a path.\n\tevent(\n\t\t\"implementation_ready\",\n\t\tStrictObject({\n\t\t\ttaskId: FlowIdSchema,\n\t\t\tround: Round,\n\t\t\ttreeDigest: FlowDigestSchema,\n\t\t\tfilesChangedCount: FlowCountSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"verification_started\",\n\t\tStrictObject({\n\t\t\tround: Round,\n\t\t\tchecksCount: FlowCountSchema,\n\t\t\tscope: lit(\"scoped\", \"full\"),\n\t\t\tbudgetMs: FlowCountSchema,\n\t\t\tcachedBaselines: FlowCountSchema,\n\t\t}),\n\t),\n\tevent(\n\t\t\"repair_proposed\",\n\t\tStrictObject({\n\t\t\tround: RepairRound,\n\t\t\tcheckIds: Type.Array(FlowIdSchema, { minItems: 1, maxItems: 16, uniqueItems: true }),\n\t\t\ttreeDigest: FlowDigestSchema,\n\t\t}),\n\t),\n\tevent(\"repair_started\", StrictObject({ round: RepairRound, taskId: FlowIdSchema, trigger: lit(\"auto\") })),\n\tevent(\n\t\t\"repair_finished\",\n\t\tStrictObject({\n\t\t\tround: RepairRound,\n\t\t\tstate: lit(\"kept\", \"reverted\", \"failed\", \"cancelled\"),\n\t\t\ttreeDigest: FlowDigestSchema,\n\t\t}),\n\t),\n\tevent(\"repair_skipped\", StrictObject({ round: RepairRound, reason: lit(...FLOW_REPAIR_SKIP_REASONS) })),\n\tevent(\n\t\t\"verification_settled\",\n\t\tStrictObject({\n\t\t\tverdict: lit(...FLOW_VERIFICATION_VERDICTS),\n\t\t\treason: Type.Optional(lit(...FLOW_VERIFICATION_REASONS)),\n\t\t\tcounts: StrictObject({\n\t\t\t\tpassed: FlowCountSchema,\n\t\t\t\treal: FlowCountSchema,\n\t\t\t\tpreExisting: FlowCountSchema,\n\t\t\t\tflaky: FlowCountSchema,\n\t\t\t\tdeadlineLimited: FlowCountSchema,\n\t\t\t\tunavailable: FlowCountSchema,\n\t\t\t}),\n\t\t\trepairRounds: Round,\n\t\t\treadyToVerdictMs: FlowCountSchema,\n\t\t}),\n\t),\n]);\nexport type FlowEventV1 = Static<typeof FlowEventV1Schema>;\n\nconst Validator = compileFlow(FlowEventV1Schema);\n\n/** `request_usage.costMicrousd` is null exactly when `costBasis` is \"unknown\"; never 0 for unknown. */\nfunction crossFieldsValid(doc: FlowEventV1): boolean {\n\tif (doc.kind === \"request_usage\")\n\t\treturn (doc.payload.costMicrousd === null) === (doc.payload.costBasis === \"unknown\");\n\treturn true;\n}\n\nfunction isEvent(value: unknown): value is FlowEventV1 {\n\treturn Validator.Check(value) && crossFieldsValid(value);\n}\n\n/** Validates a plain-data snapshot of `input` and returns the snapshot (never the caller's object). */\nexport function parseFlowEventV1(input: unknown): FlowEventV1 {\n\treturn parseFlowData(\"event_invalid\", input, isEvent);\n}\n"]}
@@ -207,6 +207,8 @@ export declare const FlowProfileV1Schema: TObject<{
207
207
  readonly largeAt: Type.TNumber;
208
208
  }>;
209
209
  readonly triageRole: Type.TLiteral<"triage">;
210
+ /** Opt in to the LLM triage call for rules-large runs. Default off: size comes from rules and repo signals. */
211
+ readonly triage: TOptional<Type.TBoolean>;
210
212
  readonly maxEscalations: Type.TUnion<[Type.TLiteral<0>, Type.TLiteral<1>]>;
211
213
  }>>;
212
214
  readonly limits: TObject<{
@@ -216,7 +218,19 @@ export declare const FlowProfileV1Schema: TObject<{
216
218
  readonly maxRetries: Type.TInteger;
217
219
  readonly inactivityMs: Type.TInteger;
218
220
  readonly ciWaitMs: Type.TInteger;
221
+ /** Wall-clock budget for the whole run; checks are capped by what remains and the run settles at it. */
222
+ readonly runDeadlineMs: TOptional<Type.TInteger>;
223
+ /** Per-check timeout for deterministic checks; replaces the method's default and is still capped by the run deadline. */
224
+ readonly checkTimeoutMs: TOptional<Type.TInteger>;
225
+ /** Repair rounds a SMALL/MEDIUM run may spend on real deterministic check failures (default 2). */
226
+ readonly repairRounds: TOptional<Type.TInteger>;
227
+ /** verify-after: wall-clock budget for verification and repair, measured from `implementation_ready` (default 15 min). */
228
+ readonly verifyBudgetMs: TOptional<Type.TInteger>;
219
229
  }>;
230
+ /** `after` publishes the result before verification finishes (verify-after); default `inline`. */
231
+ readonly verification: TOptional<TObject<{
232
+ readonly mode: Type.TUnion<[Type.TLiteral<"inline">, Type.TLiteral<"after">]>;
233
+ }>>;
220
234
  readonly spend: TObject<{
221
235
  readonly runCapMicrousd: Type.TInteger;
222
236
  readonly warnAtPct: Type.TInteger;
@@ -1 +1 @@
1
- {"version":3,"file":"flow-profile.d.ts","sourceRoot":"","sources":["../src/flow-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,KAA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;;QAExG,yHAAyH;;QAEzH,mGAAmG;;QAEnG,0HAA0H;;;IAG3H,kGAAkG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWjG,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAK/D,6FAA6F;AAC7F,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAEjE;AAiCD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAErE;AAED,sHAAsH;AACtH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAM1F"}
@@ -66,6 +66,8 @@ export const FlowProfileV1Schema = StrictObject({
66
66
  largeAt: Type.Number({ minimum: 0, maximum: 1_000_000 }),
67
67
  }),
68
68
  triageRole: Type.Literal("triage"),
69
+ /** Opt in to the LLM triage call for rules-large runs. Default off: size comes from rules and repo signals. */
70
+ triage: Type.Optional(Type.Boolean()),
69
71
  maxEscalations: Type.Union([Type.Literal(0), Type.Literal(1)]),
70
72
  })),
71
73
  limits: StrictObject({
@@ -75,7 +77,17 @@ export const FlowProfileV1Schema = StrictObject({
75
77
  maxRetries: Type.Integer({ minimum: 0, maximum: 16 }),
76
78
  inactivityMs: Type.Integer({ minimum: 1, maximum: 86_400_000 }),
77
79
  ciWaitMs: Type.Integer({ minimum: 0, maximum: 86_400_000 }),
80
+ /** Wall-clock budget for the whole run; checks are capped by what remains and the run settles at it. */
81
+ runDeadlineMs: Type.Optional(Type.Integer({ minimum: 60_000, maximum: 86_400_000 })),
82
+ /** Per-check timeout for deterministic checks; replaces the method's default and is still capped by the run deadline. */
83
+ checkTimeoutMs: Type.Optional(Type.Integer({ minimum: 60_000, maximum: 86_400_000 })),
84
+ /** Repair rounds a SMALL/MEDIUM run may spend on real deterministic check failures (default 2). */
85
+ repairRounds: Type.Optional(Type.Integer({ minimum: 0, maximum: 4 })),
86
+ /** verify-after: wall-clock budget for verification and repair, measured from `implementation_ready` (default 15 min). */
87
+ verifyBudgetMs: Type.Optional(Type.Integer({ minimum: 60_000, maximum: 7_200_000 })),
78
88
  }),
89
+ /** `after` publishes the result before verification finishes (verify-after); default `inline`. */
90
+ verification: Type.Optional(StrictObject({ mode: Type.Union([Type.Literal("inline"), Type.Literal("after")]) })),
79
91
  spend: StrictObject({
80
92
  runCapMicrousd: FlowMicrousdSchema,
81
93
  warnAtPct: Type.Integer({ minimum: 1, maximum: 99 }),