Public: anyone can read this; the crew can change it.

See what outside agents tried: a compact, redacted request log the owner can read #1231

Closed opened this
Closed without merging

The forge now writes a compact, redacted line for each non-asset request. A forge admin can read the last day's non-browser requests on a settings page and through an MCP tool. tsc is clean.

Notes

stopped closed without shipping deploy 50ca42e

opened this

The forge now writes a compact, redacted line for each non-asset request. A forge admin can read the last day's non-browser requests on a settings page and through an MCP tool.

tsc is clean. The new test/access-log.test.ts passes (6 tests), but only with a local patch that I reverted. The sandbox refuses the unix-socket listen in serve(), so every test that boots a server fails here, including reserved-names. I didn't run studio or the other gate-list files. The forge's check will be the first real run of those.

  • Log: src/http/access_log.ts writes JSON lines to <data>/access/access-YYYY-MM-DD.log. Each line has time, host, method, path without the query string, status, duration, user agent (200 characters), whether a credential came with it, and a client hash.
  • Hash and redaction: the hash is an HMAC of the address, keyed with the data-dir secret and the day, so it can't be followed across days. Only those fields are read: no cookie, token, query string or body is ever written. Path segments that look like secrets are replaced with :redacted, and control characters are stripped.
  • Keeping: files older than 14 days are deleted, and one day's file stops growing at 4 MB. The whole directory is capped at 32 MB, deleting the oldest first. No route serves the files. A write failure never fails a request.
  • Hook: src/http/server.ts wraps the existing fetch handler so it logs every answered request. App-host traffic is logged too, with its host.
  • Page: /settings/access is admin-only, with a user-agent filter and a path filter. Non-admins get a 404, and output is escaped.
  • MCP: the access {since, ua?, path?} tool returns up to 500 requests, newest first. It is marked as a write tool, so a read-only token is refused. Non-admins and agents get not_found.
  • Read view: it shows non-browser requests (user agent without Mozilla/) to /issues, /api/, /mcp, /.well-known/, /llms.txt, /signin and /signup.
  • Docs and gate: the "access log" section in docs/APPS.md describes it, and the test file is added to GATE.
  • Tests: they cover redaction (a token, cookie and query string never reach the file), the admin and write-scope gates, escaping on the page, and daily rotation, pruning and the size cap.

What I left out or chose:

  • /healthz is not logged along with static assets, because probes would fill the file.
  • "Signed in" means a forge_session cookie or an Authorization header was present. It isn't checked against a real session, to keep the hot path free of lookups.
  • A browser that doesn't say Mozilla/ in its user agent counts as non-browser, and an agent that fakes Mozilla/ is hidden from this view (it is still in the file).
  • There is no screenshot, because the sandbox can't boot the server.

To try it, sign in as the admin, send curl -A TestAgent/1 localhost:3000/api/v1/x, and open /settings/access. Or call the access tool with a write-scope token.

Closes #1061

commented

Parked by the crew: the check failed ("the forge over MCP > it speaks the protocol: initialize, a notification, ping, tools/list") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs