mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
679658b287
* fix(reference): report entries beyond the path limit as I/O failures Reference-source traversal joins each child onto the root path. A valid tree whose nested entries exceed the platform's absolute path limit (PATH_MAX 1024 on macOS) makes lstat fail with ENAMETOOLONG. The reader's filesystem error allow-list lacked that code, so filesystemFailureDetail returned undefined and the native rejection escaped both readReferenceSource and importReferenceSource instead of becoming the existing failed `io` entry. Add ENAMETOOLONG to the allow-list, matching the JavaScript application reader's list. Readable siblings stay in the graph and the unreachable entry is recorded with its OS message. Fixes #2652 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(reference): assert the imported graph keeps readable and failed entries Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(process): report no remaining time after a provider deadline fires Node timers can fire while performance.now() is still a fraction of a millisecond short of the monotonic deadline. ProviderStartupDeadline then reported interruption "timeout" and an aborted signal while remainingMs() returned ceil(0.x) = 1, so polling loops guarded by remainingMs() > 0 (Hopper and Ghidra startup) could run past an elapsed deadline, and the real-timer test "aborts a bounded wait when its real monotonic deadline expires" failed intermittently in CI (expected 1 to be 0). Once the deadline's own timer has classified a timeout, report zero remaining time. A deterministic regression test fires the timer with the monotonic clock 0.4 ms short of the deadline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(reference): preserve path limit entry uncertainty * fix(reference): preserve unknown entry failures and identity * fix(reference): type unknown-kind exclusions and keep them out of symlink counts The metadata-failure path offers "unknown" to exclusion predicates, but the predicate type only admitted concrete kinds, which broke the build. Directory-only secret and ignore rules now also match an unknown-kind entry (it may be a directory), and the summary counts unknown entries separately instead of as symlinks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> Co-authored-by: Codex <codex@users.noreply.github.com>
125 lines
3.7 KiB
TypeScript
125 lines
3.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
createHistoricalSourceGraph,
|
|
createHistoricalSourceManifest,
|
|
type HistoricalSourceGraphInput,
|
|
} from "./referenceSourceGraph.js";
|
|
import { createHistoricalSourceSummary } from "./referenceSourceSummary.js";
|
|
|
|
const input = (
|
|
entries: HistoricalSourceGraphInput["entries"],
|
|
): HistoricalSourceGraphInput => ({
|
|
schema: "HistoricalSourceGraph",
|
|
authority: "historical-reference",
|
|
root_alias: "$REFERENCE_ROOT",
|
|
inventory_state: "unknown",
|
|
entries,
|
|
relationships: [],
|
|
parse_failures: [],
|
|
exclusions: [],
|
|
languages: [],
|
|
manifests: [],
|
|
vcs: null,
|
|
provenance: { importer: "fixture", importer_version: null, caller: "test" },
|
|
limitations: ["Inventory coverage is unknown"],
|
|
});
|
|
|
|
describe("committed historical-source summaries", () => {
|
|
it("preserves unknown coverage, sizes, directories and missing symlinks without mutating the graph", () => {
|
|
const graph = createHistoricalSourceGraph(
|
|
input([
|
|
{
|
|
path: "a",
|
|
kind: "directory",
|
|
tree_state: "unknown",
|
|
classifications: ["unknown"],
|
|
limitations: ["Not enumerated"],
|
|
},
|
|
{
|
|
path: "b",
|
|
kind: "file",
|
|
sha256: null,
|
|
size: null,
|
|
content_state: "unreadable",
|
|
language: null,
|
|
classifications: ["unknown"],
|
|
limitations: ["Not readable"],
|
|
},
|
|
{
|
|
path: "c",
|
|
kind: "symlink",
|
|
target: "missing",
|
|
target_state: "missing",
|
|
classifications: ["unknown"],
|
|
limitations: [],
|
|
},
|
|
]),
|
|
);
|
|
const original = structuredClone(graph);
|
|
const summary = createHistoricalSourceSummary(graph, 1);
|
|
expect(summary).toMatchObject({
|
|
manifest: createHistoricalSourceManifest(original),
|
|
inventory_state: "unknown",
|
|
vcs: null,
|
|
provenance: original.provenance,
|
|
file_sizes: { known_bytes: "0", unknown_file_count: 1 },
|
|
counts: { entries: 3, files: 1, directories: 1, symlinks: 1 },
|
|
directory_tree_states: { unknown: 1, enumerated: 0 },
|
|
file_content_states: { unreadable: 1, hashed: 0 },
|
|
limitations: original.limitations,
|
|
outline: {
|
|
entries: [
|
|
original.entries[0],
|
|
expect.objectContaining({ size: null, content_state: "unreadable" }),
|
|
original.entries[2],
|
|
],
|
|
omitted_entry_count: 0,
|
|
},
|
|
});
|
|
expect(summary.outline.entries[1]).not.toHaveProperty("sha256");
|
|
expect(graph).toEqual(original);
|
|
});
|
|
|
|
it("counts entries of unknown kind separately from symlinks", () => {
|
|
const graph = createHistoricalSourceGraph(
|
|
input([
|
|
{
|
|
path: "deep",
|
|
kind: "unknown",
|
|
classifications: ["unknown"],
|
|
limitations: ["lstat: ENAMETOOLONG"],
|
|
},
|
|
]),
|
|
);
|
|
expect(createHistoricalSourceSummary(graph, 1).counts).toMatchObject({
|
|
entries: 1,
|
|
files: 0,
|
|
directories: 0,
|
|
symlinks: 0,
|
|
unknown: 1,
|
|
});
|
|
});
|
|
|
|
it("sums known bytes losslessly beyond the JSON safe integer range", () => {
|
|
const graph = createHistoricalSourceGraph(
|
|
input(
|
|
["a", "b"].map((path) => ({
|
|
path,
|
|
kind: "file",
|
|
sha256: "a".repeat(64),
|
|
size: Number.MAX_SAFE_INTEGER,
|
|
content_state: "hashed",
|
|
language: null,
|
|
classifications: ["unknown"],
|
|
limitations: [],
|
|
})),
|
|
),
|
|
);
|
|
expect(createHistoricalSourceSummary(graph, 0)).toMatchObject({
|
|
file_sizes: { known_bytes: "18014398509481982", unknown_file_count: 0 },
|
|
outline: { entries: [], omitted_entry_count: 2 },
|
|
});
|
|
});
|
|
});
|