audit-tools 0.55.14 → 0.55.16
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/dist/audit/cli/auditStep.d.ts.map +1 -1
- package/dist/audit/cli/auditStep.js +4 -3
- package/dist/audit/cli/auditStep.js.map +1 -1
- package/dist/audit/cli/charterComparisonPrompt.d.ts.map +1 -1
- package/dist/audit/cli/charterComparisonPrompt.js +8 -1
- package/dist/audit/cli/charterComparisonPrompt.js.map +1 -1
- package/dist/audit/cli/conceptualDispatch.d.ts.map +1 -1
- package/dist/audit/cli/conceptualDispatch.js +9 -5
- package/dist/audit/cli/conceptualDispatch.js.map +1 -1
- package/dist/audit/cli/confirmIntentStep.d.ts.map +1 -1
- package/dist/audit/cli/confirmIntentStep.js +25 -11
- package/dist/audit/cli/confirmIntentStep.js.map +1 -1
- package/dist/audit/cli/dispatch/hostHandoff.d.ts +65 -1
- package/dist/audit/cli/dispatch/hostHandoff.d.ts.map +1 -1
- package/dist/audit/cli/dispatch/hostHandoff.js +329 -126
- package/dist/audit/cli/dispatch/hostHandoff.js.map +1 -1
- package/dist/audit/cli/fanoutLanes.d.ts +1 -1
- package/dist/audit/cli/fanoutLanes.d.ts.map +1 -1
- package/dist/audit/cli/fanoutLanes.js +4 -2
- package/dist/audit/cli/fanoutLanes.js.map +1 -1
- package/dist/audit/cli/functionalPreflight.d.ts.map +1 -1
- package/dist/audit/cli/functionalPreflight.js +5 -1
- package/dist/audit/cli/functionalPreflight.js.map +1 -1
- package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
- package/dist/audit/cli/nextStepCommand.js +17 -15
- package/dist/audit/cli/nextStepCommand.js.map +1 -1
- package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
- package/dist/audit/cli/nextStepHelpers.js +4 -3
- package/dist/audit/cli/nextStepHelpers.js.map +1 -1
- package/dist/audit/cli/prompts.d.ts +2 -0
- package/dist/audit/cli/prompts.d.ts.map +1 -1
- package/dist/audit/cli/prompts.js +21 -3
- package/dist/audit/cli/prompts.js.map +1 -1
- package/dist/audit/cli/semanticReviewStep.d.ts.map +1 -1
- package/dist/audit/cli/semanticReviewStep.js +71 -6
- package/dist/audit/cli/semanticReviewStep.js.map +1 -1
- package/dist/audit/cli/validateResultsCommand.d.ts +11 -0
- package/dist/audit/cli/validateResultsCommand.d.ts.map +1 -1
- package/dist/audit/cli/validateResultsCommand.js +56 -4
- package/dist/audit/cli/validateResultsCommand.js.map +1 -1
- package/dist/audit/decompose/buildStructureDecomposition.d.ts +11 -5
- package/dist/audit/decompose/buildStructureDecomposition.d.ts.map +1 -1
- package/dist/audit/decompose/buildStructureDecomposition.js +17 -8
- package/dist/audit/decompose/buildStructureDecomposition.js.map +1 -1
- package/dist/audit/extractors/analyzers/complexityDuplication.d.ts +50 -10
- package/dist/audit/extractors/analyzers/complexityDuplication.d.ts.map +1 -1
- package/dist/audit/extractors/analyzers/complexityDuplication.js +175 -27
- package/dist/audit/extractors/analyzers/complexityDuplication.js.map +1 -1
- package/dist/audit/extractors/designAssessment.d.ts.map +1 -1
- package/dist/audit/extractors/designAssessment.js +186 -143
- package/dist/audit/extractors/designAssessment.js.map +1 -1
- package/dist/audit/extractors/docsDigest.d.ts.map +1 -1
- package/dist/audit/extractors/docsDigest.js +6 -0
- package/dist/audit/extractors/docsDigest.js.map +1 -1
- package/dist/audit/extractors/flows.d.ts +9 -5
- package/dist/audit/extractors/flows.d.ts.map +1 -1
- package/dist/audit/extractors/flows.js +59 -9
- package/dist/audit/extractors/flows.js.map +1 -1
- package/dist/audit/extractors/graph.d.ts +8 -1
- package/dist/audit/extractors/graph.d.ts.map +1 -1
- package/dist/audit/extractors/graph.js +16 -6
- package/dist/audit/extractors/graph.js.map +1 -1
- package/dist/audit/extractors/graphSignals.d.ts +9 -1
- package/dist/audit/extractors/graphSignals.d.ts.map +1 -1
- package/dist/audit/extractors/graphSignals.js +12 -1
- package/dist/audit/extractors/graphSignals.js.map +1 -1
- package/dist/audit/extractors/pathPatterns.d.ts +5 -0
- package/dist/audit/extractors/pathPatterns.d.ts.map +1 -1
- package/dist/audit/extractors/pathPatterns.js +47 -3
- package/dist/audit/extractors/pathPatterns.js.map +1 -1
- package/dist/audit/extractors/risk.d.ts.map +1 -1
- package/dist/audit/extractors/risk.js +3 -6
- package/dist/audit/extractors/risk.js.map +1 -1
- package/dist/audit/io/runArtifacts.d.ts +6 -0
- package/dist/audit/io/runArtifacts.d.ts.map +1 -1
- package/dist/audit/io/runArtifacts.js +9 -0
- package/dist/audit/io/runArtifacts.js.map +1 -1
- package/dist/audit/orchestrator/advance.d.ts.map +1 -1
- package/dist/audit/orchestrator/advance.js +3 -0
- package/dist/audit/orchestrator/advance.js.map +1 -1
- package/dist/audit/orchestrator/architectureDiscovery.d.ts +9 -0
- package/dist/audit/orchestrator/architectureDiscovery.d.ts.map +1 -1
- package/dist/audit/orchestrator/architectureDiscovery.js +11 -1
- package/dist/audit/orchestrator/architectureDiscovery.js.map +1 -1
- package/dist/audit/orchestrator/artifactMetadata.d.ts.map +1 -1
- package/dist/audit/orchestrator/artifactMetadata.js +7 -0
- package/dist/audit/orchestrator/artifactMetadata.js.map +1 -1
- package/dist/audit/orchestrator/charterPackets.d.ts +36 -7
- package/dist/audit/orchestrator/charterPackets.d.ts.map +1 -1
- package/dist/audit/orchestrator/charterPackets.js +88 -21
- package/dist/audit/orchestrator/charterPackets.js.map +1 -1
- package/dist/audit/orchestrator/dependencyMap.d.ts.map +1 -1
- package/dist/audit/orchestrator/dependencyMap.js +21 -13
- package/dist/audit/orchestrator/dependencyMap.js.map +1 -1
- package/dist/audit/orchestrator/dependencySlices.d.ts.map +1 -1
- package/dist/audit/orchestrator/dependencySlices.js +26 -11
- package/dist/audit/orchestrator/dependencySlices.js.map +1 -1
- package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
- package/dist/audit/orchestrator/designReviewPrompt.js +107 -9
- package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
- package/dist/audit/orchestrator/ingestionExecutors.d.ts.map +1 -1
- package/dist/audit/orchestrator/ingestionExecutors.js +8 -4
- package/dist/audit/orchestrator/ingestionExecutors.js.map +1 -1
- package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/intentCheckpointExecutor.js +43 -24
- package/dist/audit/orchestrator/intentCheckpointExecutor.js.map +1 -1
- package/dist/audit/orchestrator/planningExecutors.d.ts.map +1 -1
- package/dist/audit/orchestrator/planningExecutors.js +3 -3
- package/dist/audit/orchestrator/planningExecutors.js.map +1 -1
- package/dist/audit/orchestrator/runtimeValidation.d.ts +6 -0
- package/dist/audit/orchestrator/runtimeValidation.d.ts.map +1 -1
- package/dist/audit/orchestrator/runtimeValidation.js +26 -0
- package/dist/audit/orchestrator/runtimeValidation.js.map +1 -1
- package/dist/audit/orchestrator/state.d.ts.map +1 -1
- package/dist/audit/orchestrator/state.js +4 -2
- package/dist/audit/orchestrator/state.js.map +1 -1
- package/dist/audit/orchestrator/structureExecutors.d.ts.map +1 -1
- package/dist/audit/orchestrator/structureExecutors.js +2 -1
- package/dist/audit/orchestrator/structureExecutors.js.map +1 -1
- package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts +9 -0
- package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/systemicChallengeExecutor.js +12 -2
- package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -1
- package/dist/audit/systemic/reviewFileMap.d.ts +92 -45
- package/dist/audit/systemic/reviewFileMap.d.ts.map +1 -1
- package/dist/audit/systemic/reviewFileMap.js +171 -94
- package/dist/audit/systemic/reviewFileMap.js.map +1 -1
- package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts +15 -6
- package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts.map +1 -1
- package/dist/audit/systemic/secondOrderAdversaryPrompt.js +119 -36
- package/dist/audit/systemic/secondOrderAdversaryPrompt.js.map +1 -1
- package/dist/audit/types/artifactMetadata.d.ts +2 -0
- package/dist/audit/types/artifactMetadata.d.ts.map +1 -1
- package/dist/audit/types/designAssessment.d.ts +11 -0
- package/dist/audit/types/designAssessment.d.ts.map +1 -1
- package/dist/audit/types/designAssessment.js +23 -1
- package/dist/audit/types/designAssessment.js.map +1 -1
- package/dist/shared/analyzers/acquisitionEngine.d.ts +18 -0
- package/dist/shared/analyzers/acquisitionEngine.d.ts.map +1 -1
- package/dist/shared/analyzers/acquisitionEngine.js +19 -1
- package/dist/shared/analyzers/acquisitionEngine.js.map +1 -1
- package/dist/shared/analyzers/candidates.d.ts.map +1 -1
- package/dist/shared/analyzers/candidates.js +103 -7
- package/dist/shared/analyzers/candidates.js.map +1 -1
- package/dist/shared/decompose/charterExtraction.d.ts +117 -17
- package/dist/shared/decompose/charterExtraction.d.ts.map +1 -1
- package/dist/shared/decompose/charterExtraction.js +27 -3
- package/dist/shared/decompose/charterExtraction.js.map +1 -1
- package/dist/shared/decompose/systemicChallenge.d.ts.map +1 -1
- package/dist/shared/decompose/systemicChallenge.js +4 -1
- package/dist/shared/decompose/systemicChallenge.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/prompts.js +1 -1
- package/dist/shared/prompts.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@ import { ActiveReviewRunSchema } from "../../contracts/wrapperResponse.js";
|
|
|
3
3
|
import { sourceTreeInstruction } from "../../io/runSnapshot.js";
|
|
4
4
|
import { CURRENT_TASK_FILENAME } from "../../supervisor/operatorHandoff.js";
|
|
5
5
|
import { mkdir } from "node:fs/promises";
|
|
6
|
-
import { join } from "node:path";
|
|
6
|
+
import { join, relative, resolve } from "node:path";
|
|
7
7
|
import { lensDefinition } from "../../types.js";
|
|
8
|
-
import { createMemoizedSourceReader, enumerateTrackedFilePaths, deriveLaneDemand, appendSubmissionEvent, assertSubmissionRunId, SUBMISSION_LEDGER_EVENT_CONTRACT_VERSION, bindingIdentity, compareCodeUnits, contentSha256, firstDuplicateIdentity, hasExactKeys, hostHandoffResultPath, identityFailureDiagnostic, isFileMissingError, isJsonParseError, isRecord, isSha256, LaneDemandSchema, parseAllWorkloadItems, parseWorkloadEnvelope, bindWorkerPrompt, deriveResultId, workerPromptBindingHolds, enrichMissingSubmissionIssues, readTrailingSubmissionRefusals, readJsonFile, repoRelativePath, requireNonEmptyString, resolveContainedPath, resolveHostHandoffPaths, resultMapIdentity, scanBoundSubmission, siblingLockPath, sameStrings, stableStringify, groundFinding, withFileLock, writeBlockedStepContract, writeJsonFile, } from "audit-tools/shared";
|
|
8
|
+
import { createMemoizedSourceReader, enumerateTrackedFilePaths, deriveLaneDemand, appendSubmissionEvent, assertSubmissionRunId, SUBMISSION_LEDGER_EVENT_CONTRACT_VERSION, bindingIdentity, compareCodeUnits, contentSha256, firstDuplicateIdentity, hasExactKeys, hostHandoffResultPath, identityFailureDiagnostic, isFileMissingError, isJsonParseError, isRecord, isSha256, LaneDemandSchema, parseAllWorkloadItems, parseWorkloadEnvelope, bindWorkerPrompt, deriveResultId, workerPromptBindingHolds, enrichMissingSubmissionIssues, readTrailingSubmissionRefusals, readJsonFile, repoRelativePath, requireNonEmptyString, resolveContainedPath, resolveHostHandoffPaths, resultMapIdentity, scanBoundSubmission, siblingLockPath, sameStrings, stableStringify, groundFinding, withFileLock, writeBlockedStepContract, writeJsonFile, toPosixPath, } from "audit-tools/shared";
|
|
9
9
|
import { findingContractPromptLines } from "../../contracts/findingContractPrompt.js";
|
|
10
10
|
import { WORKER_REFUSED_FINDING_VERDICTS, WORKER_REFUSED_LOCATION_FIELDS, WorkerFindingSchema, } from "../../contracts/workerSchemas.js";
|
|
11
11
|
import { AuditResultSchema, AuditTaskSchema, } from "../../types.js";
|
|
@@ -14,7 +14,7 @@ import { validateOneAuditResult, formatAuditResultIssues,
|
|
|
14
14
|
// `validateVerification` build their allowed set through the same function, so
|
|
15
15
|
// they cannot disagree about which `file_paths` entries are inside the packet.
|
|
16
16
|
verificationAllowedPaths, normalizeCoveragePath, } from "../../validation/auditResults.js";
|
|
17
|
-
import { reviewWaveClosedPath } from "../../io/runArtifacts.js";
|
|
17
|
+
import { hostCoherenceGroupsPath, reviewWaveClosedPath } from "../../io/runArtifacts.js";
|
|
18
18
|
// The lane token itself is single-sourced where the steward lane is minted:
|
|
19
19
|
// `LENS_VERIFICATION_TAG` (`orchestrator/selectiveDeepening/shared.ts`). Every
|
|
20
20
|
// reader compiles against that one declaration, so a rename moves them together
|
|
@@ -22,6 +22,8 @@ import { reviewWaveClosedPath } from "../../io/runArtifacts.js";
|
|
|
22
22
|
// is what a hand-copied literal here produced, twice (this boundary and the
|
|
23
23
|
// audit-results validator).
|
|
24
24
|
import { LENS_VERIFICATION_TAG, } from "../../orchestrator/selectiveDeepening/shared.js";
|
|
25
|
+
import { buildTaskAffinityGraph } from "../../orchestrator/taskAffinityGraph.js";
|
|
26
|
+
import { buildTaskCoherencePartition } from "../../orchestrator/partitionTaskGraph.js";
|
|
25
27
|
// v1alpha2 (the emitted-lane demand ranking): each work item's `metadata`
|
|
26
28
|
// carries the shared `demand` ranking (size / complexity / risk) beside its
|
|
27
29
|
// token estimate, in place of the retired `{complexity, risk}` pair whose
|
|
@@ -44,7 +46,12 @@ import { LENS_VERIFICATION_TAG, } from "../../orchestrator/selectiveDeepening/sh
|
|
|
44
46
|
// the result template, its identity values filled in by the tool, and the
|
|
45
47
|
// prompt digest covers the text ABOVE that template. A v1alpha3 document refuses
|
|
46
48
|
// closed as stale — the same `next-step` re-prepares it.
|
|
47
|
-
|
|
49
|
+
//
|
|
50
|
+
// v1alpha5 (the 0.55.15 self-audit): the prompt and its result template name
|
|
51
|
+
// the result path ABSOLUTE, so the persisted template a work item is checked
|
|
52
|
+
// against changed shape. A v1alpha4 document refuses closed as stale — the same
|
|
53
|
+
// `next-step` re-prepares it.
|
|
54
|
+
const WORKLOAD_CONTRACT_VERSION = "audit-host-workload/v1alpha5";
|
|
48
55
|
const RESULT_MAP_CONTRACT_VERSION = "audit-host-result-map/v1alpha1";
|
|
49
56
|
const RESULT_CONTRACT_VERSION = "audit-host-result/v1alpha1";
|
|
50
57
|
/**
|
|
@@ -366,7 +373,26 @@ function isVerificationLane(tags) {
|
|
|
366
373
|
* identity values; the worker fills `file_coverage` and `findings`. The digest
|
|
367
374
|
* it states is the digest of the prompt text ABOVE it (see `bindWorkerPrompt`).
|
|
368
375
|
*/
|
|
369
|
-
|
|
376
|
+
/**
|
|
377
|
+
* The result path as a worker is told it: ABSOLUTE and forward-slashed. The
|
|
378
|
+
* persisted `result_path` is repository-relative (it is the binding's identity),
|
|
379
|
+
* and a relative path in a prompt resolves against whatever directory the
|
|
380
|
+
* worker runs in — a worker launched in its own directory wrote somewhere the
|
|
381
|
+
* ingest never reads. Stated absolute, the instruction is cwd-independent.
|
|
382
|
+
*/
|
|
383
|
+
function workerResultPath(root, resultPath) {
|
|
384
|
+
// The drive letter is case-insensitive on every system that has one, so it is
|
|
385
|
+
// folded to ONE spelling: a run prepared as `c:/repo` and resumed as
|
|
386
|
+
// `C:/repo` must re-render the identical prompt, or its digest — and every
|
|
387
|
+
// result bound to it — would go stale for no change at all. A root that
|
|
388
|
+
// really moved still re-renders differently, and that binding failure is
|
|
389
|
+
// classified `workload_stale` (see `AuditHostBindingError`): the fold
|
|
390
|
+
// re-prepares under the new root.
|
|
391
|
+
return toPosixPath(resolve(root, resultPath)).replace(/^[a-z](?=:)/u, (letter) => letter.toUpperCase());
|
|
392
|
+
}
|
|
393
|
+
function renderResultTemplate(runId, workItemId,
|
|
394
|
+
/** Absolute, from {@link workerResultPath}. */
|
|
395
|
+
resultPath, promptDigest) {
|
|
370
396
|
const template = {
|
|
371
397
|
contract_version: RESULT_CONTRACT_VERSION,
|
|
372
398
|
result_id: deriveResultId(workItemId, promptDigest),
|
|
@@ -432,11 +458,17 @@ function buildPrompt(task, resultPath, workloadPath, sourceRoot) {
|
|
|
432
458
|
// THE DESTINATION FIRST, on its own line. It used to be one field inside a
|
|
433
459
|
// single long JSON blob, which buries the one fact a reader must not have to
|
|
434
460
|
// search for: a result written anywhere else is never ingested.
|
|
435
|
-
|
|
461
|
+
// ABSOLUTE (`workerResultPath`): the worker's working directory is the
|
|
462
|
+
// host's choice, so no path here may depend on it.
|
|
463
|
+
`Write one JSON object to this exact absolute path: ${resultPath}`,
|
|
436
464
|
// WHERE TO READ, stated rather than left to the host's working directory:
|
|
437
465
|
// the run audits a frozen snapshot, and the live tree may have moved since
|
|
438
466
|
// the run started. Line counts and cited text are checked against this tree.
|
|
439
467
|
sourceTreeInstruction(sourceRoot),
|
|
468
|
+
// WHAT ELSE TO WRITE: nothing. Workers in the self-audit wrote scratch
|
|
469
|
+
// files to the OS temp directory and stalled on the permission prompt each
|
|
470
|
+
// one raised; the work needs no file but the result.
|
|
471
|
+
"Write no other file: no scratch, temporary or helper file anywhere. Both paths above are absolute and do not depend on your working directory.",
|
|
440
472
|
// LANE-AWARE, because "review every listed file" is true of the base lane
|
|
441
473
|
// and false of a steward under selective coverage — whose whole task is to
|
|
442
474
|
// decide what is worth opening.
|
|
@@ -634,9 +666,10 @@ function verificationContractFailure(verification, binding, envelope) {
|
|
|
634
666
|
}
|
|
635
667
|
function buildWorkItem(paths, task) {
|
|
636
668
|
const resultPath = resultPathFor(paths, task.task_id);
|
|
669
|
+
const promptResultPath = workerResultPath(paths.root, resultPath);
|
|
637
670
|
// The SAME path the caller writes the workload to, so a selective lane is told
|
|
638
671
|
// where its surface actually is rather than where it is expected to be.
|
|
639
|
-
const prompt = bindWorkerPrompt(buildPrompt(task,
|
|
672
|
+
const prompt = bindWorkerPrompt(buildPrompt(task, promptResultPath, paths.workloadPath, boundarySourceRoot(paths)), (digest) => renderResultTemplate(paths.runId, task.task_id, promptResultPath, digest));
|
|
640
673
|
return {
|
|
641
674
|
id: task.task_id,
|
|
642
675
|
lens: task.lens,
|
|
@@ -805,11 +838,20 @@ export async function prepareAuditHostHandoff(params) {
|
|
|
805
838
|
await writeAcceptedResults(paths, accepted);
|
|
806
839
|
await writeJsonFile(paths.workloadPath, workload);
|
|
807
840
|
await writeJsonFile(paths.resultMapPath, resultMap);
|
|
841
|
+
const coherenceGroups = {
|
|
842
|
+
contract_version: COHERENCE_GROUPS_CONTRACT_VERSION,
|
|
843
|
+
run_id: params.runId,
|
|
844
|
+
groups: coherenceGroupsFor(allWorkItems, params.coherenceGroups),
|
|
845
|
+
};
|
|
846
|
+
const coherenceGroupsPath = hostCoherenceGroupsPath(params.artifactsDir, params.runId);
|
|
847
|
+
await writeJsonFile(coherenceGroupsPath, coherenceGroups);
|
|
808
848
|
return {
|
|
809
849
|
workload,
|
|
810
850
|
result_map: resultMap,
|
|
811
851
|
workload_path: paths.workloadPath,
|
|
812
852
|
result_map_path: paths.resultMapPath,
|
|
853
|
+
coherence_groups: coherenceGroups,
|
|
854
|
+
coherence_groups_path: coherenceGroupsPath,
|
|
813
855
|
};
|
|
814
856
|
});
|
|
815
857
|
}
|
|
@@ -825,7 +867,7 @@ export async function prepareAuditHostHandoff(params) {
|
|
|
825
867
|
function isSurfaceFileMetrics(value) {
|
|
826
868
|
return AuditTaskSchema.shape.file_metrics.safeParse(value).success;
|
|
827
869
|
}
|
|
828
|
-
function parseWorkItem(value, runId) {
|
|
870
|
+
function parseWorkItem(value, runId, root) {
|
|
829
871
|
// `file_metrics` is the ONE optional scope key: a selective (steward) lane
|
|
830
872
|
// carries it, every complete lane omits it. It is added to the expected set
|
|
831
873
|
// only when the document supplies it, exactly as the result envelope treats
|
|
@@ -854,7 +896,7 @@ function parseWorkItem(value, runId) {
|
|
|
854
896
|
!hasExactKeys(value.prompt, ["sha256", "text"]) ||
|
|
855
897
|
!isSha256(value.prompt.sha256) ||
|
|
856
898
|
typeof value.prompt.text !== "string" ||
|
|
857
|
-
!workerPromptBindingHolds({ text: value.prompt.text, sha256: value.prompt.sha256 }, (digest) => renderResultTemplate(runId, value.id, value.result_path, digest)) ||
|
|
899
|
+
!workerPromptBindingHolds({ text: value.prompt.text, sha256: value.prompt.sha256 }, (digest) => renderResultTemplate(runId, value.id, workerResultPath(root, value.result_path), digest)) ||
|
|
858
900
|
!isRecord(value.scope) ||
|
|
859
901
|
!hasExactKeys(value.scope, [
|
|
860
902
|
"files",
|
|
@@ -942,7 +984,7 @@ class StaleAuditHostTaskBindingsError extends Error {
|
|
|
942
984
|
this.name = "StaleAuditHostTaskBindingsError";
|
|
943
985
|
}
|
|
944
986
|
}
|
|
945
|
-
function parseWorkload(value, runId) {
|
|
987
|
+
function parseWorkload(value, runId, root) {
|
|
946
988
|
// Envelope + all-items parsing is the CORE's scaffolding; the audit draw
|
|
947
989
|
// selects only its own contract version and item parser.
|
|
948
990
|
const envelope = parseWorkloadEnvelope(value, {
|
|
@@ -962,7 +1004,7 @@ function parseWorkload(value, runId) {
|
|
|
962
1004
|
}
|
|
963
1005
|
throw bindingFailure("workload_binding", "Invalid audit host workload");
|
|
964
1006
|
}
|
|
965
|
-
const workItems = parseAllWorkloadItems(envelope.rawItems, (raw) => parseWorkItem(raw, runId));
|
|
1007
|
+
const workItems = parseAllWorkloadItems(envelope.rawItems, (raw) => parseWorkItem(raw, runId, root));
|
|
966
1008
|
if (workItems === null) {
|
|
967
1009
|
throw bindingFailure("workload_binding", "Invalid audit host work item");
|
|
968
1010
|
}
|
|
@@ -1112,7 +1154,7 @@ export async function readPublishedAuditTaskIds(params) {
|
|
|
1112
1154
|
let items;
|
|
1113
1155
|
let bindings;
|
|
1114
1156
|
try {
|
|
1115
|
-
const workload = parseWorkload(await readJsonFile(paths.workloadPath), paths.runId);
|
|
1157
|
+
const workload = parseWorkload(await readJsonFile(paths.workloadPath), paths.runId, paths.root);
|
|
1116
1158
|
const resultMap = parseResultMap(await readJsonFile(paths.resultMapPath), paths.runId);
|
|
1117
1159
|
bindings = parseTaskBindings(await readJsonFile(paths.taskBindingsPath), paths.runId);
|
|
1118
1160
|
items = validateHandoffBinding(paths, workload, resultMap, bindings);
|
|
@@ -1462,6 +1504,260 @@ function evictInvalidatedEntries(loaded, params) {
|
|
|
1462
1504
|
});
|
|
1463
1505
|
return { kept: { ...loaded, entries: kept }, issues };
|
|
1464
1506
|
}
|
|
1507
|
+
/**
|
|
1508
|
+
* The ONE judgment of one bound submission: read it at its bound path, parse
|
|
1509
|
+
* the envelope against its binding, convert it, ground its cited text, and put
|
|
1510
|
+
* it through the per-result validator. Ingestion ACCEPTS on `ok`; the
|
|
1511
|
+
* read-only check ({@link checkAuditHostResult}) only reports — so a host that
|
|
1512
|
+
* checks a result before ingestion is told exactly what ingestion would say.
|
|
1513
|
+
*/
|
|
1514
|
+
async function judgeAuditHostSubmission(params) {
|
|
1515
|
+
const { paths, entry, item, binding } = params;
|
|
1516
|
+
const outcome = await scanBoundSubmission({
|
|
1517
|
+
root: paths.root,
|
|
1518
|
+
artifactsDir: paths.artifactsDir,
|
|
1519
|
+
workItemId: entry.work_item_id,
|
|
1520
|
+
resultPath: entry.result_path,
|
|
1521
|
+
parse: (value) => {
|
|
1522
|
+
const parsed = parseHostResult(value, paths.runId, item, binding);
|
|
1523
|
+
return parsed.ok ? { ok: true, parsed: parsed.result } : parsed;
|
|
1524
|
+
},
|
|
1525
|
+
resultId: (result) => result.result_id,
|
|
1526
|
+
seen: params.seen,
|
|
1527
|
+
messages: auditScanMessages(entry.work_item_id),
|
|
1528
|
+
});
|
|
1529
|
+
if (!outcome.ok)
|
|
1530
|
+
return { ok: false, issue: outcome.issue };
|
|
1531
|
+
const result = outcome.parsed;
|
|
1532
|
+
const converted = toAuditResult(result, binding);
|
|
1533
|
+
if (!converted.ok) {
|
|
1534
|
+
return {
|
|
1535
|
+
ok: false,
|
|
1536
|
+
issue: {
|
|
1537
|
+
code: "submission_contract_invalid",
|
|
1538
|
+
check: "result_schema",
|
|
1539
|
+
message: `work item '${entry.work_item_id}' submitted a result that does not convert to ` +
|
|
1540
|
+
`an AuditResult: ${converted.detail}`,
|
|
1541
|
+
work_item_id: entry.work_item_id,
|
|
1542
|
+
result_path: entry.result_path,
|
|
1543
|
+
},
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
// S7 quote-and-verify: the tool re-reads each cited span from disk, stamps
|
|
1547
|
+
// the verdict, and writes each entry's line numbers from where its quote
|
|
1548
|
+
// occurs. It NEVER rejects — a quote that is absent or occurs more than
|
|
1549
|
+
// once rides through as `ungrounded` and synthesis surfaces it under
|
|
1550
|
+
// "Ungrounded Findings (not confirmed)"; refusing here would discard the
|
|
1551
|
+
// whole submission over one bad citation. It mutates the CONVERTED copy
|
|
1552
|
+
// only: `result` stays the host's submission, which `result_sha256` hashes.
|
|
1553
|
+
// It runs BEFORE validation, so the derived span meets the same coverage
|
|
1554
|
+
// rule here that the downstream batch gate applies: a span that rule would
|
|
1555
|
+
// refuse is refused while the item can still be resubmitted, never
|
|
1556
|
+
// accepted and then replayed into a failing gate on every later step.
|
|
1557
|
+
for (const finding of converted.auditResult.findings) {
|
|
1558
|
+
await groundFinding(boundarySourceRoot(paths), finding, params.readSource, await params.knownPaths());
|
|
1559
|
+
}
|
|
1560
|
+
// VALIDATE BEFORE ACCEPT. The conversion above proves only the envelope
|
|
1561
|
+
// contract (`FindingSchema` admits an evidence-less finding); these are the
|
|
1562
|
+
// per-result rules the downstream batch gate applies, applied HERE so an
|
|
1563
|
+
// error-severity issue never reaches the accepted pair. A rejected item is
|
|
1564
|
+
// simply never in the ledger, so the corrected file at the same bound path
|
|
1565
|
+
// is re-read on the next fold — acceptance used to be terminal instead, and
|
|
1566
|
+
// a failed batch gate then wedged the run permanently.
|
|
1567
|
+
//
|
|
1568
|
+
// Orphans (task pruned by a re-plan) pass through UNVALIDATED with the same
|
|
1569
|
+
// stderr notice the batch gate uses — never newly rejected: refusing one
|
|
1570
|
+
// here would strand it outside the append-only ledger entirely.
|
|
1571
|
+
if (!params.activeTaskIds.has(entry.work_item_id)) {
|
|
1572
|
+
process.stderr.write(`audit host-handoff ingest: result for '${entry.work_item_id}' is not in the ` +
|
|
1573
|
+
`active task manifest (orphaned by re-planning); retained in the accepted pair ` +
|
|
1574
|
+
`but skipped at the validation gate\n`);
|
|
1575
|
+
return { ok: true, result, auditResult: converted.auditResult, warnings: [] };
|
|
1576
|
+
}
|
|
1577
|
+
const validationIssues = validateOneAuditResult(converted.auditResult, [...params.auditTasks], {
|
|
1578
|
+
lineIndex: params.lineIndex,
|
|
1579
|
+
});
|
|
1580
|
+
const errors = validationIssues.filter((issue) => issue.severity === "error");
|
|
1581
|
+
if (errors.length > 0) {
|
|
1582
|
+
return {
|
|
1583
|
+
ok: false,
|
|
1584
|
+
issue: {
|
|
1585
|
+
code: "result_validation_failed",
|
|
1586
|
+
check: "result_validation",
|
|
1587
|
+
message: `work item '${entry.work_item_id}' failed audit-results validation ` +
|
|
1588
|
+
`(${errors.length} error(s)); fix the result file at its bound path and call next-step again: ` +
|
|
1589
|
+
formatAuditResultIssues(errors),
|
|
1590
|
+
work_item_id: entry.work_item_id,
|
|
1591
|
+
result_path: entry.result_path,
|
|
1592
|
+
},
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
// Warnings are NOT rejections: an accepted result never refused anything,
|
|
1596
|
+
// so a warning must never reach the rejection-classified issue list — the
|
|
1597
|
+
// ONE ledger recorder would otherwise record kind:'rejected' for a result
|
|
1598
|
+
// that was accepted, manufacturing a repair story that never happened.
|
|
1599
|
+
// They ride the separate advisory channel instead (rendered for the
|
|
1600
|
+
// operator; never counted as a submission that could not be accepted).
|
|
1601
|
+
const warnings = validationIssues
|
|
1602
|
+
.filter((issue) => issue.severity === "warning")
|
|
1603
|
+
.map((warning) => ({
|
|
1604
|
+
work_item_id: entry.work_item_id,
|
|
1605
|
+
result_path: entry.result_path,
|
|
1606
|
+
message: `${warning.message} (${warning.field})`,
|
|
1607
|
+
}));
|
|
1608
|
+
return { ok: true, result, auditResult: converted.auditResult, warnings };
|
|
1609
|
+
}
|
|
1610
|
+
/**
|
|
1611
|
+
* The run's published binding set — workload, result map, task bindings — read
|
|
1612
|
+
* and cross-checked, or the CLASSIFIED refusal ingestion reports for it. One
|
|
1613
|
+
* reader for both doors, so the read-only check refuses a stale or corrupt set
|
|
1614
|
+
* exactly as ingestion does, never as a stack. Infrastructure failures stay
|
|
1615
|
+
* strict.
|
|
1616
|
+
*/
|
|
1617
|
+
async function readHandoffBindingSet(paths) {
|
|
1618
|
+
try {
|
|
1619
|
+
const workload = parseWorkload(await readJsonFile(paths.workloadPath), paths.runId, paths.root);
|
|
1620
|
+
const resultMap = parseResultMap(await readJsonFile(paths.resultMapPath), paths.runId);
|
|
1621
|
+
const taskBindings = parseTaskBindings(await readJsonFile(paths.taskBindingsPath), paths.runId);
|
|
1622
|
+
const items = validateHandoffBinding(paths, workload, resultMap, taskBindings);
|
|
1623
|
+
return { ok: true, resultMap, taskBindings, items };
|
|
1624
|
+
}
|
|
1625
|
+
catch (error) {
|
|
1626
|
+
if (error instanceof StaleAuditHostWorkloadError ||
|
|
1627
|
+
error instanceof StaleAuditHostTaskBindingsError ||
|
|
1628
|
+
error instanceof AuditHostBindingError)
|
|
1629
|
+
return { ok: false, refusal: error };
|
|
1630
|
+
if (isJsonParseError(error)) {
|
|
1631
|
+
return { ok: false, refusal: new AuditHostBindingError("workload_binding", error.message) };
|
|
1632
|
+
}
|
|
1633
|
+
throw error;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Judge one host result file by the rules ingestion applies, WITHOUT accepting
|
|
1638
|
+
* it: nothing is written, no lock is held, the ledger is only read. The run is
|
|
1639
|
+
* named by where the file lives (`<artifacts>/runs/<run id>/host-results/…`),
|
|
1640
|
+
* and the file must be the bound result path of one of that run's work items.
|
|
1641
|
+
*/
|
|
1642
|
+
export async function checkAuditHostResult(params) {
|
|
1643
|
+
const absolute = resolve(params.resultPath);
|
|
1644
|
+
const segments = toPosixPath(relative(resolve(params.artifactsDir, "runs"), absolute)).split("/");
|
|
1645
|
+
if (segments.length !== 3 || segments[1] !== "host-results" || segments[0] === "..") {
|
|
1646
|
+
throw new Error(`${toPosixPath(absolute)} is not a bound host result path. A semantic-review result is written at the ` +
|
|
1647
|
+
"`result_path` its work item binds in the published host-workload.json, under " +
|
|
1648
|
+
`${toPosixPath(join(resolve(params.artifactsDir), "runs", "<run id>", "host-results"))}/; ` +
|
|
1649
|
+
"write it there and validate that file.");
|
|
1650
|
+
}
|
|
1651
|
+
const runId = segments[0];
|
|
1652
|
+
const paths = resolveBoundaryPaths({
|
|
1653
|
+
root: params.root,
|
|
1654
|
+
sourceRoot: params.sourceRoot,
|
|
1655
|
+
artifactsDir: params.artifactsDir,
|
|
1656
|
+
runId,
|
|
1657
|
+
});
|
|
1658
|
+
let bindingSet;
|
|
1659
|
+
try {
|
|
1660
|
+
bindingSet = await readHandoffBindingSet(paths);
|
|
1661
|
+
}
|
|
1662
|
+
catch (error) {
|
|
1663
|
+
if (!isFileMissingError(error))
|
|
1664
|
+
throw error;
|
|
1665
|
+
throw new Error(`run ${runId} has no published workload (${toPosixPath(paths.workloadPath)} is missing); ` +
|
|
1666
|
+
"run next-step to publish one, then write each result at the result_path it binds.");
|
|
1667
|
+
}
|
|
1668
|
+
if (!bindingSet.ok) {
|
|
1669
|
+
// The SAME classified refusal ingestion reports for this binding set.
|
|
1670
|
+
return {
|
|
1671
|
+
run_id: runId,
|
|
1672
|
+
already_accepted: false,
|
|
1673
|
+
issues: [{ code: bindingSet.refusal.code, check: bindingSet.refusal.check, message: bindingSet.refusal.message }],
|
|
1674
|
+
validation_warnings: [],
|
|
1675
|
+
};
|
|
1676
|
+
}
|
|
1677
|
+
const { resultMap, taskBindings, items } = bindingSet;
|
|
1678
|
+
const entry = resultMap.entries.find((candidate) => resolve(paths.root, candidate.result_path) === absolute);
|
|
1679
|
+
const item = entry === undefined ? undefined : items.get(entry.work_item_id);
|
|
1680
|
+
const binding = entry === undefined ? undefined : taskBindings.get(entry.work_item_id);
|
|
1681
|
+
if (entry === undefined || item === undefined || binding === undefined) {
|
|
1682
|
+
throw new Error(`${toPosixPath(absolute)} is not the bound result path of any work item in run ${runId}. ` +
|
|
1683
|
+
`Each work item in ${toPosixPath(paths.workloadPath)} names its own result_path; write the result there and validate that file.`);
|
|
1684
|
+
}
|
|
1685
|
+
const accepted = await loadAcceptedResults(paths.acceptedLedgerPath, runId);
|
|
1686
|
+
const alreadyAccepted = accepted.entries.some((candidate) => bindingIdentity(candidate) === bindingIdentity(entry));
|
|
1687
|
+
// An accepted binding's own id is not a duplicate of itself: the check judges
|
|
1688
|
+
// the bytes, and says separately that ingestion will not re-read them.
|
|
1689
|
+
const otherIds = new Set(accepted.entries
|
|
1690
|
+
.filter((candidate) => candidate.work_item_id !== entry.work_item_id)
|
|
1691
|
+
.map((candidate) => candidate.result_id));
|
|
1692
|
+
let knownPaths;
|
|
1693
|
+
const judged = await judgeAuditHostSubmission({
|
|
1694
|
+
paths,
|
|
1695
|
+
entry,
|
|
1696
|
+
item,
|
|
1697
|
+
binding,
|
|
1698
|
+
seen: (resultId) => otherIds.has(resultId),
|
|
1699
|
+
activeTaskIds: new Set(params.auditTasks.map((task) => task.task_id)),
|
|
1700
|
+
auditTasks: params.auditTasks,
|
|
1701
|
+
lineIndex: params.lineIndex,
|
|
1702
|
+
readSource: createMemoizedSourceReader(),
|
|
1703
|
+
knownPaths: async () => (knownPaths ??= await enumerateTrackedFilePaths(boundarySourceRoot(paths))),
|
|
1704
|
+
});
|
|
1705
|
+
return {
|
|
1706
|
+
run_id: runId,
|
|
1707
|
+
work_item_id: entry.work_item_id,
|
|
1708
|
+
result_path: entry.result_path,
|
|
1709
|
+
already_accepted: alreadyAccepted,
|
|
1710
|
+
issues: judged.ok ? [] : [judged.issue],
|
|
1711
|
+
validation_warnings: judged.ok ? judged.warnings : [],
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
1714
|
+
/** The set-level scheduling facts beside a published workload. */
|
|
1715
|
+
const COHERENCE_GROUPS_CONTRACT_VERSION = "audit-host-coherence-groups/v1alpha1";
|
|
1716
|
+
/**
|
|
1717
|
+
* The groups to publish: the caller's, which must partition EXACTLY the
|
|
1718
|
+
* published items (a group naming an unpublished item, or an item in no group,
|
|
1719
|
+
* would describe a different publish), or one singleton per item.
|
|
1720
|
+
*/
|
|
1721
|
+
function coherenceGroupsFor(items, supplied) {
|
|
1722
|
+
if (supplied === undefined) {
|
|
1723
|
+
return items.map((item) => ({
|
|
1724
|
+
id: item.id,
|
|
1725
|
+
work_item_ids: [item.id],
|
|
1726
|
+
token_estimate: item.metadata.token_estimate,
|
|
1727
|
+
}));
|
|
1728
|
+
}
|
|
1729
|
+
const members = supplied.flatMap((group) => group.work_item_ids).sort(compareCodeUnits);
|
|
1730
|
+
const published = items.map((item) => item.id);
|
|
1731
|
+
if (stableStringify(members) !== stableStringify(published)) {
|
|
1732
|
+
throw new Error("audit host coherence groups do not partition the published work items exactly");
|
|
1733
|
+
}
|
|
1734
|
+
return supplied;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Content-coherence groups over the work items a wave PUBLISHES: the shared
|
|
1738
|
+
* task-draw partition (`buildTaskCoherencePartition`) of the affinity graph
|
|
1739
|
+
* built from exactly those tasks. Items in one group share files, a unit, a
|
|
1740
|
+
* flow, a directory or graph adjacency, so one lane taking them together reads
|
|
1741
|
+
* each file once.
|
|
1742
|
+
*
|
|
1743
|
+
* SET-LEVEL, deliberately, and never a field on a work item: a group is a
|
|
1744
|
+
* property of the whole published set, so on an item it would rewrite that
|
|
1745
|
+
* item whenever a peer is added or accepted — and an unchanged published item
|
|
1746
|
+
* must re-publish byte-identical. Metadata only: order, grouping and
|
|
1747
|
+
* parallelism stay the host's choice.
|
|
1748
|
+
*/
|
|
1749
|
+
export function buildAuditHostCoherenceGroups(tasks, graphBundle) {
|
|
1750
|
+
const partition = tasks.length === 0
|
|
1751
|
+
? { packets: [] }
|
|
1752
|
+
: buildTaskCoherencePartition(buildTaskAffinityGraph(tasks, graphBundle === undefined ? {} : { graphBundle }));
|
|
1753
|
+
const groups = partition.packets
|
|
1754
|
+
.map((packet) => {
|
|
1755
|
+
const ids = [...packet.task_ids].sort(compareCodeUnits);
|
|
1756
|
+
return { id: ids[0], work_item_ids: ids, token_estimate: packet.token_estimate };
|
|
1757
|
+
})
|
|
1758
|
+
.sort((left, right) => compareCodeUnits(left.id, right.id));
|
|
1759
|
+
return groups;
|
|
1760
|
+
}
|
|
1465
1761
|
export async function ingestAuditHostResults(params) {
|
|
1466
1762
|
const paths = resolveBoundaryPaths(params);
|
|
1467
1763
|
return withAcceptedResultsLock(paths, params.logger, async (loaded) => {
|
|
@@ -1497,27 +1793,10 @@ export async function ingestAuditHostResults(params) {
|
|
|
1497
1793
|
raw_issues: [...evictionIssues(), error],
|
|
1498
1794
|
validation_warnings: [],
|
|
1499
1795
|
});
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
try {
|
|
1505
|
-
workload = parseWorkload(await readJsonFile(paths.workloadPath), params.runId);
|
|
1506
|
-
resultMap = parseResultMap(await readJsonFile(paths.resultMapPath), params.runId);
|
|
1507
|
-
taskBindings = parseTaskBindings(await readJsonFile(paths.taskBindingsPath), params.runId);
|
|
1508
|
-
items = validateHandoffBinding(paths, workload, resultMap, taskBindings);
|
|
1509
|
-
}
|
|
1510
|
-
catch (error) {
|
|
1511
|
-
if (error instanceof StaleAuditHostWorkloadError ||
|
|
1512
|
-
error instanceof StaleAuditHostTaskBindingsError ||
|
|
1513
|
-
error instanceof AuditHostBindingError)
|
|
1514
|
-
return stale(error);
|
|
1515
|
-
if (isJsonParseError(error)) {
|
|
1516
|
-
return stale(new AuditHostBindingError("workload_binding", error.message));
|
|
1517
|
-
}
|
|
1518
|
-
// Infrastructure failures and corrupt accepted ledgers remain strict.
|
|
1519
|
-
throw error;
|
|
1520
|
-
}
|
|
1796
|
+
const bindingSet = await readHandoffBindingSet(paths);
|
|
1797
|
+
if (!bindingSet.ok)
|
|
1798
|
+
return stale(bindingSet.refusal);
|
|
1799
|
+
const { resultMap, taskBindings, items } = bindingSet;
|
|
1521
1800
|
const acceptedBindings = new Set(accepted.entries.map(bindingIdentity));
|
|
1522
1801
|
const resultIds = new Set(accepted.entries.map((entry) => entry.result_id));
|
|
1523
1802
|
const additions = [];
|
|
@@ -1535,102 +1814,26 @@ export async function ingestAuditHostResults(params) {
|
|
|
1535
1814
|
const binding = taskBindings.get(entry.work_item_id);
|
|
1536
1815
|
if (item === undefined || binding === undefined)
|
|
1537
1816
|
continue;
|
|
1538
|
-
const
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
return parsed.ok ? { ok: true, parsed: parsed.result } : parsed;
|
|
1546
|
-
},
|
|
1547
|
-
resultId: (result) => result.result_id,
|
|
1548
|
-
// CHECK only. The id is consumed further down, after conversion,
|
|
1549
|
-
// validation and grounding — a result refused there must stay re-submittable.
|
|
1817
|
+
const judged = await judgeAuditHostSubmission({
|
|
1818
|
+
paths,
|
|
1819
|
+
entry,
|
|
1820
|
+
item,
|
|
1821
|
+
binding,
|
|
1822
|
+
// CHECK only. The id is consumed below, after the judgment — a result
|
|
1823
|
+
// refused there must stay re-submittable.
|
|
1550
1824
|
seen: (resultId) => resultIds.has(resultId),
|
|
1551
|
-
|
|
1825
|
+
activeTaskIds,
|
|
1826
|
+
auditTasks: params.auditTasks,
|
|
1827
|
+
lineIndex: params.lineIndex,
|
|
1828
|
+
readSource,
|
|
1829
|
+
knownPaths: async () => (knownPaths ??= await enumerateTrackedFilePaths(boundarySourceRoot(paths))),
|
|
1552
1830
|
});
|
|
1553
|
-
if (!
|
|
1554
|
-
issues.push(
|
|
1555
|
-
continue;
|
|
1556
|
-
}
|
|
1557
|
-
const result = outcome.parsed;
|
|
1558
|
-
const converted = toAuditResult(result, binding);
|
|
1559
|
-
if (!converted.ok) {
|
|
1560
|
-
issues.push({
|
|
1561
|
-
code: "submission_contract_invalid",
|
|
1562
|
-
check: "result_schema",
|
|
1563
|
-
message: `work item '${entry.work_item_id}' submitted a result that does not convert to ` +
|
|
1564
|
-
`an AuditResult: ${converted.detail}`,
|
|
1565
|
-
work_item_id: entry.work_item_id,
|
|
1566
|
-
result_path: entry.result_path,
|
|
1567
|
-
});
|
|
1831
|
+
if (!judged.ok) {
|
|
1832
|
+
issues.push(judged.issue);
|
|
1568
1833
|
continue;
|
|
1569
1834
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
// occurs. It NEVER rejects — a quote that is absent or occurs more than
|
|
1573
|
-
// once rides through as `ungrounded` and synthesis surfaces it under
|
|
1574
|
-
// "Ungrounded Findings (not confirmed)"; refusing here would discard the
|
|
1575
|
-
// whole submission over one bad citation. It mutates the CONVERTED copy
|
|
1576
|
-
// only: `result` stays the host's submission, which `result_sha256` hashes.
|
|
1577
|
-
// It runs BEFORE validation, so the derived span meets the same coverage
|
|
1578
|
-
// rule here that the downstream batch gate applies: a span that rule would
|
|
1579
|
-
// refuse is refused while the item can still be resubmitted, never
|
|
1580
|
-
// accepted and then replayed into a failing gate on every later step.
|
|
1581
|
-
for (const finding of converted.auditResult.findings) {
|
|
1582
|
-
knownPaths ??= await enumerateTrackedFilePaths(boundarySourceRoot(paths));
|
|
1583
|
-
await groundFinding(boundarySourceRoot(paths), finding, readSource, knownPaths);
|
|
1584
|
-
}
|
|
1585
|
-
// VALIDATE BEFORE ACCEPT. The conversion above proves only the envelope
|
|
1586
|
-
// contract (`FindingSchema` admits an evidence-less finding); these are the
|
|
1587
|
-
// per-result rules the downstream batch gate applies, applied HERE so an
|
|
1588
|
-
// error-severity issue never reaches the accepted pair. A rejected item is
|
|
1589
|
-
// simply never in the ledger, so the corrected file at the same bound path
|
|
1590
|
-
// is re-read on the next fold — acceptance used to be terminal instead, and
|
|
1591
|
-
// a failed batch gate then wedged the run permanently.
|
|
1592
|
-
//
|
|
1593
|
-
// Orphans (task pruned by a re-plan) pass through UNVALIDATED with the same
|
|
1594
|
-
// stderr notice the batch gate uses — never newly rejected: refusing one
|
|
1595
|
-
// here would strand it outside the append-only ledger entirely.
|
|
1596
|
-
if (!activeTaskIds.has(entry.work_item_id)) {
|
|
1597
|
-
process.stderr.write(`audit host-handoff ingest: result for '${entry.work_item_id}' is not in the ` +
|
|
1598
|
-
`active task manifest (orphaned by re-planning); retained in the accepted pair ` +
|
|
1599
|
-
`but skipped at the validation gate\n`);
|
|
1600
|
-
}
|
|
1601
|
-
else {
|
|
1602
|
-
const validationIssues = validateOneAuditResult(converted.auditResult, [
|
|
1603
|
-
...params.auditTasks,
|
|
1604
|
-
], {
|
|
1605
|
-
lineIndex: params.lineIndex,
|
|
1606
|
-
});
|
|
1607
|
-
const errors = validationIssues.filter((issue) => issue.severity === "error");
|
|
1608
|
-
if (errors.length > 0) {
|
|
1609
|
-
issues.push({
|
|
1610
|
-
code: "result_validation_failed",
|
|
1611
|
-
check: "result_validation",
|
|
1612
|
-
message: `work item '${entry.work_item_id}' failed audit-results validation ` +
|
|
1613
|
-
`(${errors.length} error(s)); fix the result file at its bound path and call next-step again: ` +
|
|
1614
|
-
formatAuditResultIssues(errors),
|
|
1615
|
-
work_item_id: entry.work_item_id,
|
|
1616
|
-
result_path: entry.result_path,
|
|
1617
|
-
});
|
|
1618
|
-
continue;
|
|
1619
|
-
}
|
|
1620
|
-
// Warnings are NOT rejections: an accepted result never refused anything,
|
|
1621
|
-
// so a warning must never reach the rejection-classified issue list — the
|
|
1622
|
-
// ONE ledger recorder would otherwise record kind:'rejected' for a result
|
|
1623
|
-
// that was accepted, manufacturing a repair story that never happened.
|
|
1624
|
-
// They ride the separate advisory channel instead (rendered for the
|
|
1625
|
-
// operator; never counted as a submission that could not be accepted).
|
|
1626
|
-
validation_warnings.push(...validationIssues
|
|
1627
|
-
.filter((issue) => issue.severity === "warning")
|
|
1628
|
-
.map((warning) => ({
|
|
1629
|
-
work_item_id: entry.work_item_id,
|
|
1630
|
-
result_path: entry.result_path,
|
|
1631
|
-
message: `${warning.message} (${warning.field})`,
|
|
1632
|
-
})));
|
|
1633
|
-
}
|
|
1835
|
+
validation_warnings.push(...judged.warnings);
|
|
1836
|
+
const { result, auditResult } = judged;
|
|
1634
1837
|
resultIds.add(result.result_id);
|
|
1635
1838
|
// construction-site: AuditResult
|
|
1636
1839
|
// construction-site: Finding (the `findings` array; `lens` defaults from the enclosing contract, already spread in)
|
|
@@ -1641,7 +1844,7 @@ export async function ingestAuditHostResults(params) {
|
|
|
1641
1844
|
result_id: result.result_id,
|
|
1642
1845
|
result_sha256: contentSha256(result),
|
|
1643
1846
|
result,
|
|
1644
|
-
audit_result:
|
|
1847
|
+
audit_result: auditResult,
|
|
1645
1848
|
});
|
|
1646
1849
|
}
|
|
1647
1850
|
// Binding reads, validation and this accepted pair write share ONE hold.
|