Skip to content

feat: support access: time-limited, audited operator access to job contents, shown to the customer - #15

Merged
LukiPrince merged 8 commits into
mainfrom
feat/support-access
Nov 14, 2026
Merged

LukiPrince merged 8 commits into
mainfrom
feat/support-access

Conversation

@LukiPrince

Copy link
Copy Markdown
Owner

Support access, PR 2 of the operator API: the operator of a hosted deployment can look at a customer's job contents for a limited time, every access is in the audit log, and the customer sees each one on their Settings page. Nothing changes without PRINTAPI_OPERATOR_TOKEN: every new /operator/ path stays 404, and GET /support-access answers {"enabled": false, "grants": []}.

Operator side (docs/operator.md#support-access)

  • POST /operator/orgs/{id}/support {reason ≥ 8, minutes: 15|30|60, org_created_at}: one grant for the whole org, at most one active at a time. It is bound to the org's generation, so a recreated org with a reused id inherits nothing.
  • DELETE /operator/support/{grant_id} ends the grant at once.
  • POST /operator/jobs/{id}/payload downloads the stored bytes. The audit row and reads + 1 are written in the same transaction before any byte goes out. The headers keep a browser from rendering it: application/octet-stream, attachment, nosniff, CSP: sandbox; default-src 'none', no-store. Answers: 403 without an active grant, 404 for an unknown job, 410 once retention has emptied the payload.
  • Titles only on request: GET /operator/orgs/{id}/jobs?titles=1. It answers 403 without a grant. With a grant, the response and a support.list_jobs row with the returned job ids are written in one transaction. Without titles=1 nothing is written, so a tab that refetches does not fill the log.
  • GET /operator/orgs/{id} gains support (the active grant or null). The overview reports features: ["support"].
  • New table support_grants, and an index on operator_audit(target). delete_org removes the org's grants; its audit rows stay.

Customer side (docs/api.md#support-access)

  • GET /support-access is open to browser sessions (own org; another org's ?org= answers 403) and to root (?org=, default org without it). An API key gets 401. It lists every grant that was used, plus the 50 newest unused ones, each with the listed and opened job ids.
  • New card "Support access" on the dashboard's Settings page, hidden when the feature is off. The demo answers enabled: false.

Fixes from the review (security review and Codex adversarial, read-only; each finding cross-checked):

  • usePoll fetched only once on mount, so the Settings page never loaded the chosen org. This hit the existing org card too, not only the new card. usePoll now takes a key.
  • The 50-entry cap let unused grants push a used one off the list. Used grants are now always listed.
  • A 401 on /support-access no longer signs the dashboard out.

Checks

  • cargo test --workspace 1033 passed, clippy -D warnings, fmt.
  • pytest tools/docs 102, agent 75, check_docs OK.
  • Parity: "785 steps: 759 pass, 0 diff, 26 known". --db-compat: 23/23.
  • web: lint, 181 tests, check:bundles, build:app.
  • By hand: release binary with the operator token, a customer session in headless Edge. The card shows the active and the ended grant with job ids. The payload headers were checked with curl.

No release (that would be 3.6.0, only after asking).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX

LukiPrince and others added 8 commits November 14, 2026 13:53
New table support_grants (+ index on org_id) and an index on operator_audit(target). Store
functions, each one begin() transaction with its audit row: grant, end by id, the audited payload
read (Scrubbed as its own outcome), the audited titled jobs page, the one definition of an active
grant, and the customer's grant history with listed/opened job ids. delete_org removes the org's
grants; audit rows stay. No HTTP routes yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
…nload, titles on request

POST /operator/orgs/{id}/support, DELETE /operator/support/{id}, POST /operator/jobs/{id}/payload
(raw bytes as a sandboxed download) and GET /operator/orgs/{id}/jobs?titles=1. The org page gains
"support", the overview reports the feature. Every read is audited in the store's transaction; a
failed audit row answers 500 and discloses nothing. docs/operator.md gets a Support access section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
… to their org

manager() gate: a session sees its own org (a foreign ?org= is 403), root passes ?org= or reads
the default org (404 for an unknown one), an API key is 401. Answers {enabled, grants}, newest
first, at most 50, current org generation only, with the listed and opened job ids from the audit
rows. With the operator token unset: {"enabled": false, "grants": []}.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
…p out of view

The review of the support-access branch found two things:

- usePoll ran its fetcher once on mount and never again when the fetcher's
  inputs changed (the fetcher is deliberately no effect dependency). Settings
  mounts before /me answers, so the org card and the new Support access card
  both fetched "no org" once and stayed empty. usePoll takes a key now: a new
  key fetches at once and drops the old data. Checked in headless Edge against
  a local server with a session, an active and an ended grant.
- GET /support-access capped the list at the 50 newest grants, so 50 empty
  grants in a row could push a used one out of the customer's view. Every used
  grant (reads > 0) stays listed; only the unused ones are capped at 50.

A 401 on /support-access (an API key) no longer signs the dashboard out, like
/orgs and /users.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
The Settings bug went unnoticed because nothing ran the hook. This renders the
real hook under node with just enough DOM for react-dom, and fails on the old
deps (3 of 4 tests red without `key` in the effect).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX
@LukiPrince
LukiPrince merged commit 1ba4bb7 into main Nov 14, 2026
29 checks passed
@LukiPrince
LukiPrince deleted the feat/support-access branch November 14, 2026 13:44
@LukiPrince LukiPrince mentioned this pull request Nov 14, 2026
LukiPrince added a commit that referenced this pull request Nov 14, 2026
Support access (#15) and live settings (#16). The example version in
docs/operator.md follows.


Claude-Session: https://claude.ai/code/session_01TEvvb3zrZ3bLSGJbCBaEYX

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.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