Repository navigation
E5: engagement authorization artifact in the target gate, hash-chained audit schema - #31
Merged
Merged
Conversation
…d audit schema Migration 0016: audit_chain (append-only, SHA-256 linked, row triggers on intercept_pending/artex_users/engagement_authorizations), artex_users, engagement_authorizations (versioned, immutable rows). The artifact (scope, time window, technique classes) is consulted inside the existing target gate: run() and ungated() check it first, and target-less calls go through authorizeCall from CheckTargets/CheckUngated. Refusals are decided intercept rows. Card c-669406. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tamper tests
GET/POST /api/tasks/{id}/authorization, POST .../revoke;
GET /api/intercept/history/chain and /chain/verify. Verification recomputes
every hash, checks seq continuity and the head row, and compares each
intercept history row with its newest chain entry. Card c-669406.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… users API, docs Console users in artex_users; tokens carry uid/uv and are checked against the row on every request (fails closed). The legacy ARTEX login stays admin. requireAuth enforces a declarative route policy (server/rbac_policy.go) matched on the mux pattern; refusals answer 403 and are appended to the audit chain. Logins are audited. Fix: the authorization check no longer claims the call's trace entry unless it refuses (kept exact intercept correlation). docs/GOVERNANCE.md documents roles, the artifact and the chain. Card c-669406. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ify, tighter reads - spawn_task: the child inherits the caller's current artifact (read from the call's scope); a revoked/expired artifact refuses the spawn, and the gate keeps window/revocation on spawn_task. - Local tools return before the artifact lookup (never refused, no query). - Verify runs in one repeatable-read UTC snapshot; the row trigger pins UTC. - Reviewers lose raw traffic exchange/blob/HAR/stream and conversation messages. - change-password is limited to the ARTEX session; actor names reserved; control characters stripped from audited usernames. - Docs and CHANGELOG. Card c-669406. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ck no longer stalls gate writes (c-ba9f64) The intercept_pending, artex_users and engagement_authorizations audit triggers become DEFERRABLE INITIALLY DEFERRED constraint triggers. The audit_chain_head lock is now taken only during COMMIT, after every other lock, so a task archive no longer stalls gate decisions, logins and rbac.denied entries, and write-then-lock transactions cannot deadlock on the head. Concurrency tests reproduce both failures without 0018. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
client_read was global: a client account for company A could read every
client's findings, reports and exports. Bindings now live in
artex_user_companies (migration 0019, audited at commit like the other
governance tables) and are managed at GET/PUT /api/users/{id}/companies.
Every route rbacPolicy opens to client_read has a binder (client_scope.go)
that runs after the role check: findings routes are narrowed to the bound
company through the BaaRai#425 company filter, ids and tasks outside the binding
answer 404, an unbound client gets 403, and a route without a binder is
refused. Task ownership and the unanchored-finding fallback count only
operator-made company scope rows, so an agent cannot widen what a client
sees. The client report and stats no longer carry global asset/traffic
counts. Live retests across all clients moved to the read permission.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… for c-869050 web UI # Conflicts: # HANDOFF.md
…e-filtered sidebar, username login (c-869050) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ify; client_read-safe sidebar (c-869050) - /system/users (admin): table with inline role/enabled, set password, delete, client_read company bindings, add-user dialog. - Task detail Authorization tab: current version + status badge, version history table, admin-only new-version form and revoke. - Approval Records: Approvals | Chain tabs; chain table with filters, paging, entry sheet, Verify (head_seq/head_hash, broken_at, rows_mismatched). - client_read sessions skip the company switcher and the global retest poll. - verify.sh runs the governance unit tests and the i18n check; tr/zh-CN strings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # HANDOFF.md # db/migrate_test.go
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Nov 24, 2026
cybersicilian
added a commit
that referenced
this pull request
Nov 24, 2026
…(c-13e86c) (#41) * web: open SSE streams same-origin so the session cookie reaches them (c-13e86c) Since the session moved to an HttpOnly cookie, getToken() returns null, but sseUrl still sent non-production builds (next dev) straight to <host>:8787. That cross-origin EventSource carries no cookie and no token, so every connect answered 401 and the Sessions tab showed Reconnecting. Other calls went through the same-origin /api rewrite and worked. Predates E5. - web/src/lib/sse.ts: sseUrl is always a same-origin /api/ path (throws otherwise); NEXT_PUBLIC_SSE_BASE is removed (a cross-origin stream cannot present the cookie, and CORS '*' forbids credentials). - next.config.mjs: compress:false in dev, measured: with a browser's Accept-Encoding the rewrite gzips and buffers the stream; without compression frames arrive as sent. - server: PG test signs in through the login handler as the bootstrap ARTEX admin and as a console user, then opens the activity stream with only the cookie and reads a frame; no session -> 401. Co-Authored-By: Claude Opus 5.5 <[email protected]> * server: SSE streams send a first comment when they open (c-13e86c) streamActivity and streamLogs flushed only headers until the first event or the 20 s ping. The Next.js dev rewrite passes headers on only with a first body byte, so the EventSource stayed unopened and the Sessions tab showed Reconnecting for 20 s on an idle task (measured: TTFB 20.0 s through next dev, immediate direct). openSSE sets the SSE headers and writes ': open'. The PG test now asserts the comment is the first line. Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: c-13e86c state, gotchas, decision Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: condense the E5 entry to its on-main state (#31) so Current state fits Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: move the 2026-11-23 audit's operator-facing list to docs/handoff/ Co-Authored-By: Claude Opus 5.5 <[email protected]> * HANDOFF: deltas stamp (c-13e86c) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs BaaRai#425
Why
E5 follow-up: web UI for users, task authorization and audit chain
What: the E5 backend has no UI.
GET/POST/PATCH/DELETE /api/users.GET/POST /api/tasks/{id}/authorizationplus/revoke, with technique classes fromtechnique_classes.GET /api/intercept/history/chainand a Verify button on/chain/verifythat showshead_seq/head_hashand the mismatched rows.roleandpermissionsthatGET /api/auth/sessionnow returns, and handle 403 without logging out.What changed
E5: engagement authorization artifact in the target gate, hash-chained audit schema (7417d80)
Migration 0016: audit_chain (append-only, SHA-256 linked, row triggers on
intercept_pending/artex_users/engagement_authorizations), artex_users,
engagement_authorizations (versioned, immutable rows).
The artifact (scope, time window, technique classes) is consulted inside the
existing target gate: run() and ungated() check it first, and target-less calls
go through authorizeCall from CheckTargets/CheckUngated. Refusals are decided
intercept rows. Card c-669406.
E5: authorization and audit-chain endpoints, chain verification with tamper tests (b5c74e9)
GET/POST /api/tasks/{id}/authorization, POST .../revoke;
GET /api/intercept/history/chain and /chain/verify. Verification recomputes
every hash, checks seq continuity and the head row, and compares each
intercept history row with its newest chain entry. Card c-669406.
E5: governance endpoints read the task id from the path, HTTP test (aa90ed4)
E5: RBAC (admin/operator/reviewer/client_read) over the existing JWT, users API, docs (50384f0)
Console users in artex_users; tokens carry uid/uv and are checked against the
row on every request (fails closed). The legacy ARTEX login stays admin.
requireAuth enforces a declarative route policy (server/rbac_policy.go) matched
on the mux pattern; refusals answer 403 and are appended to the audit chain.
Logins are audited. Fix: the authorization check no longer claims the call's
trace entry unless it refuses (kept exact intercept correlation).
docs/GOVERNANCE.md documents roles, the artifact and the chain. Card c-669406.
E5: review fixes — spawn_task inherits the artifact, snapshot/UTC verify, tighter reads (7bd8478)
call's scope); a revoked/expired artifact refuses the spawn, and the gate
keeps window/revocation on spawn_task.
control characters stripped from audited usernames.
HANDOFF: E5 state, triage, decisions, follow-up cards (934ba39)
HANDOFF: renumber triage (12a9480)
HANDOFF: deltas stamp (b59577d)
db: chain audit row entries at commit (migration 0018) so the head lock no longer stalls gate writes (c-ba9f64) (730ddb1)
The intercept_pending, artex_users and engagement_authorizations audit
triggers become DEFERRABLE INITIALLY DEFERRED constraint triggers. The
audit_chain_head lock is now taken only during COMMIT, after every other
lock, so a task archive no longer stalls gate decisions, logins and
rbac.denied entries, and write-then-lock transactions cannot deadlock on
the head. Concurrency tests reproduce both failures without 0018.
HANDOFF: deltas stamp (c-ba9f64) (6d78d3a)
E5: bind client_read users to their companies (c-5b5421) (ed9dfc4)
client_read was global: a client account for company A could read every
client's findings, reports and exports. Bindings now live in
artex_user_companies (migration 0019, audited at commit like the other
governance tables) and are managed at GET/PUT /api/users/{id}/companies.
Every route rbacPolicy opens to client_read has a binder (client_scope.go)
that runs after the role check: findings routes are narrowed to the bound
company through the feat(web): global company switcher in the sidebar BaaRai/ARTEX#425 company filter, ids and tasks outside the binding
answer 404, an unbound client gets 403, and a route without a binder is
refused. Task ownership and the unanchored-finding fallback count only
operator-made company scope rows, so an agent cannot widen what a client
sees. The client report and stats no longer carry global asset/traffic
counts. Live retests across all clients moved to the read permission.
docs: client binding (c-5b5421) in GOVERNANCE, CHANGELOG, HANDOFF (b6682a1)
HANDOFF: deltas stamp (c-5b5421) (f2b2f6f)
web(E5): session role/permissions context, governance API client, role-filtered sidebar, username login (c-869050) (59e85fe)
web(E5): Users page, task Authorization tab, audit Chain tab with Verify; client_read-safe sidebar (c-869050) (60e20d8)
client_read company bindings, add-user dialog.
history table, admin-only new-version form and revoke.
entry sheet, Verify (head_seq/head_hash, broken_at, rows_mismatched).
HANDOFF: E5 web UI state, triage, decisions, follow-up cards (c-869050) (6bb0a97)
HANDOFF: shorten c-869050 current-state entry (7f9af4f)
HANDOFF: deltas stamp (c-869050) (f0debbf)
Files changed
Tests touched:
db/audit_chain_concurrency_test.go,db/governance_test.go,db/migrate_test.go,db/users_test.go,intercept/authorization_test.go,intercept/target_gate_test.go,server/auth_cookie_test.go,server/client_scope_pg_test.go…72 files, +7182 −123
web/src/components/audit-chain.tsxdb/authorization.goserver/client_scope.goserver/rbac_policy_test.goserver/rbac_pg_test.goweb/src/app/(main)/function/tasks/detail/_tabs/authorization-form.tsxserver/users_api.godb/audit_chain.goserver/governance_api.goserver/rbac.goserver/client_scope_pg_test.godb/governance_test.godb/users.goserver/rbac_policy.gointercept/authorization_test.godb/migrations/0016_engagement_governance.sqldb/audit_chain_concurrency_test.goweb/src/app/(main)/system/users/page.tsxweb/src/app/(main)/system/users/_components/user-row.tsxdocs/GOVERNANCE.mdintercept/authorization.goweb/src/app/(main)/system/users/_components/add-user-dialog.tsxdb/user_companies.goweb/src/app/(main)/function/tasks/detail/_tabs/authorization-tab.tsxweb/src/lib/governance-types.tsHANDOFF.mdserver/governance_api_test.goweb/src/app/(main)/function/tasks/detail/_tabs/authorization-parts.tsxweb/src/app/(main)/system/users/_components/companies-dialog.tsxintercept/technique.goweb/src/app/(main)/system/users/_components/password-dialog.tsxdb/users_test.goweb/src/i18n/locales/tr.jsonweb/src/i18n/locales/zh-CN.jsonweb/src/components/audit-chain-verify.tsxweb/src/lib/governance.tsweb/src/app/(main)/function/tasks/detail/_tabs/authorization-history.tsxweb/src/lib/governance-api.tsweb/src/lib/governance.test.mjsweb/src/app/(main)/layout.tsxserver/auth.godb/migrations/0018_audit_chain_deferred.sqlweb/src/lib/auth.tsweb/src/components/audit-chain-detail.tsxserver/client_scope_test.goserver/server.goweb/src/navigation/sidebar/sidebar-items.tsdb/migrations/0019_user_company_bindings.sqlweb/src/app/(auth)/login/page.tsxweb/src/hooks/use-session.tsxdb/findings.goweb/src/components/audit-chain-format.tsintercept/target_gate.goweb/src/app/(main)/_components/sidebar/nav-user.tsxweb/src/app/(main)/system/intercept/approvals/page.tsxweb/src/app/(main)/system/users/_components/role-label.tsweb/src/app/(main)/_components/sidebar/app-sidebar.tsxserver/orchestration.goweb/src/lib/api-errors.tsserver/auth_cookie.goOpened by Composite ·
ej/20261124-132958-94f4bf→main· cardc-869050· run20261124-132958-94f4bf🤖 Generated with Claude Code
Summary by cubic
Adds engagement governance: console user roles (
admin/operator/reviewer/client_read), per-task authorization artifacts enforced inside the target gate, and a hash-chained audit log over the intercept history, with the web UI to manage and verify them.New Features
server/rbac_policy.go) fails closed on refusals (403, never logout).client_readusers are bound to companies: findings, tasks, reports, stats, and exports narrow to the binding, out-of-binding ids answer 404, and unbound clients get 403 everywhere.Bug Fixes
rbac.deniedentries behind the chain head lock, and write-then-lock transactions can no longer deadlock on it.Written for commit f0debbf. Summary will update on new commits.