Files
hub/tasks/architecture/storage/resolve-sessions-accountid-cascade.md
glm-5.1 2b63cda1c7 Setup repo: migrate architecture specs, code stubs, and tasks from alkhub_ts
Copy architecture docs, ADRs, storage domain specs, research, reviews,
and 56 storage architecture tasks from the alkhub_ts monorepo. Adapt for
standalone @alkdev/hub repo structure (src/ not packages/hub/).

Sanitize all sensitive information:
- Replace private IPs (10.0.0.1) with localhost defaults
- Remove internal server hostnames (dev1, ns528096)
- Replace /workspace/ private paths with npm package references
- Remove hardcoded credentials from examples
- Rewrite infrastructure.md without private network details

Add Deno project scaffolding: deno.json (pinned deps), .gitignore,
AGENTS.md, entry point. Migrate existing code stubs (crypto, config
types, logger) with updated import paths.
2026-05-25 10:56:32 +00:00

1.7 KiB

id, name, status, depends_on, scope, risk, impact, level
id name status depends_on scope risk impact level
resolve-sessions-accountid-cascade Resolve sessions.accountId NOT NULL + SET NULL contradiction completed
narrow critical phase implementation

Description

sessions.accountId is declared text NOT NULL in sessions.md:17 but has onDelete: SET NULL in table-reference.md:80. PostgreSQL will reject the DELETE because it cannot nullify a NOT NULL column. This is a foundational schema decision — the resolution determines whether sessions survive account deletion and affects downstream cascade work.

Decision (D1)

Make the column nullable with SET NULL cascade. Orphaned sessions (account deleted) are still valuable data for audit and debugging. This follows the "live session data: nullable FK + SET NULL" cascade pattern.

Acceptance Criteria

  • sessions.accountId is declared text (nullable) in sessions.md with an explicit note explaining why
  • table-reference.md cascade entry for sessions.accountId → accounts.id uses SET NULL and the column is documented as nullable
  • No other doc references sessions.accountId as NOT NULL without acknowledging the nullable change
  • The doc note explains the semantic: "orphaned sessions preserve conversation history for audit and debugging"
  • Any downstream tasks that depend on this decision (e.g., resolve-org-dual-ownership) can proceed

References

  • docs/reviews/storage-architecture-review-2026-04-21.md#C01
  • docs/decisions/storage-spec-phase1-resolutions.md#D1
  • docs/architecture/storage/sessions.md:17
  • docs/architecture/storage/table-reference.md:80

Notes

To be filled by implementation agent

Summary

To be filled on completion