ARCH-01 — PostgreSQL actor context, roles, privileges, and connection-pool safety #827
Open
opened 2026-07-22 19:44:38 -05:00 by jcwalker3
·
0 comments
No Branch/Tag Specified
master
fix/issue-790-slice-a-heartbeat-policy
feat/issue-628-autonomous-handoffs-orchestration
feat/issue-634-readonly-system-health-api
feat/issue-638-webui-app-shell-phase1
fix/issue-840-cross-role-queue-allocation
feat/issue-822-atomic-install-authority-kernel
feat/issue-633-console-authz-audit-model
feat/issue-636-inventory-api
fix/issue-815-preflight-worktree-forwarding
feat/issue-812-publish-unpublished-commit
feat/issue-635-project-registry-api
feat/issue-798-worker-registry-schema
feat/issue-610-live-remote-parity
docs/issue-632-web-console-architecture
fix/issue-760-exact-owner-renewal
fix/issue-787-kill-segment-separators
chore/issue-681-preserve-review-session-wip
v1.1.0
Labels
Clear labels
allocator
anti-stomp
architecture
bug
chore
codex
concurrency
contamination
control-plane
dashboard
database
design
documentation
enhancement
gitea
glitchtip
important
incident
incident-bridge
integration
jenkins
labels
leases
mcp
mcp-health
mcp-menu
multi-project
mutating
nice-to-have
observability
portability
preflight
protected-branch
queue
read-only
reconnect
recovery
refactor
release
reliability
resumable-review
reviewer
roadmap
safety
security
self-hosted
sentry
stale-runtime
status:blocked
status:in-progress
status:pr-open
status:ready
terminal-lock
testing
tracker
type:bug
type:feature
type:feature
type:guardrail
visibility
workflow
workflow-hardening
workflow-hardening
Controller-owned work allocator
Prevent concurrent LLM session stomping
Architecture / structural design
OpenAI Codex client / workflow session surface
Concurrent session safety
Workflow or session contamination incident
MCP control-plane coordination and allocation authority
MCP operational dashboard/queue view
Internal coordination storage (SQLite/Postgres)
Design / investigation, no implementation
Docs / runbooks
New feature or improvement
Gitea MCP workflow
GlitchTip integration
Operational or process incident requiring durable audit trail
Sentry-to-Gitea incident bridging
Integration testing
Jenkins integration
Label taxonomy management
Lease adopt/release/expire lifecycle
MCP server / tooling
MCP namespace and runtime health
MCP menu surface
Work spanning multiple monitoring projects or Gitea repos
Mutating action; requires gating
Observability, metrics, traces, error reporting
Cross-platform / portability
Shared preflight gates before mutation
Protected branch / stable-branch policy concern
Work queue visibility and allocation
Read-only, no mutation
MCP client reconnect/reload recovery path
Recovery paths for stale/foreign leases
Code refactor / restructure
Release / versioning
Reliability / failure handling
Persist and resume prepared review verdicts across sessions
Reviewer workflow tooling
Roadmap / umbrella issue
Safety rails and fail-closed mutation guards
Security / trust boundary
Self-hosted infrastructure integration
Sentry error monitoring integration
Stale backend daemon / runtime-vs-master parity failures
Issue is blocked
Issue is being worked on
Issue has an open pull request
Issue is ready for work
Terminal review lock (#332) path
Tests / test coverage
Issue tracker hygiene / meta
Bug or defect
Feature or enhancement
Feature or enhancement
Safety gate or guardrail
Workflow state visibility for LLMs/operators
Cross-tool workflow
LLM workflow coordination hardening
LLM workflow coordination hardening
Milestone
No items
No Milestone
Projects
Clear projects
No projects
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Scaled-Tech-Consulting/Gitea-Tools#827
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Candidate architecture requiring executable validation; not yet approved, production-ready, or certified.
Parents: #820, #821. Depends on: #822, #823, #824, #825, #826 (SQLite semantics to mirror).
1. Summary / objective
Bring the ARCH-01 authority/identity/evidence kernel to PostgreSQL parity with an accurate trust boundary: table-owner/service-role separation, restricted privileges, transaction-scoped actor context, and pool-reset safety.
2. Security/correctness problem
SET LOCAL app.actoris service-mediated, not independently DB-authenticated: PG cannot knowapp.actormatches the transport-authenticated caller. Misstating this, or letting the table owner be the connection role, silently voids the boundary.3. Threat model / failure modes
cp_servicewriting base tables directly (bypassing triggers); a leaked/staleapp.actoron a pooled connection; PUBLIC EXECUTE/CREATE enabling shadow objects; search_path hijack; row-security/ownership bypass; SECURITY DEFINER owned by a writable role.4. In-scope behavior
[TRUSTED-SERVICE]; DB functions verify consistent use of service-supplied context; possession ofcp_serviceis privileged.cp_owner(NOLOGIN, owns allcp.*),cp_service(LOGIN, EXECUTE on SECURITY DEFINER mutation functions, no table DML),cp_migration,cp_backup,cp_readonly.REVOKE ALL ON ALL TABLES … FROM PUBLIC, cp_service;REVOKE EXECUTE ON ALL FUNCTIONS … FROM PUBLIC;REVOKE CREATE ON SCHEMA cp FROM PUBLIC, cp_service.SETeach context GUC (app.actor,app.mode,app.service_session,app.epoch) — only inside definer functions.search_path=pg_catalog,cppinned on every definer function; schema-qualify every object.cp_servicecreating shadow objects (no CREATE).cp_service.cp_service.DISCARD ALL(or verifiedapp.*reset) before return.5. Exclusions
No new authority semantics — mirrors #822–#826. No ARCH-02/04.
6. Schema/operation contracts
PG migrations creating roles/privileges + SECURITY DEFINER wrappers for every ARCH-01 mutation; triggers read
current_setting('app.*', true), NULL ⇒ fail closed.7. SQLite behavior
Reference only (parity target); no SQLite change.
8. PostgreSQL behavior
As §4;
SET LOCALtransaction-scoped; NULL context aborts.9. Concurrency / transaction requirements
Pool-return reset prevents context leakage across requests; readiness test asserts no residual
app.*afterDISCARD ALL.10. Structured results
INVALID_ACTOR_CONTEXT,AUTHORIZATION_DENIED,READINESS_FAILED, plus parity results from #822–#826.11. Enforcement classification
Role/privilege separation, definer ownership
[SCHEMA]/DB-privilege; actor authenticity[TRUSTED-SERVICE].12. Acceptance criteria
cp_servicecannot INSERT/UPDATE/DELETE base tables directly (permission denied).app.actorfails closed on every mutation.cp.cp_owner.app.*; a leaked context is not observable on the next checkout.13. Named tests
t_pg_direct_write(−),t_pg_null_context(−),t_pg_public_execute(−),t_pg_search_path(+),t_pg_pool_leak(readiness),t_pg_parity_install/t_pg_parity_grant/t_pg_parity_merge/t_pg_parity_evidence(+).14. Audit events / evidence
Same as mirrored issues; plus a readiness report asserting the privilege posture.
15. Dependencies / parent
Parents #820, #821; depends #822–#826.
16. Definition of done
PG migration executes; privilege posture proven; parity tests pass; readiness assertion required before enablement; bounded PR; no self-review/merge.
17. Known limitations / deferred
This is service-mediated authorization, not independent DB authentication — stated, not worked around. ARCH-02/04 PostgreSQL parity are separate.