Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

refactor: colocate investigation record implementation (#867)

ysopwnablebb19c9477ef3
diff --git a/docs/capability-migration.md b/docs/capability-migration.md
index 0e7009bcd..c5d29f3db 100644
--- a/docs/capability-migration.md
+++ b/docs/capability-migration.md
@@ -141,6 +141,12 @@ owner explicitly; the direct BinarySession constructor retains a fresh default
for compatibility. There is no second ledger, global store, persistence or new
retention policy.
+The ledger, Unknown Evidence helper and the ledger's two original behavior tests
+now live beside the owner in `src/application/investigation/`. Bundle validation
+and record-owner consumers follow the new paths; retained-reference access still
+uses the narrow record ports. The move preserves implementation bodies and test
+assertions. Binary snapshot/cache files remain with their existing owner.
+
EvidenceReader, EvidenceWriter and EvidenceUnknownWriter describe existing
read/write/atomic callback needs. UnknownRegistryPort preserves optimistic
revisions and consistency verification. Non-binary MCP registrars use these
diff --git a/src/application/EvidenceBundleCommands.ts b/src/application/EvidenceBundleCommands.ts
index 33fce9bbc..928b794de 100644
--- a/src/application/EvidenceBundleCommands.ts
+++ b/src/application/EvidenceBundleCommands.ts
@@ -5,7 +5,7 @@ import type { JsonValue } from "../domain/jsonValue.js";
import { jsonValueSchema } from "../domain/jsonValue.js";
import { err, ok, type Result } from "../domain/result.js";
import { compareBundles } from "../domain/bundleComparison.js";
-import { EvidenceLedger } from "./EvidenceLedger.js";
+import { EvidenceLedger } from "./investigation/EvidenceLedger.js";
import {
readEvidenceBundle,
writeEvidenceBundle,
diff --git a/src/application/EvidenceInputResolver.test.ts b/src/application/EvidenceInputResolver.test.ts
index 146989418..11491b1d2 100644
--- a/src/application/EvidenceInputResolver.test.ts
+++ b/src/application/EvidenceInputResolver.test.ts
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
import { evidenceInputSchema } from "../contracts/evidenceInputContracts.js";
import { JAVASCRIPT_FEATURE_TRACE_EXAMPLE } from "../contracts/javascriptApplicationWorkflowExamples.js";
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
-import { EvidenceLedger } from "./EvidenceLedger.js";
+import { EvidenceLedger } from "./investigation/EvidenceLedger.js";
import { resolveEvidenceInput } from "./EvidenceInputResolver.js";
const evidence = JAVASCRIPT_FEATURE_TRACE_EXAMPLE.application;
diff --git a/src/application/EvidenceLedger.residualUnknown.test.ts b/src/application/investigation/EvidenceLedger.residualUnknown.test.ts
similarity index 98%
rename from src/application/EvidenceLedger.residualUnknown.test.ts
rename to src/application/investigation/EvidenceLedger.residualUnknown.test.ts
index efd26e0f4..1dac1b9a1 100644
--- a/src/application/EvidenceLedger.residualUnknown.test.ts
+++ b/src/application/investigation/EvidenceLedger.residualUnknown.test.ts
@@ -1,19 +1,19 @@
import { describe, expect, it } from "vitest";
import { EvidenceLedger } from "./EvidenceLedger.js";
-import { createEvidence } from "../domain/evidence.js";
+import { createEvidence } from "../../domain/evidence.js";
import {
createEvidenceBundle,
parseEvidenceBundle,
serializeEvidenceBundle,
-} from "../domain/evidenceBundle.js";
+} from "../../domain/evidenceBundle.js";
import {
createResidualUnknown,
recordUnknownInputSchema,
updateUnknownInputSchema,
type RecordUnknownInput,
type ResidualUnknown,
-} from "../domain/residualUnknown.js";
+} from "../../domain/residualUnknown.js";
const provider = { id: "fixture", name: "Fixture", version: "1" };
const ledger = (): EvidenceLedger => new EvidenceLedger();
diff --git a/src/application/EvidenceLedger.test.ts b/src/application/investigation/EvidenceLedger.test.ts
similarity index 94%
rename from src/application/EvidenceLedger.test.ts
rename to src/application/investigation/EvidenceLedger.test.ts
index 14ca71572..46fe6e68d 100644
--- a/src/application/EvidenceLedger.test.ts
+++ b/src/application/investigation/EvidenceLedger.test.ts
@@ -1,9 +1,9 @@
import { describe, expect, it } from "vitest";
-import type { BinaryTarget } from "../domain/binaryTarget.js";
-import { createEvidence } from "../domain/evidence.js";
-import { createEvidenceBundle } from "../domain/evidenceBundle.js";
-import { recordUnknownInputSchema } from "../domain/residualUnknown.js";
+import type { BinaryTarget } from "../../domain/binaryTarget.js";
+import { createEvidence } from "../../domain/evidence.js";
+import { createEvidenceBundle } from "../../domain/evidenceBundle.js";
+import { recordUnknownInputSchema } from "../../domain/residualUnknown.js";
import { EvidenceLedger } from "./EvidenceLedger.js";
const TARGET: BinaryTarget = {
diff --git a/src/application/EvidenceLedger.ts b/src/application/investigation/EvidenceLedger.ts
similarity index 97%
rename from src/application/EvidenceLedger.ts
rename to src/application/investigation/EvidenceLedger.ts
index b8b9cfb1c..3b87c93d4 100644
--- a/src/application/EvidenceLedger.ts
+++ b/src/application/investigation/EvidenceLedger.ts
@@ -5,10 +5,10 @@ import {
parseEvidenceBundle,
validateResidualUnknownAddition,
type EvidenceBundle,
-} from "../domain/evidenceBundle.js";
-import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
-import { UnknownRegistryError } from "../domain/unknownRegistryError.js";
-import { parseEvidence, type Evidence } from "../domain/evidence.js";
+} from "../../domain/evidenceBundle.js";
+import { EvidenceIntegrityError } from "../../domain/evidenceErrors.js";
+import { UnknownRegistryError } from "../../domain/unknownRegistryError.js";
+import { parseEvidence, type Evidence } from "../../domain/evidence.js";
import {
createResidualUnknown,
updateResidualUnknown,
@@ -16,8 +16,8 @@ import {
type ResidualUnknown,
type UnknownStatus,
type UpdateUnknownInput,
-} from "../domain/residualUnknown.js";
-import { err, ok, type Result } from "../domain/result.js";
+} from "../../domain/residualUnknown.js";
+import { err, ok, type Result } from "../../domain/result.js";
type EvidenceLedgerFailure = EvidenceIntegrityError;
type RecordResult = Result<"added" | "duplicate", EvidenceLedgerFailure>;
diff --git a/src/application/investigation/InvestigationRecords.test.ts b/src/application/investigation/InvestigationRecords.test.ts
index 184c10e6a..6450590ec 100644
--- a/src/application/investigation/InvestigationRecords.test.ts
+++ b/src/application/investigation/InvestigationRecords.test.ts
@@ -10,7 +10,7 @@ import {
recordUnknownInputSchema,
updateUnknownInputSchema,
} from "../../domain/residualUnknown.js";
-import { unknownMutationEvidence } from "../UnknownEvidence.js";
+import { unknownMutationEvidence } from "./UnknownEvidence.js";
import { InvestigationRecords } from "./InvestigationRecords.js";
const unknownInput = (question: string) =>
diff --git a/src/application/investigation/InvestigationRecords.ts b/src/application/investigation/InvestigationRecords.ts
index 917bd06e0..9b612f11c 100644
--- a/src/application/investigation/InvestigationRecords.ts
+++ b/src/application/investigation/InvestigationRecords.ts
@@ -11,12 +11,12 @@ import type {
UpdateUnknownInput,
} from "../../domain/residualUnknown.js";
import type { Result } from "../../domain/result.js";
-import { EvidenceLedger, type EvidenceImportDelta } from "../EvidenceLedger.js";
+import { EvidenceLedger, type EvidenceImportDelta } from "./EvidenceLedger.js";
import {
UNKNOWN_REGISTRY_PROVIDER,
unknownEvidenceLinks,
unknownMutationEvidence,
-} from "../UnknownEvidence.js";
+} from "./UnknownEvidence.js";
import type {
EvidenceReader,
EvidenceWriter,
diff --git a/src/application/UnknownEvidence.ts b/src/application/investigation/UnknownEvidence.ts
similarity index 86%
rename from src/application/UnknownEvidence.ts
rename to src/application/investigation/UnknownEvidence.ts
index 5a3ea3b23..e1712a004 100644
--- a/src/application/UnknownEvidence.ts
+++ b/src/application/investigation/UnknownEvidence.ts
@@ -1,10 +1,10 @@
-import type { BinaryTarget } from "../domain/binaryTarget.js";
-import { createEvidence, type Evidence } from "../domain/evidence.js";
+import type { BinaryTarget } from "../../domain/binaryTarget.js";
+import { createEvidence, type Evidence } from "../../domain/evidence.js";
import type {
RecordUnknownInput,
UpdateUnknownInput,
-} from "../domain/residualUnknown.js";
-import type { ProviderIdentity } from "./AnalysisProvider.js";
+} from "../../domain/residualUnknown.js";
+import type { ProviderIdentity } from "../AnalysisProvider.js";
/** Provider identity for analyst-authored residual-unknown mutations. */
export const UNKNOWN_REGISTRY_PROVIDER: ProviderIdentity = {