@bastani/atomic 0.9.16-alpha.6 → 0.9.16-alpha.8
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.
- package/CHANGELOG.md +19 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/broker/broker.ts +617 -22
- package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
- package/dist/builtin/intercom/broker/client.ts +200 -10
- package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
- package/dist/builtin/intercom/broker/send-handler.ts +90 -36
- package/dist/builtin/intercom/broker/send-signature.ts +20 -8
- package/dist/builtin/intercom/group.ts +85 -0
- package/dist/builtin/intercom/index.bundle.mjs +680 -53
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/session-target.ts +54 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
- package/dist/builtin/intercom/source-ownership.ts +31 -0
- package/dist/builtin/intercom/types.ts +115 -0
- package/dist/builtin/mcp/index.bundle.mjs +109 -35
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/qlty/SKILL.md +123 -0
- package/dist/builtin/subagents/skills/qlty/references/coding-with-ai-agents.md +64 -0
- package/dist/builtin/subagents/skills/qlty/references/commands.md +291 -0
- package/dist/builtin/subagents/skills/qlty/references/plugins-and-extensions.md +228 -0
- package/dist/builtin/subagents/skills/qlty/references/quickstart.md +110 -0
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +173 -51
- package/dist/builtin/web-access/index.bundle.mjs +109 -35
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +23 -0
- package/dist/builtin/workflows/README.md +40 -37
- package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
- package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +137 -133
- package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
- package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
- package/dist/builtin/workflows/builtin/chunk-5n10x7j2.js +69730 -0
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
- package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
- package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
- package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
- package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
- package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
- package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
- package/dist/builtin/workflows/builtin/chunk-cdtd3m3w.js +529 -0
- package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
- package/dist/builtin/workflows/builtin/chunk-hdpj1dkw.js +2447 -0
- package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
- package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
- package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
- package/dist/builtin/workflows/builtin/chunk-v04c5qmd.js +1207 -0
- package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
- package/dist/builtin/workflows/builtin/chunk-zf28603f.js +1080 -0
- package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
- package/dist/builtin/workflows/builtin/goal.js +16 -0
- package/dist/builtin/workflows/builtin/index.js +49 -0
- package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
- package/dist/builtin/workflows/builtin/ralph.js +16 -0
- package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
- package/dist/builtin/workflows/builtin/steering-context.js +7 -0
- package/dist/builtin/workflows/builtin/tournament.js +13 -0
- package/dist/builtin/workflows/package.json +10 -7
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1250 -428
- package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +956 -427
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
- package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +12 -5
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-install-layout.d.ts +1 -1
- package/dist/core/builtin-install-layout.d.ts.map +1 -1
- package/dist/core/builtin-install-layout.js +1 -1
- package/dist/core/builtin-install-layout.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +10 -7
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +31 -13
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +35 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +4 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -1
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +8 -9
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +33 -5
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/intercom.md +15 -6
- package/docs/packages.md +2 -2
- package/docs/providers.md +8 -3
- package/docs/quickstart.md +3 -2
- package/docs/rpc.md +21 -4
- package/docs/settings.md +6 -4
- package/docs/skills.md +4 -0
- package/docs/subagents.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows.md +112 -239
- package/npm-shrinkwrap.json +32 -32
- package/package.json +9 -13
- package/dist/builtin/workflows/ambient.d.ts +0 -61
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
- package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
- package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
- package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
- package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -211
- package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
- package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
- package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
- package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
- package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
- package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
- package/dist/builtin/workflows/builtin/goal.ts +0 -78
- package/dist/builtin/workflows/builtin/index.ts +0 -16
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
- package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
- package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
- package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
- package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -455
- package/dist/builtin/workflows/builtin/ralph.ts +0 -82
- package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
- package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
- package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
- package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
- package/dist/builtin/workflows/builtin/tournament.ts +0 -73
- package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
- package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
- package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { Type } from "typebox";
|
|
2
|
-
import type {
|
|
3
|
-
WorkflowRunContext,
|
|
4
|
-
WorkflowSerializableValue,
|
|
5
|
-
WorkflowTaskResult,
|
|
6
|
-
} from "../src/shared/types.js";
|
|
7
|
-
import {
|
|
8
|
-
build_scoring_prompt,
|
|
9
|
-
scoring_prompt_reads,
|
|
10
|
-
type ScoringCandidate,
|
|
11
|
-
type SharedHead,
|
|
12
|
-
} from "./verification-prompts.js";
|
|
13
|
-
import { VERIFICATION_SCALE } from "./verification-criteria.js";
|
|
14
|
-
import type {
|
|
15
|
-
ConsolidatableFinding,
|
|
16
|
-
ConsolidatedFinding,
|
|
17
|
-
} from "./review-convergence.js";
|
|
18
|
-
|
|
19
|
-
/** Confidence values strictly below this threshold can enter re-verification. */
|
|
20
|
-
export const DEFAULT_REVERIFY_THRESHOLD = 0.7;
|
|
21
|
-
|
|
22
|
-
const STANDARD_CONFIRM_THRESHOLD = 10;
|
|
23
|
-
const REQUIRED_CONFIRM_THRESHOLD = 6;
|
|
24
|
-
const DEFAULT_REPEATS = 3;
|
|
25
|
-
const REVERIFY_QUESTION =
|
|
26
|
-
"Assess this specific finding against the code it cites: is it a real, objective-relevant, currently-unresolved blocker?";
|
|
27
|
-
|
|
28
|
-
/** The finding fields needed by the re-verification door. */
|
|
29
|
-
export type ReverifiableFinding = ConsolidatableFinding & {
|
|
30
|
-
readonly body?: string;
|
|
31
|
-
readonly confidence_score?: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type ReverifiableConsolidatedFinding = ConsolidatedFinding<ReverifiableFinding>;
|
|
35
|
-
|
|
36
|
-
export type ReverifyResult = {
|
|
37
|
-
readonly verdict: "confirmed" | "demoted";
|
|
38
|
-
readonly meanScore: number;
|
|
39
|
-
readonly perRepeat: readonly (number | null)[];
|
|
40
|
-
readonly evidence: readonly string[];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/** Audit evidence retained alongside the original consolidated finding. */
|
|
44
|
-
export type ReverifyAuditEntry<F extends ReverifiableFinding = ReverifiableFinding> = {
|
|
45
|
-
readonly finding: ConsolidatedFinding<F>;
|
|
46
|
-
readonly verdict: ReverifyResult["verdict"];
|
|
47
|
-
readonly meanScore: number;
|
|
48
|
-
readonly perRepeat: readonly (number | null)[];
|
|
49
|
-
readonly evidence: readonly string[];
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type ReverifyContext = Pick<WorkflowRunContext, "task">;
|
|
53
|
-
|
|
54
|
-
export type ReverifyBatchResult<F extends ReverifiableFinding = ReverifiableFinding> = {
|
|
55
|
-
readonly batch: readonly ConsolidatedFinding<F>[];
|
|
56
|
-
readonly audits: readonly ReverifyAuditEntry<F>[];
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export type ReverifyBatchInput<F extends ReverifiableFinding = ReverifiableFinding> = {
|
|
60
|
-
readonly batch: readonly ConsolidatedFinding<F>[];
|
|
61
|
-
readonly context: {
|
|
62
|
-
readonly objective: string;
|
|
63
|
-
readonly candidateRefs: readonly string[];
|
|
64
|
-
};
|
|
65
|
-
readonly repeats?: number;
|
|
66
|
-
readonly threshold?: number;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const reverifySchema = Type.Object(
|
|
70
|
-
{
|
|
71
|
-
score: VERIFICATION_SCALE.schema,
|
|
72
|
-
evidence: Type.Array(Type.String()),
|
|
73
|
-
},
|
|
74
|
-
{ additionalProperties: false },
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
type ReverifyReport = {
|
|
78
|
-
readonly score: number;
|
|
79
|
-
readonly evidence: readonly string[];
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
function isRecord(value: WorkflowSerializableValue | undefined): value is Record<string, WorkflowSerializableValue> {
|
|
83
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function isStringArray(value: WorkflowSerializableValue | undefined): value is readonly string[] {
|
|
87
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function parseReport(result: WorkflowTaskResult): ReverifyReport | undefined {
|
|
91
|
-
if (!isRecord(result.structured)) return undefined;
|
|
92
|
-
const score = result.structured.score;
|
|
93
|
-
if (
|
|
94
|
-
typeof score !== "number" ||
|
|
95
|
-
!Number.isInteger(score) ||
|
|
96
|
-
score < VERIFICATION_SCALE.min ||
|
|
97
|
-
score > VERIFICATION_SCALE.max
|
|
98
|
-
) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
101
|
-
const evidence = result.structured.evidence;
|
|
102
|
-
return {
|
|
103
|
-
score,
|
|
104
|
-
evidence: isStringArray(evidence) ? evidence : [],
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function requiredByObjective(finding: ReverifiableConsolidatedFinding): boolean {
|
|
109
|
-
return finding.finding.objective_alignment === "required_by_objective";
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Pure eligibility predicate. Missing confidence is deliberately ineligible:
|
|
114
|
-
* an absent graded signal is doubt, and doubt remains blocking.
|
|
115
|
-
*/
|
|
116
|
-
export function is_reverifiable(
|
|
117
|
-
finding: ReverifiableConsolidatedFinding,
|
|
118
|
-
threshold = DEFAULT_REVERIFY_THRESHOLD,
|
|
119
|
-
): boolean {
|
|
120
|
-
const confidence = finding.finding.confidence_score;
|
|
121
|
-
return (
|
|
122
|
-
finding.blocking &&
|
|
123
|
-
finding.reviewers.length === 1 &&
|
|
124
|
-
typeof confidence === "number" &&
|
|
125
|
-
Number.isFinite(confidence) &&
|
|
126
|
-
confidence < threshold &&
|
|
127
|
-
finding.finding.objective_alignment !== "beyond_objective" &&
|
|
128
|
-
finding.finding.objective_alignment !== "contradicts_objective"
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function readPaths(
|
|
133
|
-
finding: ReverifiableConsolidatedFinding,
|
|
134
|
-
candidateRefs: readonly string[],
|
|
135
|
-
): readonly string[] {
|
|
136
|
-
const codePath = finding.finding.code_location?.absolute_file_path;
|
|
137
|
-
return [
|
|
138
|
-
...(codePath === undefined ? [] : [codePath]),
|
|
139
|
-
...candidateRefs,
|
|
140
|
-
];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function promptFor(
|
|
144
|
-
finding: ReverifiableConsolidatedFinding,
|
|
145
|
-
context: ReverifyBatchInput["context"],
|
|
146
|
-
): { readonly prompt: string; readonly reads: readonly string[] } {
|
|
147
|
-
const codePath = finding.finding.code_location?.absolute_file_path;
|
|
148
|
-
const candidate: ScoringCandidate = {
|
|
149
|
-
...(codePath === undefined ? {} : { path: codePath }),
|
|
150
|
-
body: [
|
|
151
|
-
`Title: ${finding.finding.title}`,
|
|
152
|
-
`Body: ${finding.finding.body ?? ""}`,
|
|
153
|
-
`Code location: ${codePath ?? "not supplied"}`,
|
|
154
|
-
].join("\n"),
|
|
155
|
-
};
|
|
156
|
-
const head: SharedHead = {
|
|
157
|
-
task: `${REVERIFY_QUESTION}\n\nObjective:\n${context.objective}`,
|
|
158
|
-
groundTruthNote: `The objective is the contract. Verify the finding against observed code, not reviewer narration.`,
|
|
159
|
-
candidates: [candidate],
|
|
160
|
-
outputFormat: "Call structured_output with score (an integer from 1 to 20) and evidence (an array of observed, concise reasons).",
|
|
161
|
-
};
|
|
162
|
-
const prompt = build_scoring_prompt(head, {
|
|
163
|
-
id: "finding_reverification",
|
|
164
|
-
name: "Finding re-verification",
|
|
165
|
-
description: REVERIFY_QUESTION,
|
|
166
|
-
});
|
|
167
|
-
return {
|
|
168
|
-
prompt,
|
|
169
|
-
reads: [
|
|
170
|
-
...readPaths(finding, context.candidateRefs),
|
|
171
|
-
...scoring_prompt_reads(head),
|
|
172
|
-
],
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
async function runRepeat(
|
|
177
|
-
ctx: ReverifyContext,
|
|
178
|
-
finding: ReverifiableConsolidatedFinding,
|
|
179
|
-
context: ReverifyBatchInput["context"],
|
|
180
|
-
stageName: string,
|
|
181
|
-
): Promise<ReverifyReport | undefined> {
|
|
182
|
-
try {
|
|
183
|
-
const rendered = promptFor(finding, context);
|
|
184
|
-
const options = {
|
|
185
|
-
prompt: rendered.prompt,
|
|
186
|
-
context: "fresh" as const,
|
|
187
|
-
reads: rendered.reads,
|
|
188
|
-
schema: reverifySchema,
|
|
189
|
-
};
|
|
190
|
-
return parseReport(await ctx.task(stageName, options));
|
|
191
|
-
} catch {
|
|
192
|
-
return undefined;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Re-score one eligible finding in K independent fresh contexts.
|
|
198
|
-
*
|
|
199
|
-
* A zero-valid-repeat mean is the deterministic sentinel `0`, matching the
|
|
200
|
-
* verification criteria module's empty-mean convention. It never authorizes a
|
|
201
|
-
* demotion because the quorum checks below require at least one valid score.
|
|
202
|
-
*/
|
|
203
|
-
export async function reverify_finding(
|
|
204
|
-
ctx: ReverifyContext,
|
|
205
|
-
input: {
|
|
206
|
-
readonly finding: ReverifiableConsolidatedFinding;
|
|
207
|
-
readonly context: {
|
|
208
|
-
readonly objective: string;
|
|
209
|
-
readonly candidateRefs: readonly string[];
|
|
210
|
-
};
|
|
211
|
-
repeats?: number;
|
|
212
|
-
threshold?: number;
|
|
213
|
-
},
|
|
214
|
-
): Promise<ReverifyResult> {
|
|
215
|
-
if (!is_reverifiable(input.finding, input.threshold)) {
|
|
216
|
-
throw new Error("Cannot re-verify an ineligible finding.");
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const repeatCount = Number.isFinite(input.repeats) && input.repeats !== undefined
|
|
220
|
-
? Math.max(0, Math.floor(input.repeats))
|
|
221
|
-
: DEFAULT_REPEATS;
|
|
222
|
-
const perRepeat: Array<number | null> = [];
|
|
223
|
-
const evidence: string[] = [];
|
|
224
|
-
const validScores: number[] = [];
|
|
225
|
-
for (let repeat = 1; repeat <= repeatCount; repeat += 1) {
|
|
226
|
-
let report = await runRepeat(ctx, input.finding, input.context, `reverify-${repeat}`);
|
|
227
|
-
if (report === undefined) {
|
|
228
|
-
report = await runRepeat(ctx, input.finding, input.context, `reverify-${repeat}-reask`);
|
|
229
|
-
}
|
|
230
|
-
if (report === undefined) {
|
|
231
|
-
perRepeat.push(null);
|
|
232
|
-
evidence.push(
|
|
233
|
-
`Re-verification repeat ${repeat} was invalid after one re-ask; doubt defaults to confirmed.`,
|
|
234
|
-
);
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
perRepeat.push(report.score);
|
|
238
|
-
validScores.push(report.score);
|
|
239
|
-
if (report.evidence.length === 0) {
|
|
240
|
-
evidence.push(`Re-verification repeat ${repeat} scored ${report.score}/20.`);
|
|
241
|
-
} else {
|
|
242
|
-
evidence.push(...report.evidence);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const meanScore = validScores.length === 0
|
|
247
|
-
? 0
|
|
248
|
-
: validScores.reduce((total, score) => total + score, 0) / validScores.length;
|
|
249
|
-
const validCount = validScores.length;
|
|
250
|
-
const requiredQuorum = Math.ceil(repeatCount / 2);
|
|
251
|
-
const demoted = requiredByObjective(input.finding)
|
|
252
|
-
? repeatCount > 0 && validCount === repeatCount && meanScore < REQUIRED_CONFIRM_THRESHOLD
|
|
253
|
-
: validCount > 0 && validCount >= requiredQuorum && meanScore < STANDARD_CONFIRM_THRESHOLD;
|
|
254
|
-
return {
|
|
255
|
-
verdict: demoted ? "demoted" : "confirmed",
|
|
256
|
-
meanScore,
|
|
257
|
-
perRepeat,
|
|
258
|
-
evidence,
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function auditKey<F extends ReverifiableFinding>(finding: ConsolidatedFinding<F>): string {
|
|
263
|
-
return JSON.stringify([
|
|
264
|
-
finding.finding.code_location?.absolute_file_path ?? "",
|
|
265
|
-
finding.finding.title,
|
|
266
|
-
finding.reviewers,
|
|
267
|
-
]);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/** Apply only evidence-backed demotions; the original finding remains present. */
|
|
271
|
-
export function apply_reverify_results<F extends ReverifiableFinding>(
|
|
272
|
-
batch: readonly ConsolidatedFinding<F>[],
|
|
273
|
-
audits: readonly ReverifyAuditEntry<F>[],
|
|
274
|
-
): ReverifyBatchResult<F> {
|
|
275
|
-
const demoted = new Set(
|
|
276
|
-
audits
|
|
277
|
-
.filter((audit) => audit.verdict === "demoted")
|
|
278
|
-
.map((audit) => auditKey(audit.finding)),
|
|
279
|
-
);
|
|
280
|
-
return {
|
|
281
|
-
batch: batch.map((entry) =>
|
|
282
|
-
demoted.has(auditKey(entry)) ? { ...entry, blocking: false } : entry,
|
|
283
|
-
),
|
|
284
|
-
audits,
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** Re-verify only eligible entries and return the batch plus durable audit data. */
|
|
289
|
-
export async function reverify_consolidated_batch<F extends ReverifiableFinding>(
|
|
290
|
-
ctx: ReverifyContext,
|
|
291
|
-
input: ReverifyBatchInput<F>,
|
|
292
|
-
): Promise<ReverifyBatchResult<F>> {
|
|
293
|
-
const audits: ReverifyAuditEntry<F>[] = [];
|
|
294
|
-
for (const entry of input.batch) {
|
|
295
|
-
if (!is_reverifiable(entry, input.threshold)) continue;
|
|
296
|
-
const result = await reverify_finding(ctx, {
|
|
297
|
-
finding: entry,
|
|
298
|
-
context: input.context,
|
|
299
|
-
repeats: input.repeats,
|
|
300
|
-
threshold: input.threshold,
|
|
301
|
-
});
|
|
302
|
-
audits.push({ finding: entry, ...result });
|
|
303
|
-
}
|
|
304
|
-
return apply_reverify_results(input.batch, audits);
|
|
305
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { WorkflowTaskResult } from "../src/shared/types.js";
|
|
2
|
-
import type { ReviewDecision, ReviewRecord } from "./goal-types.js";
|
|
3
|
-
import {
|
|
4
|
-
finalActionRemaining,
|
|
5
|
-
parseFailureDiagnostics,
|
|
6
|
-
summarizeReviewConvergence,
|
|
7
|
-
type ParsedReviewDecision,
|
|
8
|
-
} from "./review-convergence.js";
|
|
9
|
-
|
|
10
|
-
export function reviewDecisionFromResult(result: WorkflowTaskResult): ReviewDecision | undefined {
|
|
11
|
-
return result.structured as ReviewDecision | undefined;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function parsedReviewDecisionFromResult(
|
|
15
|
-
result: WorkflowTaskResult,
|
|
16
|
-
reviewer: string,
|
|
17
|
-
): ParsedReviewDecision<ReviewDecision> {
|
|
18
|
-
const parsed = reviewDecisionFromResult(result);
|
|
19
|
-
if (parsed !== undefined) {
|
|
20
|
-
return { decision: parsed, parsed: true, diagnostics: [] };
|
|
21
|
-
}
|
|
22
|
-
const diagnostics = parseFailureDiagnostics(reviewer, result.text);
|
|
23
|
-
return {
|
|
24
|
-
decision: reviewerErrorDecision(diagnostics.join("\n")),
|
|
25
|
-
parsed: false,
|
|
26
|
-
diagnostics,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Deterministic single-reviewer approval gate.
|
|
32
|
-
*
|
|
33
|
-
* The reviewer's self-reported `stop_review_loop` boolean is the single
|
|
34
|
-
* authoritative convergence signal: the harness does not recompute approval
|
|
35
|
-
* from findings arrays, priorities, or requirements_traceability statuses.
|
|
36
|
-
* Those fields remain required audit evidence for humans and later stages,
|
|
37
|
-
* and the reviewer prompt instructs the model how to derive the flag from
|
|
38
|
-
* them — but the gate itself trusts the boolean.
|
|
39
|
-
*
|
|
40
|
-
* Two hard guards remain: a reviewer execution failure (`reviewer_error`)
|
|
41
|
-
* never approves, and unparsed reviewer output is synthesized upstream as a
|
|
42
|
-
* `stop_review_loop: false` decision, so parse failures never approve either.
|
|
43
|
-
*/
|
|
44
|
-
export function reviewApproved(decision: ReviewDecision): boolean {
|
|
45
|
-
return decision.stop_review_loop === true && decision.reviewer_error == null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function reviewerErrorDecision(message: string): ReviewDecision {
|
|
49
|
-
return {
|
|
50
|
-
findings: [],
|
|
51
|
-
overall_correctness: "patch is incorrect",
|
|
52
|
-
overall_explanation:
|
|
53
|
-
"Reviewer execution failed, so the review gate cannot safely approve the current repository state.",
|
|
54
|
-
overall_confidence_score: 0,
|
|
55
|
-
goal_oracle_satisfied: false,
|
|
56
|
-
requirements_traceability: [],
|
|
57
|
-
receipt_assessment:
|
|
58
|
-
"No reviewer receipt could be produced because reviewer execution failed.",
|
|
59
|
-
verification_remaining: "Recover reviewer execution and re-run oracle validation.",
|
|
60
|
-
stop_review_loop: false,
|
|
61
|
-
reviewer_error: {
|
|
62
|
-
kind: "reviewer_failure",
|
|
63
|
-
message,
|
|
64
|
-
attempted_recovery:
|
|
65
|
-
"Model fallbacks were configured for the reviewer stage; continuing the bounded loop without approval.",
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function blockerFromReviewDecision(decision: ReviewDecision): string | null {
|
|
71
|
-
const reviewerError = decision.reviewer_error;
|
|
72
|
-
if (reviewerError == null) return null;
|
|
73
|
-
if (
|
|
74
|
-
reviewerError.kind !== "dependency_unavailable" &&
|
|
75
|
-
reviewerError.kind !== "tool_failure"
|
|
76
|
-
) {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const blocker = reviewerError.message.trim();
|
|
80
|
-
return blocker.length > 0 ? blocker : null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function reviewDecisionToRecord(args: {
|
|
84
|
-
readonly turn: number;
|
|
85
|
-
readonly reviewer: string;
|
|
86
|
-
readonly artifactPath: string;
|
|
87
|
-
readonly decision: ReviewDecision;
|
|
88
|
-
readonly parsed: boolean;
|
|
89
|
-
readonly diagnostics: readonly string[];
|
|
90
|
-
readonly allowFinalActionRemaining: boolean;
|
|
91
|
-
}): ReviewRecord {
|
|
92
|
-
const blocker = blockerFromReviewDecision(args.decision);
|
|
93
|
-
const approved = reviewApproved(args.decision);
|
|
94
|
-
const hasFinalActionRemaining = args.allowFinalActionRemaining &&
|
|
95
|
-
finalActionRemaining(args.decision.requirements_traceability);
|
|
96
|
-
const verificationGap = args.decision.verification_remaining.trim();
|
|
97
|
-
const traceabilityGaps = args.decision.requirements_traceability
|
|
98
|
-
.filter((entry) => entry.status !== "proven")
|
|
99
|
-
.map((entry) => `${entry.status}: ${entry.requirement} — ${entry.evidence}`);
|
|
100
|
-
const gaps = [
|
|
101
|
-
...args.decision.findings.map((finding) =>
|
|
102
|
-
`[${finding.objective_alignment}] ${finding.title}: ${finding.body}`
|
|
103
|
-
),
|
|
104
|
-
...traceabilityGaps,
|
|
105
|
-
...(approved || verificationGap.length === 0 ? [] : [verificationGap]),
|
|
106
|
-
...(args.decision.reviewer_error == null
|
|
107
|
-
? []
|
|
108
|
-
: [`${args.decision.reviewer_error.kind}: ${args.decision.reviewer_error.message}`]),
|
|
109
|
-
];
|
|
110
|
-
|
|
111
|
-
const nextAction = approved
|
|
112
|
-
? hasFinalActionRemaining ? "pull-request" : "finish"
|
|
113
|
-
: blocker === null ? "implementation" : "blocked";
|
|
114
|
-
const convergenceDecision = summarizeReviewConvergence({
|
|
115
|
-
parsed: args.parsed,
|
|
116
|
-
approved,
|
|
117
|
-
stopReviewLoop: args.decision.stop_review_loop,
|
|
118
|
-
nextAction,
|
|
119
|
-
finalActionRemaining: approved && hasFinalActionRemaining,
|
|
120
|
-
diagnostics: args.diagnostics,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
...args.decision,
|
|
125
|
-
decision: approved ? "complete" : blocker === null ? "continue" : "blocked",
|
|
126
|
-
evidence: [args.decision.receipt_assessment, args.decision.overall_explanation],
|
|
127
|
-
gaps,
|
|
128
|
-
blocker,
|
|
129
|
-
confidence_score: args.decision.overall_confidence_score,
|
|
130
|
-
explanation: args.decision.overall_explanation,
|
|
131
|
-
turn: args.turn,
|
|
132
|
-
reviewer: args.reviewer,
|
|
133
|
-
artifact_path: args.artifactPath,
|
|
134
|
-
parsed: args.parsed,
|
|
135
|
-
approved,
|
|
136
|
-
parse_diagnostics: args.diagnostics,
|
|
137
|
-
convergence_decision: convergenceDecision,
|
|
138
|
-
};
|
|
139
|
-
}
|