30 Commits

Author SHA1 Message Date
ae242f33b9 Restructure identity tables: separate credential types, add peer_credentials, specify FK cascades and indexes
Identity tables were derived from hub's PostgreSQL schema but simplified
without documenting what was removed or why. This restructures them for the
current auth landscape (API key + wraith SSH/cert-authority):

- ADR-049: Separate api_keys and peer_credentials tables (different lookup
  patterns, columns, lifecycles), remove Gitea columns, map hub data→metadata
- ADR-050: Extract SHA-256 vs KDF decision from inline spec text
- Add peer_credentials table for SSH key and cert-authority auth
- Specify all FK cascade behaviors within system DB (RESTRICT, CASCADE, SET NULL)
- Complete index specifications for all identity tables
- Add scope boundary section (storage owns schemas, not auth/authorization)
- Update audit_logs with credentialId+credentialType polymorphic reference
- Add 3 new open questions (OQ-33/34/35) for credential type expansion
2026-06-02 12:33:20 +00:00
412ad98f11 Pivot: fold drizzlebox as utils, HonkerEventTarget, OperationSpecs as repo surface
- Update architecture docs to reflect pivot from @libsql/client to Honker
- Fold @alkdev/drizzlebox Phase 0 into src/sqlite/utils/ (ADR-046)
- Add HonkerEventTarget adapter for pubsub TypedEventTarget (ADR-047)
- Replace hand-written CRUD with OperationSpec generation (ADR-048)
- Resolved OQ-26: Honker replaces Redis for single-node pub/sub (POC validated)
- Updated OQ-17, OQ-18, OQ-19 for OperationSpec repository surface
- Added OQ-30 (composite event target), OQ-31 (consumer naming), OQ-32 (Drizzle Kit)
- POC results: adapter buildable, same-process pub/sub works, transactional
  outbox semantics confirmed, concurrent listeners/streams work
- Research doc at docs/research/pivot-honker-sqlite-adapter.md
2026-06-01 16:31:40 +00:00
6aa2fcc6ff Architect storage around SQLite+Honker: remove PG, add multi-tenant identity, scoping
Reorient @alkdev/storage around a single SQLite database host with Honker
for pub/sub, event streams, and task queues. PostgreSQL is removed as a
target (ADR-038), eliminating dual schema maintenance and infrastructure
complexity. Honker provides DB + pubsub + queues in one .db file (ADR-039).

Add system/tenant DB model (ADR-040): identity tables in system.db, all
graph data in tenant-{orgId}.db files. Identity tables move from the hub
into storage (ADR-041). Scoping columns (ownerId, projectId) added to
graphs table (ADR-042). Graph types get scope (system/tenant/user) to
protect infrastructure schemas (ADR-043).

Define Drizzle-Honker session adapter (ADR-044): ~100-line adapter enabling
Drizzle typed queries and Honker pubsub/queue on a single connection with
transactional consistency.

Resolve OQ-03, OQ-04, OQ-19, OQ-21, OQ-22, OQ-23, OQ-24. Add new
open questions OQ-26 through OQ-29 for Honker integration specifics.

New docs: honker-integration.md (adapter, event patterns, migration).
Scrub all PG/jsonb/libsql references from existing spec docs.
2026-05-31 15:41:41 +00:00
6b5f32bad4 Add ACL graph architecture spec with principal-agent framework
- New acl.md: AclGraph Module definition (PrincipalNode, ResourceNode,
  DelegatesEdge, ScopesEdge, MemberEdge), principal-agent hierarchy
  with no-escalation invariant, setup-time vs runtime separation,
  multi-parent aggregation rules, cycle detection, scope semantics
- ADR-034: ACL as metagraph (not domain-specific tables)
- ADR-035: Actors become PrincipalNode entries, standalone table removed
- ADR-036: Principal-agent as DelegatesEdge with scope narrowing
- ADR-037: Setup-time definitions seed graph types, runtime instances
  are separate graphs
- Resolve OQ-03 (actors table design) — actors become ACL nodes
- Add OQ-20 through OQ-25 (delegation expiration, evaluator location,
  graph instance lifecycle, BelongsToEdge derivation, identityId
  references, scope string semantics)
- Update README.md and overview.md to reflect new doc and ADRs
- Note: multi-tenancy / graph scoping problem (no ownerId/scopeId on
  graphs table, no identity tables at this level) still needs
  resolution — identity and org tables will likely need to be added
  at this level for referential integrity
2026-05-31 07:11:59 +00:00
a2ee452a63 Add repository layer strategy: JSON path queries, CRUD decisions, ecosystem integration
Add three open questions (OQ-17, OQ-18, OQ-19) covering attribute query
strategy, CRUD generation approach, and storage-operations bridge placement.
Create ADR-033 recording the v1 decision: JSON path queries for attributes
with hand-written CRUD for static tables.

Expand forward-look.md with Repository Layer Strategy section analyzing
three approaches (JSON path, native columns via dbtype, hybrid) and their
implications for the metagraph pattern. Add drizzle-graphql and dbtype
from-dbtype comparison showing neither handles dynamic schema-as-data.

Update overview.md with dbtype/ujsx in the dependency diagram, expanded
ecosystem context in the bridging pattern section, and new open questions.

Align open-questions.md: resolve OQ-17 and OQ-18 for v1 (ADR-033), add
OQ-19 as open, update summary counts and ADR impact table.
2026-05-30 11:02:49 +00:00
ed8710a7f5 Clean up architecture specs: remove stale references, align docs with code, improve readability
- Replace stale DD references (DD3, DD6, DD9, DD10) with proper ADR links
- Fix 'Open Question 1' → OQ-01/OQ-03 cross-references
- Rewrite metagraph-module.md 'Why TypeBox Modules' to describe capabilities
  directly instead of framing as SchemaBuilder replacement
- Remove 'Transition from SchemaBuilder' section, replace with Source Structure
- Clean up implementation path: strikethrough phases → status table
- Fix data model diagram: remove non-existent nodeTypeId, fix EdgeType label
- Align EdgeConstraints examples with actual code (add default values)
- Clarify validateNode/validateEdge error behavior in docs
- Align EncryptedDataSchema code example with actual implementation
- Fix overview.md: correct dependency table, update current state, fix TypeBox URL
- Fix forward-look.md garbled text about dbtype element migration
- Fix open-questions.md: correct OQ count (4→7 open), add summary table
- Update doc statuses: schema-evolution, encrypted-data, open-questions → reviewed
- Update AGENTS.md to reflect current implementation state
2026-05-30 09:12:24 +00:00
33e66bc414 Add reference graph type Modules (CallGraph, SecretGraph) 2026-05-29 12:27:20 +00:00
14c7fa4746 Add bridge.ts with moduleToDbSchema, validateNode, validateEdge 2026-05-29 12:23:46 +00:00
6f6cabaf42 Merge branch 'feat/drift/replace-types-exports' 2026-05-29 10:57:52 +00:00
7206044250 Replace types.ts standalone schemas with Metagraph Module re-exports
Delete types.ts and move all schema definitions to modules/metagraph.ts.
Named exports (GraphConfig, BaseNodeAttributes, BaseEdgeAttributes) use
Metagraph.Import() for -based references. Remove NodeType, EdgeType,
GraphSchema, GRAPH_BASE_TYPE, GraphBaseType (replaced by Module approach).
Update sqlite host imports to resolve from metagraph.ts.
2026-05-29 10:57:37 +00:00
09f8f7ef51 Add crypto module: encrypt, decrypt, generateEncryptionKey, EncryptedDataSchema 2026-05-29 10:57:02 +00:00
c999e24242 Merge branch 'feat/drift/metagraph-module'
# Conflicts:
#	src/graphs/mod.ts
2026-05-29 10:55:28 +00:00
79141d594d Create Metagraph Type.Module with Config, BaseNode, BaseEdge entries
Add src/graphs/modules/metagraph.ts exporting Metagraph as Type.Module()
with Config (Union defaults for type, Boolean defaults for multi/allowSelfLoops),
BaseNode (optional created/modified/metadata with Type.Unknown()), and
BaseEdge (type string, optional metadata with Type.Unknown()). Also export
GRAPH_STATUS const and GraphStatus TypeBox schema for sqlite host usage.
Update mod.ts to re-export from modules/metagraph.ts.
2026-05-29 10:55:18 +00:00
37a7fe2a14 Merge branch 'feat/drift/remove-schema-builder' 2026-05-29 10:53:43 +00:00
62ba181b7e remove SchemaBuilder — replaced by Type.Module() per ADR-009 2026-05-29 10:53:36 +00:00
aad9636150 Replace Type.Any() with Type.Unknown() across all source files
Type.Unknown() is canonical per ADR-012. Both produce identical JSON Schema
output but Unknown communicates intent. Changed in src/graphs/types.ts (metadata,
schema fields) and src/sqlite/tables/{nodes,edges}.ts (AttributesSchema).
2026-05-29 10:53:18 +00:00
2b0badd501 tasks: add drift sync tasks to align source with architecture specs 2026-05-29 10:41:15 +00:00
62f8da8ec4 docs: formalize architecture pattern in architect role and SDD process
- Update architect.md to codify the ADR/OQ/README pattern:
  - decisions/ directory with numbered ADRs (not inline)
  - open-questions.md with OQ-IDs (not scattered per-doc)
  - README.md as index with doc table and ADR table
  - Spec docs reference ADRs and OQs by number
  - Document lifecycle states (draft/reviewed/stable/deprecated)
  - Anti-patterns updated for the new pattern
- Update sdd_process.md:
  - Phase 1 (Architecture) now specifies the full doc structure
  - Document Structure section updated with ADR/OQ format templates
  - Architect role deliverables updated
  - Architecture Reviewer checks updated for structural issues
  - Spec document Design Decisions section format specified
2026-05-29 08:58:57 +00:00
67ccfbf928 docs: restructure architecture docs to flowgraph pattern
- Create decisions/ directory with 32 numbered ADRs (ADR-001 through ADR-032)
  extracted from inline DD/SD/ED/SE decision sections
- Create open-questions.md with 16 OQs organized by theme, cross-referenced
  to ADRs, with status tracking (resolved/open)
- Create README.md as architecture index with doc table, ADR table, and
  lifecycle status definitions (draft/reviewed/stable/deprecated)
- Replace inline decision sections in all spec docs with ADR reference tables
- Replace inline open questions with OQ references to centralized tracker
- Update frontmatter: metagraph-module.md, overview.md, sqlite-host.md → reviewed;
  schema-evolution.md and encrypted-data.md remain draft
- DD1-DD10 → ADR-009 through ADR-018
- D1-D8 → ADR-001 through ADR-008
- SD1-SD5 → ADR-019 through ADR-023 (SD5 folded into ADR-006/008)
- ED1-ED5 → ADR-023 through ADR-027
- SE1-SE5 → ADR-028 through ADR-032
2026-05-29 07:19:03 +00:00
6c3ed598db docs: restructure metagraph-module.md for clarity and reduced redundancy
- Eliminate 4x redundancy on SchemaBuilder removal (was in Overview, Equivalence section, DD1, DD2)
- Remove forward references to DD numbers that break reading flow
- Separate specification from rationale (DDs capture decisions, body specifies)
- Fix Type.Ref inconsistency in Edge Constraints example (should use Metagraph.Import per DD2)
- Expand 'Why TypeBox Modules' with the three friction points it solves
- Add Performance subsection, Codegen Path, Transition table, Implementation Path
- Restore Relationship to Other Packages table
- Remove historical artifacts (SchemaBuilder equivalence internals, Type.Any migration notes)
- 887 lines → 694 lines (22% reduction)
2026-05-29 06:59:05 +00:00
3b63d92976 docs: delete metagraph.md, migrate data model into metagraph-module.md
The historical reference doc was exactly the confusing artifact we were
cleaning up. Its unique content (the three-level type system overview
and ASCII diagram) now lives in metagraph-module.md as an introductory
section. Everything else was redundant:

- Schema types → metagraph-module.md (Module entries)
- SchemaBuilder → metagraph-module.md (SchemaBuilder Equivalence section)
- Usage patterns → metagraph-module.md + encrypted-data.md (Module examples)
- Composite identity / attributes storage → sqlite-host.md (table definitions)
- Versioning → schema-evolution.md (thorough treatment)
- Ecosystem context → overview.md (Ecosystem Integration section)

All cross-references updated: AGENTS.md, sqlite-host.md, schema-evolution.md.
2026-05-29 05:27:08 +00:00
95e02f939d docs: add schema-evolution.md — TypeBox Value.Diff/Patch/Cast for schema evolution 2026-05-28 16:31:25 +00:00
1e804b9174 docs: remove backward compatibility framing from architecture specs 2026-05-28 16:18:54 +00:00
5ce93b1357 docs: add metagraph-module and forward-look architecture specs, remove SchemaBuilder legacy support
Graph type definitions as TypeBox Modules — the core architecture evolution
for @alkdev/storage. The SchemaBuilder is removed (no existing consumers),
replaced by direct TypeModule construction with Metagraph.Import() for
base attribute composition and Type.Composite() for node/edge type
specialization.

Key additions:
- metagraph-module.md: Module pattern, edge constraints as named entries,
  SchemaBuilder equivalence, DB bridge contracts (moduleToDbSchema return
  type, validateNode/validateEdge signatures), 10 design decisions (DD1-DD10)
- forward-look.md: pointer abstraction (ujsx ValuePointer analogy, JPATH
  Module), dbtype table rendering relationship, ujsx as universal IR pipeline

Critical corrections from architecture review:
- Type.Composite uses IntersectEvaluated (intersection, not Object.assign
  override) — overlapping keys with subtype relationships resolve correctly
- Type.Ref inside Type.Composite within a Module is verified working
- BaseNode/BaseEdge use Metagraph.Import() for same-package Modules (Option B),
  not local re-declaration (no circular dep within same package)
- Edge constraints use Type.String() for node type name arrays (not Type.Ref) —
  constraints contain names, not schemas
2026-05-28 15:32:56 +00:00
33a5b0816d docs: correct ecosystem dependency direction and add integration context
Architecture docs previously referenced the hub as the authoritative source
for call/identity specs. In reality, call protocol, identity, and access control
come from @alkdev/operations; call graph schemas from @alkdev/flowgraph; task
graph schemas from @alkdev/taskgraph; event transport from @alkdev/pubsub. The
hub is a consumer of @alkdev/storage, not the other way around.

Key changes:
- overview.md: add Ecosystem Integration section with dependency direction
  diagram, What Comes From Where table, repo layer bridging pattern, and
  circular dependency avoidance guidance
- overview.md: promote repo-layer vs operations-bridging from open question
  to explicit decision (CRUD in storage, bridging in consumer)
- overview.md: add zero-ecosystem-dependency statement; fix taskgraph type
  names (TaskGraphNodeAttributes, DependencyEdge)
- overview.md: fix terminology (hub is consumer, not authority)
- metagraph.md: add Ecosystem Context section; replace hub references with
  correct ecosystem sources; fix GraphStatus/GraphBaseType enum
  mischaracterization (C1); unify empty-array semantics with sqlite-host (C2);
  clarify repo layer does NOT import operations (C3); add flowgraph canonical
  schema note; add versioning cross-reference to graph_types table
- encrypted-data.md: reframe hub as provenance not authority; update What
  Lives Where table; fix standalone table advice; update references
- sqlite-host.md: fix actors table description; unify empty-array semantics;
  contextualize hub as reference consumer; add operations identity reference
2026-05-28 14:25:16 +00:00
bb544469fd fix: use import type for GraphConfig, remove verbatim-module-syntax exclusion
The verbatim-module-syntax lint rule was correctly flagging that
GraphConfig is only used in a type position (typeof GraphConfig). Since
typeof resolves purely at the type level, import type works fine here
and is the correct form. No lint exclusion needed.

Also: deno fmt across all files (markdown line wrapping).
2026-05-28 13:38:42 +00:00
b0298663dc feat: add architecture docs, fix code issues from review, add analyze_lint script
Architecture docs (docs/architecture/):
- overview.md: package purpose, exports, terminology, design decisions, gaps
- metagraph.md: core graph model, schema types, SchemaBuilder, validation
- sqlite-host.md: SQLite tables, common columns, relations, concurrency model
- encrypted-data.md: encrypted data as a node type, AES-256-GCM crypto utility design

Code fixes from architecture review:
- Remove ConfigSchema duplication in graphTypes.ts (import GraphConfig from types.ts)
- Add missing SelectNodeSchema/SelectNode to nodes.ts
- Fix InsertEdge.key to be Optional (match nullable DB column)
- Replace TypeScript enums with as const objects (GRAPH_STATUS, GRAPH_BASE_TYPE)
- Add verbatim-module-syntax to lint exclusions (TypeBox false positive)
- Add @std/flags and @std/path to deno.json imports

Infrastructure:
- Add scripts/analyze_lint.ts from @ade for grouped lint analysis
- Add deno task lint:analyze
- Update AGENTS.md with architecture doc references, enum convention, crypto todo
2026-05-28 13:18:56 +00:00
351fc98ec1 docs: add AGENTS.md and fix agent role defs for deno-first project
- Add AGENTS.md with project overview, conventions, commands, and heritage notes
- Fix all npm→deno command references in coordinator, implementation-specialist, poc-specialist
- Fix project name in coordinator spawn template (@alkdev/operations→@alkdev/storage)
- Remove hub-specific content (future model, hub operations) from coordinator
- Add project-specific conventions to implementation-specialist (no comments, TypeBox, slow types, etc.)
- Add deno-specific review checks to code-reviewer
- Fix file path examples in implementation-specialist (packages/core→src/graphs)
- Update sdd_process.md to remove hub-specific references and architecture doc list
- Update architect examples to use storage component names
2026-05-28 12:29:39 +00:00
8c68dd6b07 feat: deno-first storage package with sqlite host and graph schemas
Scaffolded @alkdev/storage from @ade/storage_sqlite and @ade/core/graphs:
- graphs/ module: TypeBox schema types + SchemaBuilder (from @ade/core/graphs)
- sqlite/ module: Drizzle table defs, relations, injectable client (from @ade/storage_sqlite)
- pg/ module: placeholder for Postgres host
- deno.json configured for JSR with subpath exports (./graphs, ./sqlite, ./pg)
- Imports swapped: @sinclair/typebox → @alkdev/typebox, drizzle-typebox → @alkdev/drizzlebox
- Client is now injectable (no hardcoded env vars or module-level side effects)
- no-slow-types lint excluded (Drizzle generics); --allow-slow-types on publish
2026-05-28 12:19:48 +00:00
c6ea6c15e9 init 2026-05-28 11:16:10 +00:00