Skip to content

Commit 1526f6f

Browse files
committed
Fold archive occurrence refs into the compaction archive module
archive-uri.ts owned the archive:// addressing scheme apart from the store that honors it. The ref helpers now live on compaction-archive.ts verbatim; plugins and session importers follow. No behavior change.
1 parent ecbda8d commit 1526f6f

7 files changed

Lines changed: 44 additions & 32 deletions

‎src/plugins/evidence-archive-search-plugin.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
advertiseArchiveSurface,
99
evidenceArchiveSearchPlugin,
1010
} from "./evidence-archive-search-plugin.js";
11-
import { formatArchiveRef } from "../session/archive-uri.js";
1211
import {
1312
createCompactionArchive,
13+
formatArchiveRef,
1414
type CompactionArchive,
1515
} from "../session/compaction-archive.js";
1616
import { CATALOG_TOOL_NAMES, CORE_TOOL_NAMES } from "../agent/tool-search.js";

‎src/plugins/evidence-archive-search-plugin.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
formatArchiveRef,
1212
isArchiveLike,
1313
parseArchiveTarget,
14-
} from "../session/archive-uri.js";
14+
} from "../session/compaction-archive.js";
1515

1616
const SEARCH_DEFAULT_MAX = 1000;
1717
const GREP_DEFAULT_MAX = 500;

‎src/plugins/path-escape-plugin.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { resolve } from "node:path";
22
import type { ToolPlugin } from "@intx/tools-posix";
33
import { isToolOutputLike } from "../util/tool-output-uri.js";
4-
import { isArchiveLike } from "../session/archive-uri.js";
4+
import { isArchiveLike } from "../session/compaction-archive.js";
55
import { resolveWorkspacePath } from "../permission/path-restriction.js";
66
import type { RootsProvider } from "../permission/worktree-roots.js";
77

‎src/session/archive-uri.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
isArchiveLike,
66
parseArchiveRef,
77
parseArchiveTarget,
8-
} from "./archive-uri.js";
8+
} from "./compaction-archive.js";
99

1010
describe("archive URI", () => {
1111
test("formats and parses archive:/// occurrence refs", () => {

‎src/session/archive-uri.ts‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎src/session/compaction-archive.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,3 +925,39 @@ export function wrapCompactorWithCompletenessGate(
925925
},
926926
};
927927
}
928+
929+
// ---------------------------------------------------------------------------
930+
// Archive occurrence refs (pure addressing)
931+
// ---------------------------------------------------------------------------
932+
// The archive's own addressing scheme: `archive:///<occurrenceId>` refs name
933+
// where an occurrence's payload bytes live. Kept on the archive module so the
934+
// URI scheme and the store that honors it cannot drift apart.
935+
936+
/** Prefix for every archive target, including the bare `archive:///` root. */
937+
export const ARCHIVE_URI_PREFIX = "archive:";
938+
const ARCHIVE_URI_CANONICAL = "archive:///";
939+
940+
/** Render the canonical ref for an occurrence id. */
941+
export function formatArchiveRef(occurrenceId: string): string {
942+
return `${ARCHIVE_URI_CANONICAL}${occurrenceId}`;
943+
}
944+
945+
export function isArchiveLike(path: string): boolean {
946+
return path.startsWith(ARCHIVE_URI_PREFIX);
947+
}
948+
949+
/** Accept archive:///occ-… and common slashes; return the occurrence id or undefined. */
950+
export function parseArchiveRef(value: string): string | undefined {
951+
return parseArchiveTarget(value)?.occurrenceId;
952+
}
953+
954+
/** Root `archive:///` has no occurrenceId; a ref includes one. */
955+
export function parseArchiveTarget(
956+
value: string,
957+
): { occurrenceId?: string } | undefined {
958+
if (!isArchiveLike(value)) return undefined;
959+
const rest = value.slice(ARCHIVE_URI_PREFIX.length).replace(/^\/+/, "");
960+
const occurrenceId = rest.split(/[/?#]/)[0] ?? "";
961+
if (occurrenceId.length === 0) return {};
962+
return { occurrenceId };
963+
}

‎src/session/summarizer.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ import {
2020
} from "@intx/types/runtime";
2121
import { LOG_NAMESPACE_ROOT } from "../branding.js";
2222
import { NOOP_TELEMETRY, type Telemetry } from "../telemetry/index.js";
23-
import type { CompactionArchive } from "./compaction-archive.js";
23+
import {
24+
formatArchiveRef,
25+
type CompactionArchive,
26+
} from "./compaction-archive.js";
2427
import type {
2528
ArchiveKind,
2629
ArchiveOccurrence,
2730
} from "./compaction-archive-schema.js";
28-
import { formatArchiveRef } from "./archive-uri.js";
2931
import { readSourceCredentialMaterial } from "../config/source-credentials.js";
3032

3133
const logger = getLogger([LOG_NAMESPACE_ROOT, "session", "summarizer"]);

0 commit comments

Comments
 (0)