Inspect real Playbooks (Schemas), Codebase Standards, and Detected Topic Clusters from engrams-cli itself and an anonymized multi-tenant production monorepo (meridian-mono).
⬡ Playbook: Reusable rule bundle confirmed by a human◆ / ⚑ Standard: Regex, AST, or review guardrail◎ Cluster: Co-edited files & notes grouped automatically
CONFIRMED PLAYBOOK · ENGRAMS-CLIRust Zero-Allocation Hot Pathsengrams-cli (public Rust repo)
performance-rules
Hot retrieval and enrichment paths must avoid avoidable heap allocations and clones.
⚡ WHEN IT FIRES & WHAT TO DO
Fires whenever editing Rust code that creates, copies, or hands off collections and strings: borrow SQL params via Vec<&dyn ToSql>, keep Cow<str> borrowed through string transforms, consume temporary lookup maps by move (remove / mem::take), and fuse iterators instead of collecting throwaway Vecs.
⚓ src/ops⚓ src#performance#rust#sql
Inputs / Notes Specimen Hub Governed Targets
Click or hover any pin above to inspect its full label.
Borrowed SQL Parameters Only — blocks Box<dyn rusqlite::ToSql> so dynamic parameter lists borrow via Vec<&dyn ToSql>.
pattern:8warn · regex
One Allocation Per String Chain — keeps Cow<str> borrowed through trim/transform chains instead of allocating intermediate Strings.
pattern:9warn · regex
Enrich By Move Not get().clone() — consumes temporary lookup maps with remove() or mem::take when enriching rows.
pattern:10info · regex
No Throwaway Intermediate Collections — flags .collect::<Vec<_>>().join() so iterators stay fused.
pattern:12warn · ast
AST-grep structural companion catching multiline $MAP.get($KEY).clone() chains that line regexes miss.
EVIDENCE & TRIGGERS
pattern:7 · Borrowed SQL params (Vec<&dyn ToSql>)
pattern:8 · Keep Cow<str> borrowed in chains
pattern:9 · Consume lookup maps with remove()
pattern:12 · Structural AST-grep clone check
schema:1 · performance-rules
GOVERNED FILES & DOMAINS
src/ops/advise.rs
src/ops/brief.rs
src/ops/schemas/retrieval.rs
engrams check --staged
MACRO CODEBASE TOPOLOGY · 100 ACTIVE DAYS · 1,503 NODES · 3,137 LINKS
Seven Codebase Domains, Not an Unreadable Hairball
Across 100 days of real feature development on a multi-tenant monorepo, Engrams linked 465 decisions, 525 progress logs, 50 architectural standards, 342 source files, and 66 pull requests—organizing the 887-item connected core into 7 clear domains and 106 topic clusters.
PLAYBOOK EMERGENCE · FOUR REAL CLUSTER SHAPES
How Topic Clusters Turn Into Human-Confirmed Playbooks
Not every cluster behaves the same way: some converge cleanly onto one playbook, others split into two distinct concerns, fence off a documented exception, or wait as a dashed draft until you approve the wording.
Click, tap, or hover any node in the four real cluster shapes below to inspect the underlying decision, standard, source file, or exception.
⬡ Confirmed Playbook Standard Decision Source File
1 · Clean Convergence
scheduling-write-convergence
7 related scheduling decisions and their source files group cleanly into 1 reusable playbook.
2 · One Cluster → Two Playbooks
Dialog Cluster Splits by Concern
Tightly coupled UI decisions separate into two distinct playbooks: component API rules vs. keyboard/focus accessibility.
3 · Rule + Explicit Exception
shared-core-lockstep-pins
Unifies 11 lockstep version-pinning rules while fencing off 1 documented temporary exception.
4 · Staged for Human Approval
Proposal #6 · support-agent-simplification
4 recurring decisions staged at session close wait as a dashed draft until a developer confirms the wording.
CONFIRMED PLAYBOOKscheduling-write-convergence
Scheduling writes converge to one correct state under retries, races and stale screens: reads that feed a write ignore soft-deleted rows, superseded rows are soft-deleted instead of removed, and duplicates are stopped by row locks, unique indexes and the sync ledger instead of check-then-insert.
Enforceable Standards & Code Smells Across Every Domain
Filter all 50 registered standards and 7 anti-pattern smell detectors by domain below—each one surfaces during engrams advise and code review before repetitive bugs reach your main branch.
Tenant-owned operational workflows compose Core.Workflows and Core.Scheduling Multi builders inside an outer Ecto.Multi persisted via Core.Repo.transact_ok, open each command with an org-scoped SELECT FOR UPDATE of the authoritative workflow/task row, and use core.workflow_events (related_entity_id plus workflow_status_period_id) as the…
pattern:38Platform Core
API response envelope
All API responses are wrapped in {data: ...} structure.
pattern:41Atlas Workflows
Rule Sync Workflow (mix rules.sync)
docs/rules/ is the single canonical source for all AI/IDE rules. Generated targets (.cursor/rules/*.mdc and .agent/rules/*.md) must never be edited directly. Workflow for rule changes: 1. Edit the relevant file in docs/rules/ (e.g., docs/rules/ecto.md) 2. Run `mix rules.sync` from the repo root to regenerate .cursor/rules/ and…
pattern:44Platform Core
Frontend-Backend Key Alignment for Enum Values
When a frontend form sends enum-like string values (e.g., Renewal Adherence levels, status keys) that the backend compares against hardcoded strings, the frontend constant values MUST exactly match the backend comparison strings. The backend is the source of truth. Before defining frontend option values, trace the backend code that…
pattern:45Platform Core
Payload Completeness Check for Schema Fields
When a frontend form collects data for a backend schema field (e.g., member_complaint on HealthCheck), the API payload mapping function must explicitly include that field. The HealthCheck changeset uses cast(params, __schema__(:fields)) which auto-casts ALL schema fields — so if the frontend omits a field, the backend silently inserts…
IntakeWorkflow, EngagementWorkflows, and hh2_engagement_reconciler each have their own move_workflow_to_status/3 that re-implements Core.Workflows.move_to_new_status/3 logic (update workflow, close period, create new period, compute ensure_after_period_start). Core already handles all of this with opts for :start_at and…
pattern:47Atlas Workflows
ANTI-PATTERN: get_intake_workflow copy-pasted into 5 modules
The query `from wf in Workflow, where: wf.account_id == ^account_id and wf.type_key == 'intake' and not wf.is_deleted` is copy-pasted into IntakeWorkflow, ConsentForRecordsSignedHandler, EmrVisitNoteSignedHandler, EmrVisitNoteSyncedHandler, and HealthChecks. Core.Workflows.get_active_workflow_for_member/3 already exists and does the…
ANTI-PATTERN: Application.get_env(:core, :system_user_id) scattered across 40+ sites
The system_user_id config value is read via Application.get_env at 40+ individual call sites across sentinel handlers, staging importers, health checks, workflows, and seed data. FIX: Define a single `def system_user_id` in Core.Users or Core.Config and call that everywhere.
pattern:50Atlas Workflows
ANTI-PATTERN: @org_id compile-time attribute in 12 tenant modules
@org_id Application.compile_env(:core, :default_org_id, 1) appears in 12 Summit modules (bensup_workflows, health_checks, triage_workflows, barriers, escalation_workflows, etc.). Bakes tenant assumption at compile time. FIX: Centralize in Summit.Config or pass org_id through function parameters (which Core already does).
pattern:51Atlas Workflows
ANTI-PATTERN: Core.Workflows God Module (1,530 lines)
Core.Workflows.workflows.ex handles workflow CRUD, task CRUD, task locking (acquire/release/extend/batch), status period management, assignment period management, queue status periods, debug logging, event listing, comment listing, and lookup queries — all in one 1,530-line module. FIX: Extract sub-contexts: Core.Workflows.TaskLocking…
pattern:52Atlas Workflows
ANTI-PATTERN: N+1 in IntakeWorkflow.move_to_inactive sub-operations
close_active_tasks_ms and cancel_future_appointments_ms both load all matching records via Repo.all then Enum.map to update each individually. Each task triggers the full Workflows.update_workflow_task Multi pipeline. For large member panels this could be dozens of nested transactions. FIX: Use Repo.update_all for bulk closes or audit…
pattern:53Platform Core
Feedback URL Context Capture
When enriching feedback/exception reports with URL context, use TanStack Router's useMatches() to get the route template (fullPath with $param placeholders), not useLocation().pathname (which has resolved values). Stabilize the deepest match's fullPath as a primitive string for hook deps to avoid re-render storms. Parse search params…
pattern:54Platform Core
Thin Phoenix controllers
Business logic lives in Context modules, not controllers. Controllers delegate immediately.
pattern:55Atlas Workflows
Core-to-Tenant dependency direction
backend/apps/core/ and backend/apps/core_web/ must never reference Summit/summit modules. frontend/src/apps/core/ must never import from @/apps/company/. Dependency flows one way: Core <- Tenant.
pattern:56Atlas Workflows
Multi-tenant org_id scoping
Every database query must filter by org_id. No query returns cross-tenant data.
pattern:57Platform Core
React Compiler directives
Use 'use memo' directive instead of manual useMemo/useCallback. React Compiler handles memoization.
pattern:58Platform Core
TanStack wrapper hooks
Never use raw TanStack Query. Always use useRequestQuery / useRequestMutation wrappers.