docs: document module database access
Add ADR 0016 recording the accepted module database access design (ModuleDatabase, the frozen ModuleRuntimeServices boundary, one pool/one facade/one services-object identity, explicit migrations, and the trust model), with narrow cross-reference corrections to ADR 0006 and ADR 0015 where their original text is now inaccurate. Sweep docs/development/api.md, docs/development/authorization.md, docs/module-development/README.md, docs/development/testing.md, and docs/development/identity.md for the new database boundary and remaining Phase 4C staleness; correct the stale "Phase 4C is next" roadmap paragraph in platform-architecture.md and the matching gap in README's current-status narrative. Extend the module template with a permissioned GET /records route reading through context.services.database, using the canonical createModuleTable helper, with matching template tests.
This commit is contained in:
@@ -162,6 +162,16 @@ configured trusted origin — never a wildcard, and never anything module-influe
|
||||
|
||||
### A frozen, minimal handler context and sanitized failure boundary
|
||||
|
||||
> **Cross-reference — see [ADR 0016](0016-module-database-access.md).**
|
||||
> "A frozen context of exactly `moduleId`... and an immutable, Hono-decoded parameter record" and "A
|
||||
> handler never receives a Hono `Context`, a database connection... or any other middleware-internal
|
||||
> state," below, described the handler context's complete shape accurately at the time. ADR 0016
|
||||
> adds a fourth field, `services`, carrying `ModuleRuntimeServices` (currently just a typed
|
||||
> `ModuleDatabase` facade) — never a raw database connection, `pg.Pool`, `PoolClient`, connection
|
||||
> string, or other infrastructure object. Every other statement in this section remains accepted and
|
||||
> unchanged: a handler still never receives a Hono `Context`, the authorization store or evaluator,
|
||||
> raw PostgreSQL access, configuration, or secrets.
|
||||
|
||||
A handler receives the unmodified Fetch `Request` (`c.req.raw`, so `Request.url`, headers, method,
|
||||
body, and a streaming request all behave normally, and the full query string remains available
|
||||
without a competing query abstraction) and a frozen context of exactly `moduleId`, the
|
||||
@@ -276,6 +286,10 @@ runs, since nothing about this design sandboxes it.
|
||||
|
||||
## Deferred
|
||||
|
||||
> **Cross-reference — see [ADR 0016](0016-module-database-access.md).**
|
||||
> Module database or Drizzle access, listed immediately below as deferred, is now implemented.
|
||||
> Every other item in this list remains deferred and unimplemented.
|
||||
|
||||
Module database or Drizzle access; module storage access; jobs and workflow/event automation;
|
||||
module-owned configuration and secrets services; a `ModuleRuntimeContext` authorization service;
|
||||
relationship-derived grant operations; reinstall/reactivation semantics for a permission or route
|
||||
|
||||
Reference in New Issue
Block a user