Skip to content

Codex/import artifact byte replication retry3#951

Open
lupuszr wants to merge 5 commits into
mainfrom
codex/import-artifact-byte-replication-retry3
Open

Codex/import artifact byte replication retry3#951
lupuszr wants to merge 5 commits into
mainfrom
codex/import-artifact-byte-replication-retry3

Conversation

@lupuszr

@lupuszr lupuszr commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add generic imported-artifact byte support for source/original artifacts alongside markdown
  • add /api/assertion/import-artifact/read-file for source/original byte reads, while keeping /read-markdown markdown-only
  • gate peer byte serving on public+open context graphs plus verified completed import metadata/hash linkage
  • add focused proto, agent responder, and CLI route regression coverage

Validation

  • pnpm --dir packages/core exec vitest run test/import-artifact-bytes-proto.test.ts
  • pnpm --dir packages/agent exec vitest run test/dkg-agent-imported-artifact-bytes.test.ts --config vitest.unit.config.ts
  • pnpm --dir packages/cli exec vitest run test/import-artifact-read-file-routes.test.ts --config vitest.unit.config.ts
  • pnpm --dir packages/core exec tsc --noEmit --pretty false --tsBuildInfoFile /dev/null
  • pnpm --dir packages/agent exec tsc --noEmit --pretty false --tsBuildInfoFile /dev/null
  • pnpm --dir packages/cli exec tsc --noEmit --pretty false --tsBuildInfoFile /dev/null
  • git diff --check

@lupuszr lupuszr force-pushed the codex/import-artifact-byte-replication-retry3 branch from 9aa8629 to 379be8e Compare June 3, 2026 12:34
Comment thread packages/agent/src/dkg-agent-import-artifact-bytes.ts Outdated
Comment thread packages/agent/src/dkg-agent-import-artifact-bytes.ts Outdated
OPTIONAL { <${assertionUri}> <${ns}mdIntermediateHash> ?mdIntermediateHash }
}`,
]);
const result = await this.store.query(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Bug: This lookup only checks whether the assertion has sourceFile/sourceFileHash linkage. It never verifies that assertionUri is actually a completed imported artifact (extractionStatus=completed, structural triples present, etc.), so any public+open assertion that references an existing urn:dkg:file:<hash> can now expose file-store bytes over the new protocol. Please reuse the same completed-import guard that /import-artifact/resolve applies before serving bytes.


switch (response.status) {
case IMPORTED_ARTIFACT_BYTES_RESPONSE_STATUS.ALLOW: {
const bytes = Buffer.from(response.bytes);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Bug: We buffer and persist whatever payload the origin peer returns, and only enforce the caller's maxBytes later in the HTTP route. A buggy/malicious peer can therefore make us download and cache multi-MB content even when the caller requested a tiny read. Please reject oversized response.bytes before fileStore.put() (at least against the protocol cap, and ideally against the route's maxBytes).

@@ -1325,7 +1515,7 @@ export async function handleAssertionRoutes(ctx: RequestContext): Promise<void>
}
return jsonResponse(res, 200, {
artifact,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Issue: artifact can still report canReadMarkdown: false here because resolveImportedArtifact() only checks the local cache, but this handler now succeeds after fetching from the origin peer. That leaves a 200 response with self-contradictory metadata and will also mislead callers that gate on /import-artifact/resolve. Consider updating the returned artifact/capability once the remote fetch path succeeds.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex review skipped: filtered diff is 42213 lines (cap: 5,000). Please consider splitting this into smaller PRs for reviewability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants