#546

Make completed command results verifiable: output digests on process_exited, optional signed execution record

Openbabyblueviper1opened 1mo ago

Problem

When a command finishes, the only record of what it produced is the transcript the client saved while streaming. The docs say so directly: output is "a live stream, not durable log storage", reconnecting yields resync_required rather than a replay, and the single-process endpoint returns not_found after exit, so "use the saved event transcript for completed command results" (docs/first-sandbox.md).

The process_exited frame carries process_id, exit_code and status (M1 baseline, DataPlaneServerFrame). Nothing in it lets a client check that the transcript it holds is the complete output. Today completeness is inferred from what's absent: no error, no resync_required, no incomplete frame (docs/troubleshooting.md). Missing frames that leave none of those traces go unnoticed. Also, once the client has the transcript, nothing ties it to the sandbox, template and command that produced it, so a third party has only the client's word for it.

This matters most for SPACE's stated use, running agent code. The party that later has to check an agent's run (a reviewer, an auditor, the user it acted for) usually isn't the client that streamed it.

Proposed approach

1. Output digests on process_exited (additive). Add optional fields:

fieldvalue
stdout_sha256, stderr_sha256sha256 over the decoded bytes of every frame on that stream, in seq order
stdout_bytes, stderr_bytestotal decoded length per stream
last_seqhighest seq emitted on each stream

A client recomputes the digests from its saved frames and knows whether it has the complete output. It doesn't need to rely on the absence of an error frame. This is a small change and useful on its own, even with nothing signed.

2. Optional signed execution record (opt-in, per deployment). On exit, emit or make retrievable a record over canonical JSON (RFC 8785):

sandbox_id, template, template_digest (both already on PublicSandbox), process_id, argv_sha256, cwd, exit_code, status, the five fields above, started_at, exited_at.

It would be signed with a deployment key published at a well-known JWKS URL. env is excluded because it often carries secrets; at most, a digest of its keys. Anyone holding the record and the transcript can then check offline that this output came from this command in this template, without trusting the client.

Open question: where should the digests be computed? Outside the guest seems right, in the data plane where frames are already sequenced, so a compromised guest can't misreport its own output. But you know whether the data plane sees every byte that reaches the client.

Why now

docs/versioning.md names 0.9.0 as the final planned breaking-change release before the 1.0 contract. Part 1 is additive either way, but settling the field names before the M1 schema hardens is cheaper than retrofitting them after 1.0.

Self-assessed severity

Low, as an enhancement. Nothing is broken, but completed command results can't be verified today, which limits SPACE for audited agent workloads.

Offer

If you agree on a shape, I'll write an independent verifier and test vectors for it in a separate repo, built from your spec text alone, so you have a second implementation to check against. I maintain conformance vectors for similar signed decision and payment records. I can't run SPACE end to end myself (no KVM on my host), so I'd verify against fixtures you or the CI produce.

This issue was drafted with AI assistance (Claude), and I reviewed it against the M1 OpenAPI baseline and the docs at 253d8b3.

Activity

1
NancyKwongPerplexity1mo ago

Thanks for opening this issue! A SPACE maintainer will take a look.

CONTRIBUTING.md explains how we review outside contributions.