Skip to content

Correlate Link handshake replies - #453

Merged
SaladDay merged 2 commits into
feature/agent-outside-sandboxfrom
aos/b4-link
Oct 6, 2026
Merged

SaladDay merged 2 commits into
feature/agent-outside-sandboxfrom
aos/b4-link

Conversation

@SaladDay

@SaladDay SaladDay commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

This is a Link protocol change from the B4 simplicity audit.

  • Replies are correlated. Hello, Open, the relay's Bind, Renew and Close accept a reply only when it carries the request's ID and answers the request's operation. Before, a success with any nonzero ID was accepted, and Failure.Op was not checked. A reply that fails to decode or fails correlation is now a non-retryable ProtocolViolation with EffectPossible, and only a failed stream stays Uncertain. Serve stops rather than reconnects after a malformed Hello reply.
  • Negotiated limits are gone. MaxFrameBytes and MaxStreams leave HelloAccepted, Opened and Bind, along with their validators and fixtures. No production code set them, and File and Process ignored the frame limit. Every service stream uses sandboxwire.MaxPayload, and the relay keeps a 256-stream constant.
  • Unused surface is deleted:
    • HelloAccepted.LinkID, so OnConnected takes no argument;
    • relay.Config, so relay.New takes the Authority;
    • ReadMessage's limit parameter, so it always enforces MaxMessageBytes;
    • AttachLink.Accepted;
    • sandboxlinktest.Authority.RemoveGrant.
  • Docs: docs/sandbox-link-protocol.md and its zh translation, with a current source_hash.

Net: production −48, tests +83, docs −10.

Testing:

  • TestAnswersMatchTheirRequests drives the real callers with a wrong ID, a zero ID and a wrong op. Reverting any single guard fails exactly the matching cases.
  • -race -count=50 on internal/sandboxlink/....
  • The tests of the 23 importing packages.
  • The fuzz seeds, plus 20 s of FuzzDecode.

Blind review (Codex) asked for these fixes; they are all included.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

The Hello, Open and Bind exchanges accepted a reply under any request ID
and a Failure for any operation. sandboxlink.ReadReply now reads the reply
to one request and answers anything else with ProtocolViolation and
EffectPossible; control calls check the Failure's operation the same way.

Delete the negotiable frame limit: HelloAccepted.MaxStreams and the
MaxFrameBytes of HelloAccepted, Opened and Bind had no reader, and every
service stream reads against sandboxwire.MaxPayload. relay.Config keeps
only the Authority and the stream limit becomes a constant. Delete the
uncalled AttachLink.Accepted and sandboxlinktest.Authority.RemoveGrant.
An answer that does not decode, or that carries another request ID or operation, fails its request with a final ProtocolViolation and EffectPossible; only a failed stream stays Uncertain. HelloAccepted carries no fields, ReadMessage enforces MaxMessageBytes itself, and relay.New takes the Authority directly.
@SaladDay
SaladDay merged commit b362c92 into feature/agent-outside-sandbox Oct 6, 2026
20 checks passed
@SaladDay
SaladDay deleted the aos/b4-link branch October 6, 2026 23:48
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.

1 participant