fix(domain): replace bare parser errors with typed codes (#8057)

* fix(domain): replace bare parser errors with typed codes

OpenStep syntax, canonical JSON digests, managed-graph source checks,
frame fingerprints, and reference-flow invariants threw Error and
published the sentence. Each refusal now carries a code. Tests assert
that code, including OpenStep position, instead of the previous prose.

* test(domain): pin OpenStep refusal codes and positions

The syntax cases accepted any code and any offset. Each container
refusal now expects its code and source position, including the deep
suffix that changes (x from unterminated_array to expected_separator.
Scalar failures stay identical to the pinned decoder.

* test(filesystem): assert OpenStep keyed-archive codes

The deep-suffix keyed archive cases compared ArtifactReaderFailure
message text with the pinned decoder sentence. They now require
reason format and the OpenStep code and source position on the cause.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
morlutoandCursor Agent authored and GitHub committed 2026-10-30 05:23:10 +08:00
1 parent a4c183b750
commit b663c79552
12 files changed
+232 -74

No files matched your search

+14 -2
View File
@@ -17,6 +17,18 @@ interface FlowEdge {
remaining: number;
}
/** Residual-network invariant. The code is the stable identity. */
class ReferenceFlowError extends Error {
readonly _tag = "ReferenceFlowError";
constructor(
readonly code: "endpoint_unallocated" | "reverse_edge_unallocated",
) {
super(code);
this.name = "ReferenceFlowError";
}
}
/** A local residual network: no recursive walk or pairwise adjacency matrix. */
class ReferenceFlow {
private readonly edges: FlowEdge[][] = [];
@@ -30,7 +42,7 @@ class ReferenceFlow {
const forward = this.edges[from];
const reverse = this.edges[to];
if (forward === undefined || reverse === undefined)
throw new Error("Reference flow endpoint was not allocated.");
throw new ReferenceFlowError("endpoint_unallocated");
forward.push({ to, reverse: reverse.length, remaining: capacity });
reverse.push({ to: from, reverse: forward.length - 1, remaining: 0 });
}
@@ -87,7 +99,7 @@ class ReferenceFlow {
edge.remaining -= amount;
const reverse = this.edges[edge.to]?.[edge.reverse];
if (reverse === undefined)
throw new Error("Reference flow reverse edge was not allocated.");
throw new ReferenceFlowError("reverse_edge_unallocated");
reverse.remaining += amount;
}
return amount;