fix: complete paste artifact storage contract
This commit is contained in:
@@ -133,7 +133,16 @@ message: string,
|
||||
*/
|
||||
timestamp_ms: number, };
|
||||
|
||||
export type PasteArtifactRef = { artifact_id: string, byte_len: number, char_count: number, line_count: number, sha256: string, source_entry_id: string, };
|
||||
export type PasteArtifactMediaType = "text_plain_utf8";
|
||||
|
||||
export type PasteArtifactAvailability = "available" | "unavailable" | "integrity_failed";
|
||||
|
||||
export type PasteArtifactRef = { artifact_id: string, created_at_ms: number, media_type: PasteArtifactMediaType,
|
||||
/**
|
||||
* Availability observed when this immutable reference was committed.
|
||||
* Reads revalidate storage and integrity rather than trusting this field.
|
||||
*/
|
||||
availability: PasteArtifactAvailability, byte_len: number, char_count: number, line_count: number, sha256: string, source_entry_id: string, };
|
||||
|
||||
export type Segment = { "kind": "text", content: string, } | { "kind": "paste", id: number, chars: number, lines: number, content: string, } | { "kind": "paste_artifact", artifact: PasteArtifactRef, } | { "kind": "file_ref", path: string, } | { "kind": "flow", selector: string, } | { "kind": "unknown" };
|
||||
|
||||
|
||||
@@ -143,6 +143,9 @@ Deno.test("large paste segments project compact artifact metadata", () => {
|
||||
kind: "paste_artifact",
|
||||
artifact: {
|
||||
artifact_id: "019ca7c8-57b6-7f05-8edf-524147aba7b2",
|
||||
created_at_ms: 1_700_000_000_000,
|
||||
media_type: "text_plain_utf8",
|
||||
availability: "available",
|
||||
byte_len: 65536,
|
||||
char_count: 65530,
|
||||
line_count: 200,
|
||||
@@ -152,6 +155,9 @@ Deno.test("large paste segments project compact artifact metadata", () => {
|
||||
}]);
|
||||
assert(text.includes("019ca7c8-57b6-7f05-8edf-524147aba7b2"), "artifact id is visible");
|
||||
assert(text.includes("65536 bytes"), "bounded size metadata is visible");
|
||||
assert(text.includes("text_plain_utf8"), "media type is visible");
|
||||
assert(text.includes("available"), "availability is visible");
|
||||
assert(text.includes("1700000000000"), "creation time is visible");
|
||||
assert(!text.includes(body), "artifact body is not projected");
|
||||
});
|
||||
|
||||
|
||||
@@ -1070,7 +1070,7 @@ export function segmentsToText(segments: Segment[]): string {
|
||||
return segment.content ||
|
||||
`[paste ${segment.id}: ${segment.chars} chars / ${segment.lines} lines]`;
|
||||
case "paste_artifact":
|
||||
return `[Large paste artifact ${segment.artifact.artifact_id}: ${segment.artifact.byte_len} bytes, sha256 ${segment.artifact.sha256}]`;
|
||||
return `[Large paste artifact ${segment.artifact.artifact_id}: ${segment.artifact.byte_len} bytes, ${segment.artifact.media_type}, ${segment.artifact.availability}, created ${segment.artifact.created_at_ms} ms, sha256 ${segment.artifact.sha256}]`;
|
||||
case "file_ref":
|
||||
return `@file ${segment.path}`;
|
||||
case "unknown":
|
||||
|
||||
Reference in New Issue
Block a user