Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion loopx/chat/result_files_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ..capabilities.manager_context.roundtrip import read_chat_return_file
from ..chat_attachments import CHAT_IMAGE_MAX_BYTES, CHAT_IMAGE_TYPES
from ..control_plane.content_digest import BARE_SHA256_PATTERN
from ..control_plane.effect_runtime import effect_runtime_request_scope


Expand Down Expand Up @@ -116,7 +117,7 @@ def _serve_chat_history_image(self, parts) -> bool:
self._send_error("Conversation images are only available to the original App.", status=403)
return True
try:
if not re.fullmatch(r"[0-9]{1,3}", parts[7]) or not re.fullmatch(r"[a-f0-9]{64}", parts[8]):
if not re.fullmatch(r"[0-9]{1,3}", parts[7]) or not BARE_SHA256_PATTERN.fullmatch(parts[8]):
raise KeyError("image unavailable")
mime, body = read_chat_history_image(
self.server.chat_store, unquote(parts[3]), unquote(parts[5]), int(parts[7]), parts[8])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {constants} from "node:fs";
import {open, readdir} from "node:fs/promises";
import {isAbsolute, join, toNamespacedPath} from "node:path";

import {ENVELOPED_SHA256_PATTERN} from "../content_digest.ts";
import type {JsonObject} from "../effect_program.ts";
import {EffectRuntimeRequestError} from "../effect_runtime_errors.ts";
import {atomicWriteJson, atomicWriteText, withFileMutationLock} from "../effect_runtime_io.ts";
Expand Down Expand Up @@ -106,7 +107,7 @@ async function readEntry(source: ReturnType<typeof scope>, id: string): Promise<
fail("host terminal receipt id is invalid");
}
requireStringLiteral(row.outcome, [...OUTCOMES], "native child result outcome");
if (typeof row.content_sha256 !== "string" || !/^sha256:[0-9a-f]{64}$/u.test(row.content_sha256)
if (typeof row.content_sha256 !== "string" || !ENVELOPED_SHA256_PATTERN.test(row.content_sha256)
|| !Number.isSafeInteger(row.content_bytes) || Number(row.content_bytes) < 0
|| Number(row.content_bytes) > MAX_CONTENT_BYTES) fail("native child result content identity is invalid");
instant(row.created_at, "result creation time");
Expand Down
1 change: 1 addition & 0 deletions tests/architecture/test_content_digest_single_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"loopx.capabilities.progress_review.receipt",
"loopx.chat_action_normalization",
"loopx.capabilities.manager_context.chat_history",
"loopx.chat.result_files_api",
"loopx.cli_commands.quota_context_reader",
"loopx.cli_commands.update_artifact",
"loopx.configuration_transaction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const CANONICAL_CONSUMERS = [
"control_plane/capabilities/explore_result_page.ts",
"control_plane/capabilities/external_evidence.ts",
"control_plane/capabilities/goal_capability_organization.ts",
"control_plane/capabilities/native_child_result_inbox.ts",
"control_plane/capabilities/trajectory_assessment.ts",
"control_plane/capabilities/trajectory_input_usage.ts",
"control_plane/capabilities/trajectory_tool_context.ts",
Expand Down
Loading