Skip to content

fix(acp): expose terminal auth before credential setup - #701

Open
yxlyx wants to merge 2 commits into
mainfrom
fix/613-acp-preauth-bootstrap
Open

fix(acp): expose terminal auth before credential setup#701
yxlyx wants to merge 2 commits into
mainfrom
fix/613-acp-preauth-bootstrap

Conversation

@yxlyx

@yxlyx yxlyx commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Let a clean graff acp process answer initialize before provider credential resolution and advertise the existing graff-login Terminal Auth method.
  • Keep the credential-free ACP process protocol-valid, returning ACP AuthRequired for session/model operations until the client runs graff login and restarts it.
  • Reuse the full engine's initialize responder and bound per-record parsing memory; oversized records are discarded through their newline without killing the process.
  • Restore an early fullscreen TUI claim before showing the existing missing-credential diagnostic.
  • Add registry-shaped subprocess and real-PTY regressions.

Why

Problem / failure mode

The ACP Registry installs and starts agents in an isolated HOME, then sends initialize to discover authentication. Graff advertised Terminal Auth only after resolveKeys; without a credential it exited first, so fresh registry installs could never discover or launch graff login. Registry PR agentclientprotocol/registry#558 therefore cannot pass its auth matrix while pinned to v0.0.280 (or v0.0.282).

Reason for this approach

The pre-auth loop has no fake provider and does not duplicate the initialize payload. It shares acp_engine.respondInitialize, serves only protocol/auth discovery, and returns the standard ACP auth-required error for operations needing an Agent. Once login succeeds, a restarted process follows the unchanged credentialed ACP runtime.

Constraints and trade-offs

Rejected alternatives

  • A dummy API key would make initialization pass while producing a broken session on the first model request.
  • Printing one initialize response and exiting would satisfy a narrow probe but violate ACP lifecycle semantics.
  • Duplicating auth metadata in a second responder would let the pre-auth and full runtimes drift.

Verification

  • Current ACP Registry auth checker: graff-login(terminal) passed
  • scripts/eval-tier1.sh: green
  • main suite: 1867 tests
  • TUI suite: 465/465
  • PTY/tuiguard: 17/17, including clean missing-credential tui and TTY repl
  • 2,048 near-limit pre-auth records reuse bounded scratch memory

Addresses #613. The issue closes after a release containing this change is pinned and merged in agentclientprotocol/registry#558.

Fresh registry installs launch  without credentials, but startup previously exited before reading initialize, making Terminal Auth unreachable. Add a bounded pre-auth ACP loop that shares the normal initialize response, rejects authenticated methods with ACP AuthRequired, restores early TUI claims before missing-key diagnostics, and reuses per-record parsing memory.\n\nThe credentialed ACP/TUI runtime remains unchanged; the registry listing must be repinned to the first release containing this commit.\n\nCo-Authored-By: Codegraff <blackfloofie@codegraff.com>
The pre-auth integration test sent its exact 65,535-byte boundary record through text-mode subprocess stdin. Windows newline translation could add a carriage return, making the accepted boundary appear oversized and dropping the first initialize response even though ACP behavior was correct.

Send explicit UTF-8 bytes so record lengths and delimiters are identical on every platform while retaining the real-binary EOF, oversize, ordering, and response assertions.

Co-Authored-By: Codegraff <blackfloofie@codegraff.com>
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