ai-foreman 1.7.26 → 1.7.27

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 (91) hide show
  1. package/dist/adapters/codex.d.ts +12 -0
  2. package/dist/adapters/codex.js +50 -1
  3. package/dist/adapters/recovering.d.ts +4 -0
  4. package/dist/adapters/recovering.js +10 -0
  5. package/dist/adapters/sessionFailure.d.ts +6 -0
  6. package/dist/adapters/sessionFailure.js +19 -0
  7. package/dist/adapters/types.d.ts +6 -0
  8. package/dist/branch/currentGuard.d.ts +8 -0
  9. package/dist/branch/currentGuard.js +5 -0
  10. package/dist/branch/runner.js +6 -2
  11. package/dist/buildApproval.js +2 -1
  12. package/dist/buildRuns.d.ts +12 -0
  13. package/dist/buildRuns.js +50 -0
  14. package/dist/buildWorkContext.js +1 -1
  15. package/dist/buildWorkMigration.d.ts +10 -0
  16. package/dist/buildWorkMigration.js +18 -2
  17. package/dist/cli/start.d.ts +8 -0
  18. package/dist/cli/start.js +164 -27
  19. package/dist/cli/state.js +39 -1
  20. package/dist/cli/tickets.d.ts +37 -0
  21. package/dist/cli/tickets.js +367 -12
  22. package/dist/config.js +1 -0
  23. package/dist/continuity.d.ts +1 -0
  24. package/dist/continuity.js +5 -0
  25. package/dist/foreman.js +89 -8
  26. package/dist/graph/preparation.js +6 -3
  27. package/dist/graph/semantic.js +2 -1
  28. package/dist/graph/turn.js +8 -1
  29. package/dist/handoffProtocol.js +2 -1
  30. package/dist/handoffs.js +7 -19
  31. package/dist/log.d.ts +1 -1
  32. package/dist/managerPacket.js +1 -1
  33. package/dist/permissions/policy.js +21 -0
  34. package/dist/planChanges.js +1 -1
  35. package/dist/projectDiagnostics.js +30 -0
  36. package/dist/providerQuestions.js +4 -24
  37. package/dist/qaBuildGate.d.ts +6 -1
  38. package/dist/qaBuildGate.js +76 -16
  39. package/dist/qaBuilderCoverage.d.ts +2 -1
  40. package/dist/qaBuilderCoverage.js +47 -5
  41. package/dist/qaBuilderEvidence.d.ts +18 -0
  42. package/dist/qaBuilderEvidence.js +60 -0
  43. package/dist/qaContractCoverage.d.ts +12 -1
  44. package/dist/qaContractCoverage.js +34 -2
  45. package/dist/qaContractDelivery.d.ts +2 -2
  46. package/dist/qaContractDelivery.js +88 -10
  47. package/dist/qaEffectiveConfig.js +2 -1
  48. package/dist/qaFailureDelivery.d.ts +23 -0
  49. package/dist/qaFailureDelivery.js +87 -6
  50. package/dist/qaHostFacts.d.ts +2 -0
  51. package/dist/qaHostFacts.js +11 -0
  52. package/dist/qaPreparation.d.ts +38 -1
  53. package/dist/qaPreparation.js +372 -31
  54. package/dist/qaPreparationInputs.js +5 -1
  55. package/dist/qaPreparationPolicy.d.ts +2 -1
  56. package/dist/qaPreparationPolicy.js +39 -9
  57. package/dist/qaRecovery.d.ts +7 -0
  58. package/dist/qaRecovery.js +73 -1
  59. package/dist/qaReview.js +35 -8
  60. package/dist/qaReviewEvidence.d.ts +6 -0
  61. package/dist/qaReviewEvidence.js +37 -0
  62. package/dist/qaRollbackRehearsal.d.ts +2 -0
  63. package/dist/qaRollbackRehearsal.js +78 -0
  64. package/dist/qaSnapshot.d.ts +3 -1
  65. package/dist/qaSnapshot.js +3 -2
  66. package/dist/qaVerificationContract.d.ts +9 -0
  67. package/dist/qaVerificationContract.js +143 -17
  68. package/dist/sources/sourceRegistry.js +16 -5
  69. package/dist/stateTransfer.d.ts +14 -0
  70. package/dist/stateTransfer.js +51 -0
  71. package/dist/statusReporter.d.ts +8 -0
  72. package/dist/statusReporter.js +5 -0
  73. package/dist/ticketPlanning.d.ts +373 -0
  74. package/dist/ticketPlanning.js +34 -3
  75. package/dist/ticketPopulation.d.ts +28 -3
  76. package/dist/ticketPopulation.js +125 -15
  77. package/dist/tickets/details.d.ts +2 -1
  78. package/dist/tickets/details.js +7 -3
  79. package/dist/tickets/eligibility.d.ts +6 -0
  80. package/dist/tickets/eligibility.js +12 -1
  81. package/dist/tickets/riskWaivers.d.ts +3 -0
  82. package/dist/tickets/riskWaivers.js +12 -0
  83. package/dist/tickets/stateDb.d.ts +10 -0
  84. package/dist/tickets/stateDb.js +23 -0
  85. package/dist/tickets/ticketLoader.d.ts +9 -0
  86. package/dist/tickets/ticketLoader.js +15 -2
  87. package/dist/tickets/ticketSchema.d.ts +14 -1
  88. package/dist/tickets/ticketSchema.js +2 -1
  89. package/dist/tickets/validate.js +11 -1
  90. package/dist/workflowDb.js +11 -2
  91. package/package.json +9 -4
@@ -13,6 +13,8 @@ export interface QaFailureDeliveryInput {
13
13
  reviewNumber: number;
14
14
  reviewedSourceStateDigest: string;
15
15
  reviewBasisDigest: string;
16
+ /** Frozen published contract identity when contract enforcement is active. */
17
+ contractDigest?: string;
16
18
  remediationGeneration: number;
17
19
  latestBuilderResult: string;
18
20
  history: unknown[];
@@ -24,6 +26,12 @@ export interface QaFailureDeliveryInput {
24
26
  answer: string;
25
27
  };
26
28
  }
29
+ /**
30
+ * Remediation is deliberately smaller than review. The initial and every
31
+ * subsequent QA review still sees the complete ticket; only the Builder's
32
+ * follow-up work is limited to a bounded set of current findings.
33
+ */
34
+ export declare const QA_REMEDIATION_CHUNK_SIZE = 2;
27
35
  export interface QaFailureDeliveryController {
28
36
  adapter(): BuilderAdapter | undefined;
29
37
  setAdapter?(adapter: BuilderAdapter): void;
@@ -74,6 +82,20 @@ interface QaFailureHandoffV3 {
74
82
  value: QaFailureReportV1;
75
83
  findingRefs: QaFindingRefV2[];
76
84
  };
85
+ remediationChunk: {
86
+ version: 1;
87
+ ordinal: number;
88
+ findingIds: string[];
89
+ findingKeys: string[];
90
+ sourceDigest: string;
91
+ contractBinding: {
92
+ kind: "published-contract" | "review-basis";
93
+ digest: string;
94
+ };
95
+ reviewBasisDigest: string;
96
+ reviewAttemptId: string;
97
+ finalIndependentReviewRequired: true;
98
+ };
77
99
  latestBuilderResult: {
78
100
  rawResponseDigest: string;
79
101
  summaryDigest: string;
@@ -115,4 +137,5 @@ export declare class QaFailureDeliveryService {
115
137
  private buildHandoff;
116
138
  }
117
139
  export declare function renderQaFailureHandoff(handoff: QaFailureHandoffV3): string;
140
+ export declare function selectQaRemediationFindingIds(report: QaFailureReportV1): string[];
118
141
  export {};
@@ -14,6 +14,12 @@ import { withActivityPhase } from "./activity.js";
14
14
  import { captureFrozenQaSourceAsync } from "./qaSnapshot.js";
15
15
  import { canonicalJson, createQaFindingRefs, qaDigest } from "./qaProtocolV2.js";
16
16
  import { WorkflowDb } from "./workflowDb.js";
17
+ /**
18
+ * Remediation is deliberately smaller than review. The initial and every
19
+ * subsequent QA review still sees the complete ticket; only the Builder's
20
+ * follow-up work is limited to a bounded set of current findings.
21
+ */
22
+ export const QA_REMEDIATION_CHUNK_SIZE = 2;
17
23
  export class QaFailureDeliveryService {
18
24
  faults;
19
25
  constructor(faults = {}) {
@@ -93,6 +99,7 @@ export class QaFailureDeliveryService {
93
99
  prior = read.atomic(() => read.transitionQaFailureHandoff(handoffId, "recheck-required", { receiptDigest, responseDigest: historical.responseDigest, providerTurnId: historical.providerTurnId, detail: "Linked confirmed historical remediation idempotently; fresh source-bound QA required" }));
94
100
  }
95
101
  if (prior && prior.state !== "prepared") {
102
+ validateReplayBinding(read, input, prior);
96
103
  const raw = prior.receiptDigest ? read.getEvidence(prior.receiptDigest) : undefined;
97
104
  const receipt = raw ? JSON.parse(raw.toString()) : undefined;
98
105
  const accepted = prior.state === "recheck-required" && read.qaRemediationAttempt(prior.operationId)?.status === "succeeded";
@@ -120,7 +127,8 @@ export class QaFailureDeliveryService {
120
127
  const preBoundary = await phase("source-before-preparation", () => captureFrozenQaSourceAsync(input.builderWorktree));
121
128
  if (preBoundary.digest !== input.reviewedSourceStateDigest)
122
129
  return this.drift(input, "source-drift-before-delivery", preBoundary.digest);
123
- const findingRefs = createQaFindingRefs({ runId: input.runId, ticketId: input.ticket.id, reviewAttemptId: input.reviewAttemptId, reportDigest: input.reportDigest, rawFindingIds: input.report.findings.map(f => f.id) });
130
+ const chunkFindingIds = selectRemediationChunk(input);
131
+ const findingRefs = createQaFindingRefs({ runId: input.runId, ticketId: input.ticket.id, reviewAttemptId: input.reviewAttemptId, reportDigest: input.reportDigest, rawFindingIds: chunkFindingIds });
124
132
  const handoff = this.buildHandoff(input, preBoundary, findingRefs);
125
133
  let instruction = renderQaFailureHandoff(handoff) + (input.operatorAnswer ? `\nAuthorized operator answer (${input.operatorAnswer.decisionId}): ${JSON.stringify(input.operatorAnswer.answer)}` : "");
126
134
  enforceMandatoryPromptLimit(Buffer.from(instruction));
@@ -435,7 +443,7 @@ export class QaFailureDeliveryService {
435
443
  catch (caught) {
436
444
  errors.push(String(caught));
437
445
  }
438
- const contract = turn && !graphRequest ? parseBuilderQaRemediationContract(turn.cleanedResponse ?? turn.text, { handoffId: qaDigest("qa-failure-handoff", { runId: input.runId, ticketId: input.ticket.id, reviewAttemptId: input.reviewAttemptId, reportDigest: input.reportDigest, remediationGeneration: input.remediationGeneration + 1 }), findings: createQaFindingRefs({ runId: input.runId, ticketId: input.ticket.id, reviewAttemptId: input.reviewAttemptId, reportDigest: input.reportDigest, rawFindingIds: input.report.findings.map(f => f.id) }) }) : undefined;
446
+ const contract = turn && !graphRequest ? parseBuilderQaRemediationContract(turn.cleanedResponse ?? turn.text, { handoffId: qaDigest("qa-failure-handoff", { runId: input.runId, ticketId: input.ticket.id, reviewAttemptId: input.reviewAttemptId, reportDigest: input.reportDigest, remediationGeneration: input.remediationGeneration + 1 }), findings: createQaFindingRefs({ runId: input.runId, ticketId: input.ticket.id, reviewAttemptId: input.reviewAttemptId, reportDigest: input.reportDigest, rawFindingIds: selectRemediationChunk(input) }) }) : undefined;
439
447
  record.parserErrors = [...(contract?.errors ?? []), ...(turn?.continuityErrors ?? [])];
440
448
  record.validationErrors = errors;
441
449
  if (contract?.report)
@@ -524,9 +532,24 @@ export class QaFailureDeliveryService {
524
532
  occurrenceId: reportOccurrenceId(input.runId, input.ticket.id, input.reviewNumber),
525
533
  digest: input.reportDigest,
526
534
  rawEvidenceDigest: input.reportDigest,
527
- value: input.report,
535
+ // The complete report remains host-retained under rawEvidenceDigest.
536
+ // Builder receives only the bounded remediation chunk.
537
+ value: { ...input.report, findings: input.report.findings.filter((finding) => findingRefs.some((ref) => ref.rawId === finding.id)) },
528
538
  findingRefs,
529
539
  },
540
+ remediationChunk: {
541
+ version: 1,
542
+ ordinal: input.remediationGeneration + 1,
543
+ findingIds: findingRefs.map((finding) => finding.rawId),
544
+ findingKeys: findingRefs.map((finding) => finding.findingKey),
545
+ sourceDigest: input.reviewedSourceStateDigest,
546
+ contractBinding: input.contractDigest
547
+ ? { kind: "published-contract", digest: input.contractDigest }
548
+ : { kind: "review-basis", digest: input.reviewBasisDigest },
549
+ reviewBasisDigest: input.reviewBasisDigest,
550
+ reviewAttemptId: input.reviewAttemptId,
551
+ finalIndependentReviewRequired: true,
552
+ },
530
553
  latestBuilderResult: {
531
554
  rawResponseDigest: evidenceDigest(input.latestBuilderResult),
532
555
  summaryDigest: evidenceDigest(latestSummary.text),
@@ -562,6 +585,8 @@ export function renderQaFailureHandoff(handoff) {
562
585
  `Remediation generation: ${handoff.scope.remediationGeneration}`,
563
586
  `Reviewed source digest: ${handoff.source.reviewedContentDigest}`,
564
587
  `Review basis digest: ${handoff.source.reviewBasisDigest}`,
588
+ `Contract binding: ${JSON.stringify(handoff.remediationChunk.contractBinding)}`,
589
+ `Remediation chunk: ${JSON.stringify(handoff.remediationChunk)}`,
565
590
  `Captured at: ${handoff.source.capturedAt}`,
566
591
  `Builder worktree: ${handoff.source.worktreePath}`,
567
592
  `Git directory: ${handoff.source.gitDir}`,
@@ -571,7 +596,7 @@ export function renderQaFailureHandoff(handoff) {
571
596
  `Latest Builder result digest: ${handoff.latestBuilderResult.rawResponseDigest}`,
572
597
  `Latest Builder result summary${handoff.latestBuilderResult.summaryTruncated ? " (truncated)" : ""}:\n${handoff.latestBuilderResult.summary}`,
573
598
  `Current validated QA failure report digest: ${handoff.report.digest}`,
574
- `Current validated QA failure report:\n${JSON.stringify(handoff.report.value, null, 2)}`,
599
+ `Current validated QA remediation chunk:\n${JSON.stringify(handoff.report.value, null, 2)}`,
575
600
  `Raw QA finding ID to host finding key mapping:\n${findingMap}`,
576
601
  `Prior QA/report/remediation history:\n${handoff.history.length ? JSON.stringify(handoff.history, null, 2) : "(none)"}`,
577
602
  ...(handoff.plannerRemediation ? [
@@ -626,8 +651,9 @@ function boundedUtf8(text, maximumBytes) {
626
651
  function responseInstructions(handoff) {
627
652
  return [
628
653
  `QA failure handoff ID: ${handoff.handoffId}`,
629
- `Required finding identities: ${JSON.stringify(handoff.report.findingRefs.map(f => ({ finding_key: f.findingKey, raw_id: f.rawId })))}`,
630
- "Address, dispute with evidence, or mark blocked every current finding. A Builder claim never approves QA findings.",
654
+ `Required finding identities for this remediation chunk: ${JSON.stringify(handoff.report.findingRefs.map(f => ({ finding_key: f.findingKey, raw_id: f.rawId })))}`,
655
+ "Address, dispute with evidence, or mark blocked every finding in this remediation chunk. Do not address findings outside the chunk. A Builder claim never approves QA findings.",
656
+ "This is only a bounded remediation chunk. It does not approve the ticket. Any source change invalidates this chunk's source binding, and Rafi must perform a fresh full independent QA review afterward.",
631
657
  "The envelope must be the first non-empty content of the cleaned response. STEP_STATUS must be the final non-empty line. No prologue, trailing prose, duplicate keys, unknown or missing findings.",
632
658
  "In raw output, put the required RAFI_CONTINUITY_DELTA record between the envelope end and STEP_STATUS. The continuity wrapper removes only that record before contract validation.",
633
659
  `${BUILDER_QA_REMEDIATION_START}\n${JSON.stringify({ version: 3, handoff_id: handoff.handoffId, summary: "Truthful result", findings: handoff.report.findingRefs.map(f => ({ finding_key: f.findingKey, raw_id: f.rawId, disposition: "disputed", changes: ["Explain actual changes or why none were needed"], evidence: "Actual evidence", verification: [{ check: "Actual verification", outcome: "not_run", evidence: "Actual reason" }] })), observations: [] })}\n${BUILDER_QA_REMEDIATION_END}\nSTEP_STATUS: done | summary="short truthful summary"`,
@@ -636,6 +662,56 @@ function responseInstructions(handoff) {
636
662
  `Authoritative V3 schema: ${JSON.stringify(builderQaRemediationReportV3Schema)}`,
637
663
  ].join("\n\n");
638
664
  }
665
+ export function selectQaRemediationFindingIds(report) {
666
+ const ids = report.findings.slice(0, QA_REMEDIATION_CHUNK_SIZE).map((finding) => finding.id);
667
+ if (!ids.length)
668
+ throw new Error("QA remediation cannot create a chunk without a validated finding");
669
+ return ids;
670
+ }
671
+ function selectRemediationChunk(input) {
672
+ return selectQaRemediationFindingIds(input.report);
673
+ }
674
+ function currentPublishedContractDigest(db, input) {
675
+ if (!input.contractDigest)
676
+ return undefined;
677
+ const admission = db.assertAdmittedWork(input.runId, input.ticket.id);
678
+ const preparation = db.qaPreparationStore();
679
+ const contractHead = preparation.head(input.runId, input.ticket.id, admission.requirementsDigest);
680
+ return contractHead.state === "ready" && contractHead.digest ? preparation.contract(contractHead.digest).contentDigest : undefined;
681
+ }
682
+ function validateReplayBinding(db, input, prior) {
683
+ if (!prior || prior.runId !== input.runId || prior.ticketId !== input.ticket.id || prior.reviewAttemptId !== input.reviewAttemptId
684
+ || prior.reportDigest !== input.reportDigest || prior.generation !== input.remediationGeneration + 1
685
+ || prior.reviewedContentDigest !== input.reviewedSourceStateDigest || prior.reviewBasisDigest !== input.reviewBasisDigest) {
686
+ throw new Error("Replayed QA remediation handoff does not match the current review, source, or review basis");
687
+ }
688
+ if (input.contractDigest && currentPublishedContractDigest(db, input) !== input.contractDigest) {
689
+ throw new Error("Replayed QA remediation handoff has a stale or changed host-published contract binding");
690
+ }
691
+ if (prior.handoffDigest) {
692
+ const raw = db.getEvidence(prior.handoffDigest);
693
+ if (!raw)
694
+ throw new Error("Replayed QA remediation handoff is missing its durable request evidence");
695
+ const handoff = JSON.parse(raw.toString());
696
+ const chunk = handoff.remediationChunk;
697
+ const expectedBinding = input.contractDigest
698
+ ? { kind: "published-contract", digest: input.contractDigest }
699
+ : { kind: "review-basis", digest: input.reviewBasisDigest };
700
+ // Older durable handoffs predate chunk metadata. Their review/source/basis
701
+ // bindings were checked above; preserve idempotent recovery for those
702
+ // records, while requiring complete chunk metadata for new handoffs.
703
+ if (!chunk)
704
+ return;
705
+ const legacyChunk = chunk;
706
+ const storedBinding = chunk.contractBinding ?? (typeof legacyChunk.contractDigest === "string"
707
+ ? { kind: input.contractDigest ? "published-contract" : "review-basis", digest: legacyChunk.contractDigest }
708
+ : undefined);
709
+ if (chunk.sourceDigest !== input.reviewedSourceStateDigest || chunk.reviewBasisDigest !== input.reviewBasisDigest
710
+ || chunk.reviewAttemptId !== input.reviewAttemptId || storedBinding?.kind !== expectedBinding.kind || storedBinding?.digest !== expectedBinding.digest) {
711
+ throw new Error("Replayed QA remediation chunk binding is stale or incomplete");
712
+ }
713
+ }
714
+ }
639
715
  function validateReviewBinding(db, input) {
640
716
  const report = db.qaReport(input.reportDigest, { runId: input.runId, ticketId: input.ticket.id, reviewNumber: input.reviewNumber });
641
717
  const attempt = db.qaReviewAttempt(input.reviewAttemptId);
@@ -649,6 +725,11 @@ function validateReviewBinding(db, input) {
649
725
  || head.reviewBasisDigest !== input.reviewBasisDigest || !head.openReportDigests.includes(input.reportDigest)) {
650
726
  throw new Error("Builder remediation binding does not match the current failed review and open report occurrence");
651
727
  }
728
+ if (input.contractDigest) {
729
+ const currentContractDigest = currentPublishedContractDigest(db, input);
730
+ if (currentContractDigest !== input.contractDigest)
731
+ throw new Error("Builder remediation contract binding is stale or does not match the host-published QA contract");
732
+ }
652
733
  return head;
653
734
  }
654
735
  function canonicalEvidence(value) { return canonicalJson(JSON.parse(JSON.stringify(value))); }
@@ -0,0 +1,2 @@
1
+ /** A read-only configuration observation, not a graph scan or proof about external Graphify installations. */
2
+ export declare function qaHostGraphFact(projectDir: string): string;
@@ -0,0 +1,11 @@
1
+ import { loadGraphConfig } from "./graph/config.js";
2
+ /** A read-only configuration observation, not a graph scan or proof about external Graphify installations. */
3
+ export function qaHostGraphFact(projectDir) {
4
+ try {
5
+ const graph = loadGraphConfig(projectDir);
6
+ return `Host observation of Rafi-managed graph configuration: ${JSON.stringify({ adoption: graph.adoption ? "recorded" : "not-recorded", enabled: graph.enabled, reason: graph.reason })}. This describes only Rafi-managed graph adoption at observation time, not any external Graphify installation; assess applicable project rules and any evidence of external adoption separately.`;
7
+ }
8
+ catch {
9
+ return "Host observation of Rafi-managed graph configuration is unavailable; do not assume it is adopted or unadopted.";
10
+ }
11
+ }
@@ -1,19 +1,23 @@
1
- import type { QaContractCandidateV1, RequirementRef, QaVerificationContractV1 } from "rafi-spec";
1
+ import type { QaContractCandidateV1, QaSemanticAssessmentV1, RequirementRef, QaVerificationContractV1 } from "rafi-spec";
2
2
  import type { QaPreparationStore, LogicalPreparationBudget } from "./qaPreparationStore.js";
3
3
  export interface PreparationProviderResult {
4
4
  operationId?: string;
5
5
  text: string;
6
6
  sessionId: string;
7
7
  graphReceiptRefs?: string[];
8
+ workspacePaths?: Record<string, string>;
8
9
  usage?: Partial<LogicalPreparationBudget["usage"]>;
9
10
  }
10
11
  export interface PreparationDependencies {
11
12
  store: QaPreparationStore;
12
13
  now(): number;
14
+ /** Provider-specific wording is allowed; contract ownership is not. */
15
+ provider?: "claude" | "codex";
13
16
  /** Each dispatch is a fresh, confined conversation, with a persisted reservation. */
14
17
  dispatch(phase: "planner" | "prepare" | "assess" | "challenge" | "repair", instruction: string, operationId: string, remainingMs: number): Promise<PreparationProviderResult>;
15
18
  inputsCurrent(candidate: QaContractCandidateV1): boolean;
16
19
  normalizeDraft?(draft: QaContractCandidateV1, response: PreparationProviderResult): QaContractCandidateV1;
20
+ hostFacts?: string;
17
21
  }
18
22
  export type PreparationOutcome = {
19
23
  status: "ready";
@@ -23,4 +27,37 @@ export type PreparationOutcome = {
23
27
  detail: string;
24
28
  nextAction: string;
25
29
  };
30
+ export declare const FILE_SCOPE_GUIDANCE = "File lists in plans and tickets, including likely_files and generated file-only diff expectations, are estimates of implementation, not exhaustive boundaries. Different named files or an extra relevant file do not by themselves create a material conflict or block the build. Retain and assess every original requirement; for file-list checks verify that changes serve the approved work rather than requiring an exact file list or a pre-edit snapshot proving no other files changed. Rafi owns tracker lifecycle updates. Generated instructions to mark a ticket done in a document are bookkeeping, not a Builder acceptance criterion or a material conflict; do not require the Builder to perform them, and do not require the host to amend the plan before building. Do not disregard explicit user-established security, privacy, access, or other safety restrictions, or expand the approved product functionality. Report genuine substantive or safety conflicts.";
31
+ export declare const ROLLBACK_VERIFICATION_GUIDANCE = "When an original requirement explicitly asks to verify that rollback restores behavior, specify concrete future verification evidence rather than only inspecting rollback prose. A rollback plan alone does not require a rollback execution or mutation-testing rehearsal. For an npm test project where current uncommitted product changes represent the change to rehearse, the Builder may run rafi qa-rehearse-rollback alone from the project root; it runs npm test before and after reverting a synthetic commit of all uncommitted product changes in an independent temporary repository. It also runs git diff --exit-code against the captured pre-change HEAD after the revert and tests; success proves the tracked files match that baseline. For a requirement that a particular string be absent after rollback, inspecting its absence in the captured baseline plus that successful whole-tree comparison is concrete evidence of absence in the reverted tracked file. The rehearsal cannot use installed dependencies or symbolic links and does not prove ticket isolation or that an actual existing ticket commit was reverted. Assess whether this evidence satisfies the original requirement; do not claim it does when the original explicitly requires the actual ticket commit. Do not assume copying files to external scratch, arbitrary scripts or mutation experiments are allowed. If actual rollback execution is explicitly required but no permitted method satisfies it, report the limitation. Never perform destructive rollback in the source workspace or claim a rehearsal has already happened.";
32
+ export declare const EXECUTABLE_CHECK_GUIDANCE = "Choose verification procedures compatible with the Builder's project permissions and workspace. Documentation is disabled unless the host-bound contract documentation.required is true. When it is false, do not invent documentation checks merely because a docs directory or API-looking path exists; an absent documentation surface is not a failure. When it is true, use only the contract's exact targets and criteria, and define an actionable absent-target outcome. Do not invent mandatory inline node -e or node --eval commands: the Builder policy may refuse them. For a JavaScript behavior or export check, prefer a project-local test file executed with the project's existing test command, or a permitted node --test invocation. Do not invent a mandatory test-first RED phase or other historical sequence merely because a plan requires tests before and after implementation: a passing baseline test is not a failing new test. When an original requirement actually requires a historical sequence, preserve it and specify concrete independently reviewable evidence paths or retained host events for each required step; a generic statement that sequencing evidence exists is not actionable, and a later passing test does not prove past events. If the project policy makes raw stdout redirection or scratch-log creation unavailable, do not turn log-file capture into a blocker: use the retained bounded tool output and host events instead, and never cite a scratch path unless that exact file was successfully created and inspected. The independent QA snapshot may have a detached HEAD even when the Builder source workspace is on a branch; do not use its branch name to infer the Builder source branch. Diff and scope checks must compare the current snapshot with the captured pre-implementation baseline, not blindly with repository HEAD: previously approved or completed ticket changes are part of that baseline and must not be reported as new work. A scope check must first enumerate every changed path outside the explicit bookkeeping/evidence exclusions, then compare that complete host-observed set with the approved product/ticket scope; do not pre-filter the list to expected filenames, because that would hide accidental extra product edits. Bounded evidence-only paths such as scratch/ are not product scope and must be excluded from product-path scope checks while their retained evidence remains subject to QA review. For a current-branch multi-ticket build, do not invent a mandatory branch-alone execution check merely to prove ticket independence; use baseline-aware source/test inspection and the permitted project tests unless the original requirement explicitly requires an actual isolated execution. For additive tickets in a current-branch multi-ticket build, \u201Cacceptable on its own\u201D is satisfied by showing that each ticket's own tests import and exercise only its own feature, pass with the shared baseline and required project tests, and do not depend on the sibling feature; do not require removing another additive feature or perform a destructive rollback experiment unless the approved requirement explicitly requires absence testing or an isolated branch. Preserve explicitly requested procedures and substantive requirements; if a required procedure cannot be run, identify the limitation rather than claiming it was executed. Independently assess whether proposed evidence actually tests the required behavior.";
33
+ /** Baseline bookkeeping must not block ordinary approved implementation work. */
34
+ export declare const APPROVED_PATH_BASELINE_GUIDANCE = "Baseline membership is host-owned bookkeeping, not a Builder requirement. An approved product path, export, or test file is not a material QA concern merely because the provider cannot prove whether it was present before implementation. Do not reconstruct or disclose the full baseline, and do not turn that uncertainty into an unresolved concern. Rafi performs the exact host comparison. Do not author a provider-executed check that asks for Rafi's host postimplementation path manifest, complete changed-path inventory, or unchanged-file comparison; that host-owned comparison is already performed outside the provider snapshot and must be represented by the retained host observation, not by raw manifest disclosure or a provider check. For current-branch additive tickets, a provider-authored or inferred request to test the branch with an already-completed sibling feature removed is not an applicable requirement when the approved scope says not to remove or reconstruct that sibling; verify the ticket's own behavior and tests against the shared baseline instead. Treat sibling-absence testing as binding only when the user explicitly approved that absence requirement. Escalate only an actual host-observed out-of-scope, destructive, protected-file, or requirement-relevant change.";
35
+ /** Ignore known non-authoritative annotations; the original provider response remains retained. */
36
+ export declare function normalizeAssessmentMetadata<T extends QaSemanticAssessmentV1>(assessment: T): T;
37
+ /** Accept only an exact known obligation label when a provider wraps it in a
38
+ * descriptive object. This is a representation repair, not a host decision:
39
+ * unknown or ambiguous objects remain unchanged and fail schema validation. */
40
+ export declare function normalizeAssessmentObligations<T extends QaSemanticAssessmentV1>(assessment: T, allowed: string[]): T;
41
+ /** A preparation assessor must not block on the expected absence of future
42
+ * Builder work. Keep the concern for auditability, but make it non-material
43
+ * only when every referenced check is postimplementation and the concern is
44
+ * explicitly asking the Builder to implement/rerun that check. Concerns tied
45
+ * to preimplementation checks, missing procedures, or other semantic gaps
46
+ * remain blocking. */
47
+ export declare function normalizeExpectedFutureAssessment<T extends QaSemanticAssessmentV1>(assessment: T, candidate: QaContractCandidateV1): T;
48
+ /**
49
+ * A mandatory requirement must have at least one mandatory verification check.
50
+ * Providers occasionally return a concrete check with the weaker advisory
51
+ * label. Promote the existing covering check at the host boundary; never
52
+ * invent a check, evidence, or requirement, and let the normal validator still
53
+ * enforce readiness and independent-QA requirements for the promoted check.
54
+ */
55
+ export declare function enforceMandatoryCoverage(candidate: QaContractCandidateV1): QaContractCandidateV1;
56
+ /**
57
+ * Codex occasionally appends a made-up requirement ID to an otherwise valid
58
+ * check. Remove only those extraneous annotations when the check still has an
59
+ * exact authoritative reference. Never invent or remap an ID, and leave a
60
+ * check with no valid references untouched so normal validation fails closed.
61
+ */
62
+ export declare function removeExtraneousRequirementReferences(candidate: QaContractCandidateV1, inventory: RequirementRef[]): QaContractCandidateV1;
26
63
  export declare function prepareVerificationContract(initial: QaContractCandidateV1, inventory: RequirementRef[], deps: PreparationDependencies): Promise<PreparationOutcome>;