chore(bmad): preserve planning and acceptance artifacts in Git

This commit is contained in:
bsodfather committed 2026-10-03 16:10:35 +03:00
1 parent fed5b7dfb3
commit ea3b71cb5e
93 files changed
+20696

No files matched your search

@@ -0,0 +1,68 @@
---
scope: Production-ready Crank Community across FR-1..FR-54
purpose: Build substrate for architecture, features, epics, implementation, and QA
altitude: initiative
updated: 2026-08-03T19:30
---
- (decision) Fast path selected: draft the complete architecture spine with explicit assumptions for later correction.
- (decision) The architecture spine is the only requested deliverable; no deck, C4 package, or expanded solution-design document is required.
- (constraint) The final PRD and its confirmed decisions bind this architecture; architecture may choose mechanisms but may not weaken FR/NFR/Release Gate outcomes.
- (constraint) Brownfield reality is authoritative for existing boundaries: ratify established conventions rather than invent a replacement architecture.
- (decision) Adopt a hexagonal modular monolith with explicit control-plane and execution-plane composition roots; binds all FRs and prevents microservice proliferation or inward dependencies on transport/storage frameworks.
- (decision) Keep crank-core as framework-free domain and ports, crank-registry as PostgreSQL adapter, crank-runtime as Operation execution application layer, protocol adapters at the edge, and apps as the only composition roots; binds FR-1..FR-45 and prevents cyclic or transport-owned business logic.
- (decision) Model Operation, Resource, and Prompt as separate versioned aggregates sharing CapabilityKind, CapabilityRef, lifecycle, sensitivity and publication contracts; AgentVersion binds exact published refs and exposes one immutable catalog revision; binds FR-1, FR-4, FR-15..FR-18 and prevents EAV blobs, draft leakage and independently drifting lifecycle rules.
- (decision) Dynamic Resources may execute only a pinned read-safe GET/HEAD Operation through RuntimeExecutor; Prompts are pure deterministic renderers over pinned Resource versions with no code execution; binds FR-16 and FR-18 and prevents safety bypass or hidden mutable dependencies.
- (decision) PostgreSQL 16 is the sole source of truth for configuration, published catalogs, approvals, idempotency, Tasks, Load Runs, business events and safety state; Valkey 8 is optional rebuildable acceleration only; binds FR-1..FR-45, NFR-R2 and NFR-S7 and prevents split-brain correctness or silent safety degradation.
- (decision) Serve MCP 2026-07-28 stateless and the 2025-11-25 and 2025-06-18 session-based revisions through version-specific transport/lifecycle adapters over shared method services; binds FR-13..FR-20 and NFR-C2 and prevents protocol-version branches from leaking into capability and execution domains.
- (decision) Normalize Tools, Resources, Prompts, completion, progress, cancellation and notifications into internal service contracts, and advertise only behavior implemented for the negotiated revision; binds FR-13..FR-20 and prevents capability overclaiming.
- (decision) Implement durable Tasks in a new crank-tasks application crate and task-worker composition root; crank-core owns task types and TaskStore port, crank-registry implements persistence, and crank-tasks depends on RuntimeExecutor through an execution port; binds FR-21..FR-26 and prevents background work inside HTTP handlers or protocol sessions.
- (decision) Create Task record and dispatch intent in one PostgreSQL transaction before acknowledgement; claim queue rows with FOR UPDATE SKIP LOCKED, CAS lease expiry and monotonic fencing token; every write requires the current token; binds FR-22..FR-25 and prevents lost accepted work, double terminal commit and stale-worker mutation.
- (decision) Task delivery is at-least-once; persist attempt and idempotency fingerprint before outbound dispatch, automatically retry writes only with a verified upstream idempotency contract, and route ambiguous side effects to nonterminal outcome_unknown reconciliation; binds FR-23..FR-26 and prevents false exactly-once claims or unsafe repeats.
- (decision) Map the same internal Task lifecycle to the official io.modelcontextprotocol/tasks extension for 2026-07-28 and to the negotiated 2025-11-25 task shape; 2025-06-18 uses published synchronous fallback or explicit unsupported; binds FR-13, FR-20..FR-23 and prevents wire evolution from redefining durable semantics.
- (decision) Move shared immutable files into crank-artifacts: a bounded content-addressed local store keyed by SHA-256 with atomic write/fsync/rename and PostgreSQL metadata; binds FR-7..FR-12, FR-15..FR-18, FR-40, FR-43 and prevents mutable file references, traversal and inconsistent restore.
- (decision) OpenAPI preview resolves local and allowlisted external refs into an immutable content-addressed artifact graph; import commit consumes only the preview digest in one registry transaction; binds FR-7..FR-12 and prevents SSRF/TOCTOU, partial mutation and silent remote drift.
- (decision) Use one canonical W3C TraceContext generated or validated at browser/Admin/MCP boundaries; persist request_id and trace_id in Invocation, Task and Load Run records and continue the stored context across worker attempts; binds FR-27..FR-31 and NFR-O1 and prevents correlation forks across foreground/background paths.
- (decision) crank-observability alone owns redaction, W3C propagation, OTLP export, GlitchTip Sentry-envelope projection and per-destination disk-backed bounded spool; browser telemetry enters through a scrubbed same-origin Admin API relay; binds FR-27..FR-31 and prevents raw OTLP assumptions for GlitchTip, direct browser exfiltration and unobserved telemetry loss.
- (decision) Telemetry is fail-open after validated startup; each evicted or expired undelivered envelope atomically creates a PostgreSQL Telemetry Loss Record through an app-injected sink, while spool partitions and quotas stay outside PostgreSQL and artifact safety reserve; binds FR-29..FR-31 and NFR-O2 and prevents backend outage from breaking requests or silently losing evidence.
- (decision) crank-metrics exclusively defines low-cardinality technical/business metric names, labels and buckets; exact activation/adoption uniqueness is stored as PostgreSQL events and daily rollups, then exposed only as aggregates; binds FR-32..FR-35 and prevents identifier cardinality and inaccurate DAU inference.
- (decision) Ship Prometheus scrape/rules and provisioned Grafana dashboards as versioned deployment assets; metrics listeners use a separate credential and Grafana reads Prometheus plus read-only PostgreSQL rollups where exact business aggregates are required; binds FR-32..FR-35 and prevents dashboard drift or high-cardinality Prometheus workarounds.
- (decision) Run load generation in a separate load-runner process using the public MCP endpoint and immutable Scenario version; PostgreSQL owns Run/lease/stop state and a reserved independent control connection enforces heartbeat, hard ceilings and kill switch; binds FR-36..FR-40 and prevents self-measurement bias, arbitrary-target load and a saturated data plane blocking emergency stop.
- (decision) All secret-using processes validate the same master-key fingerprint/epoch from PostgreSQL at startup and readiness; ciphertext carries key version and rotation is transactional re-encryption with old-key revocation evidence; binds FR-3, FR-36..FR-43 and prevents partial-key deployments and unrecoverable restore.
- (decision) Replace mutable baseline-only migration behavior with one checksummed append-only core sequence, expand/migrate/contract compatibility and a dedicated migrate command under transaction advisory lock; runtime processes verify compatible schema but never apply migrations; binds FR-43 and NFR-C3 and prevents concurrent schema owners, modified history and unsafe rollback.
- (decision) Introduce a leaf crank-config crate as the canonical typed configuration schema and validator; apps compose dependencies from it, generated examples/docs derive from it, and library crates do not read environment variables; binds FR-41..FR-45 and prevents parsed/documented/Compose drift.
- (decision) Production topology is ui, admin-api, mcp-server, task-worker, load-runner, PostgreSQL and optional Valkey, with an optional isolated observability profile containing Prometheus, Grafana and GlitchTip on its own storage; minimal profile preserves product correctness without external telemetry services; binds FR-41..FR-45 and prevents observability dependencies from entering product readiness.
- (decision) Use single-instance drain/restart: stop admission and new claims, checkpoint/lease accepted work, bound foreground drain to 30 seconds, flush telemetry to durable spool, and require N/N-1 schema/task envelope reads during rollback window; binds FR-23, FR-31, FR-43..FR-44 and NFR-R3 and prevents rolling-update claims the Community topology cannot prove.
- (decision) Preserve the Alpine/concatenated UI architecture; all mutations use Admin API DTOs with stable machine error_code plus request_id/trace_id, stale-response identity guards, and no direct PostgreSQL/MCP/GlitchTip access; binds FR-1..FR-45 and prevents a frontend rewrite, cross-boundary writes and correlation loss.
- (decision) Release evidence is immutable and content-addressed: Capability Inventory, protocol/import matrices, load/recovery/security results and environment/config/image digests are indexed by one Evidence Manifest tied to the RC digest; binds FR-12, FR-20, FR-40..FR-54 and prevents documentation-only gates or evidence from another artifact.
- (version) Verified architecture seed on 2026-08-03: Rust 1.96.1 / Edition 2024 / MSRV 1.96, Axum 0.8, Tokio 1, SQLx 0.9, Reqwest 0.12, OpenTelemetry 0.32, Sentry 0.49, metrics 0.24.6, PostgreSQL 16, Valkey 8, Node 22, Alpine 3.15.12, Playwright 1.61.1.
- (version) Verified MCP compatibility seed: current 2026-07-28 stateless protocol plus 2025-11-25 and 2025-06-18; official Tasks extension identifier io.modelcontextprotocol/tasks is isolated behind the MCP adapter.
- (constraint) No independent paid or cloud backend is required; all data and telemetry remain operator-owned and outbound telemetry is opt-in.
- (constraint) Reference Deployment, SLOs, release gates and ceilings from the final PRD are binding and architecture mechanisms may strengthen but not weaken them.
- (decision) Reconciliation amendment: MCP support is a feature-freeze matrix of latest stable plus two prior stable revisions, while current 2025-03-26 compatibility remains until an evidence-backed deprecation gate; release candidates/extensions never become the sole path for a critical Tool.
- (decision) Reconciliation amendment: ratify crank-community-mcp and crank-community-auth as brownfield composition-support adapters that may currently depend on concrete registry/runtime adapters; the dependency diagram must show these real edges and forbid them from lower layers rather than pretending they are already inverted.
- (decision) Add a unified OutboundPolicy and execution-pipeline invariant for Admin test, MCP Tool, dynamic Resource and Task paths: actual-address validation on every connection, redirect revalidation, system proxy disabled by default, and bounded body/response/deadline/concurrency.
- (decision) Add a capability publication validator for Resources and Prompts covering typed static/dynamic forms, exact dependency versions, DAG/root/template validation, MIME/size limits, secret scan and effective sensitivity policy.
- (decision) Reconciliation amendment: OpenAPI pipeline is ParsedDocument to typed NormalizedIR plus complete Findings to immutable ImportPlan to idempotent transactional Apply; every construct is preserved or explicitly unsupported/blocking and raw credentials never enter artifacts or plans.
- (decision) Add execution admission and approval invariants: synchronous executions, durable Tasks and queue records remain distinct; global/per-Agent/per-Tool bounded fairness and deadlines precede both sync/background paths; approvals deduplicate by full scope and input fingerprint with conditional terminal transitions.
- (decision) Reconciliation amendment: input_required updates use versioned schema plus fingerprint/CAS; identical replay returns prior transition, conflicting replay is rejected, and TTL expiry cannot dispatch a new side effect.
- (decision) Reconciliation amendment: production telemetry defaults to 100 percent generation, 7-day trace and 30-day error retention, delivery latency at least 99.99 percent, 25-hour completeness for outage up to 24 hours, and a 30-hour measured-p95 spool at 100 RPS plus a 250 RPS five-minute burst; GlitchTip remains a mandatory tested default path.
- (decision) Reconciliation amendment: exact business rollups are exported through the typed Prometheus surface; Grafana queries Prometheus and reaches traces through exemplars/external URLs, never trace-id labels or direct product-table coupling. Non-loopback metrics uses a dedicated credential.
- (decision) Reconciliation amendment: LoadAuthorizationPlan contains DAU assumptions, load-test-safe evidence, sandbox/test credential/quota/cleanup for writes, production flag with repeated confirmation, dead-man and control readiness; immutable ceilings are 1000 RPS, 512 VU, two hours and ten million iterations.
- (decision) Add consistent backup and verified restore: BackupManifest binds snapshot time, PostgreSQL WAL LSN, artifact checksums, config digest and external protected master-key reference; RPO at most five minutes and RTO at most thirty minutes end only after a real MCP call using encrypted auth.
- (decision) Add Admin identity and web boundary: community-auth owns one-time bootstrap, login backoff, sessions and CSRF lifecycle; PostgreSQL owns revocation/audit; TLS, trusted-proxy allowlist, secure cookies, deny CORS and security headers are production prerequisites; offline recovery is local-only and revokes sessions.
- (decision) Add signed offline deployment artifact: digest-pinned images, Compose/config, SBOM, licenses and docs; non-root/minimal privilege/read-only checks, no Critical/High vulnerabilities, deny-by-default egress, and air-gapped fresh install/upgrade are release evidence.
- (decision) Reconciliation amendment: Reference Deployment is Linux x86_64, 4 vCPU, 8 GiB, SSD at least 100 GB/3000 IOPS/100 MB/s, 1 Gbit/s, PostgreSQL 16 and Valkey 8 with 30 percent headroom; load generation and observability have separate budgets.
- (decision) Reconciliation amendment: migration consolidation imports and verifies legacy core, MCP and extension ledgers without modifying baseline v1/checksum; extension migrations gain checksums and the dedicated migration command becomes sole writer only after compatibility transition.
- (decision) Reconciliation amendment: new artifact refs are opaque content-addressed refs; legacy absolute file refs remain read-compatible during a digest-verified migration and are never rewritten before verification.
- (decision) Reconciliation amendment: Evidence Manifest is signed and schema-validated, binds commands, raw results, owner, RC digest, 72-hour soak and 30-day burn-in; gate fails closed on missing/stale/mismatched evidence and requires executable Community guardrails/project context updated without allow-marker bypass.
- (decision) Add dataset retention policy: History, Tasks, Load Runs, traces, errors and metrics have separate typed retention; published-version audit and signed release evidence remain immutable, and archive verification precedes deletion where required.
- (decision) Reviewer amendment: crank-core owns the versioned ProductEvent schema and TelemetryLossSink port; apps emit typed events, registry persists them, and telemetry loss deduplicates by service/destination/spool-record id.
- (decision) Reviewer amendment: artifact publication writes and verifies immutable bytes first, then commits PostgreSQL metadata/ref ownership; unreferenced bytes are swept only after a grace period, and referenced bytes delete only through retention-safe reference counting.
- (event) spine finalized
- (decision) Final reviewer amendment: every telemetry spool uses a dedicated quota-reserved persistent volume outside PostgreSQL/artifact reserve, write-ahead fsync before acceptance, crash recovery before export, least-privilege ownership and encryption-at-rest inherited from the deployment volume.
- (decision) Final reviewer amendment: load-runner exposes a non-networked local operator CLI over a permission-restricted Unix control socket on a reserved runtime/control path; stop halts new dispatch immediately and handles in-flight work by immutable Run policy with durable/local audit fallback.
- (decision) Final reviewer amendment: Logs, Task and Load Run UI must search/copy request and trace IDs and generate configured GlitchTip deep links, while Telemetry Loss Record or backend outage suppresses any claim that the trace is externally available; one E2E proves the path.
- (decision) Final reviewer amendment: release evidence signatures use a repository-pinned release trust policy containing public key IDs, validity and revocation; protected offline/CI private keys sign manifests, rotation is reviewed and old keys remain verifiable for historical evidence.
- (decision) Final reviewer amendment: queued Task keeps pinned execution semantics from enqueue but claim revalidates authorization, Agent publication, key revocation, deadline and current admission capacity; invalidated work terminates without outbound dispatch.
- (event) late reviewer findings resolved; spine re-linted with zero findings and post-fix gate verdict GO