aiConnected v2 Core Shell — Completeness Pack
Version:1.0Date:
2026-03-26Status:
Implementation-Ready Draft (Pending Quality Gates)Owners:
Product + Architecture + Engineering
Table of Contents
- Purpose and Authority
- Program Boundary Addendum
- v1 Parity Replication Matrix
- Schema + RLS Specification Pack
- Contract Pack (OpenAPI + Canonical Types)
- Event + Gateway Operational Semantics
- Billing Enforcement State Machine
- NFR + Security Control Pack
- Cutover and Validation Runbook
- Master Acceptance Matrix
- Quality Gates
- Implementation-Ready Gate
- Appendix A — Source References
1. Purpose and Authority
This Completeness Pack is the implementation-readiness companion to the Core Shell PRD.It closes remaining ambiguity for the Shell phase so Codex can build from a blank repo without product decisions during implementation. Authority rules:
- This document and the Shell PRD govern
Shellphase behavior. - The Layout Manager PRD governs Layout Manager internals; this pack governs shell integration boundaries.
- If a requirement conflicts with shell/module boundary, shell boundary wins and the requirement is deferred to a later phase.
- Shell must be fully operable with zero modules installed.
2. Program Boundary Addendum
2.1 Phase Boundaries
Shellphase: control-plane infrastructure only.Modulesphase: first-party and imported module runtime/domain behavior.Capabilitiesphase: higher-order capability graph/composition features.
2.2 Shell Done Definition
Shell is considered done when:- Super, Agency, Business workflows operate end-to-end.
- Tenancy, RBAC, branding, billing enforcement, layout lifecycle integration, module lifecycle infra, event bus, and gateway all work.
- No module business logic is present in shell code.
- Shell supports dynamic modules via contracts, while still functioning with none installed.
2.3 Module-Absent Operating Mode (Required)
- Empty module registry does not break navigation or dashboards.
- Gateway returns deterministic errors:
MODULE_NOT_REGISTEREDMODULE_NOT_ENABLED
- Module admin UI shows actionable empty states.
- Event bus remains operational for shell-emitted events with no module subscribers.
3. v1 Parity Replication Matrix
3.1 v1 Input Sources
/Users/MrBobHunter-MacPro/Code/platform.sec-admn.com-2/docs/v1-audit/02-foundation-vs-apps.md/Users/MrBobHunter-MacPro/Code/platform.sec-admn.com-2/docs/v1-audit/03a-auth-and-permissions.md/Users/MrBobHunter-MacPro/Code/platform.sec-admn.com-2/docs/v1-audit/03b-module-manifest-system.md/Users/MrBobHunter-MacPro/Code/platform.sec-admn.com-2/docs/v1-audit/03c-branding-and-theming.md/Users/MrBobHunter-MacPro/Code/platform.sec-admn.com-2/docs/v1-audit/03f-db-client-server-patterns.md/Users/MrBobHunter-MacPro/Code/platform.sec-admn.com-2/docs/v1-audit/07-multi-tenancy-clean-port-plan.md
3.2 Disposition Table
3.3 Parity Acceptance Rules
- Every
Replicate nowrow has package ownership and automated validation. - Every
Deferrow is absent in shell implementation. - Every
Retirerow has an explicit replacement or removal rationale in docs.
4. Schema + RLS Specification Pack
4.1 Migration Order
001_identities.sql002_workspaces.sql003_memberships_roles_permissions.sql004_themes.sql005_layouts.sql006_module_registry_installations.sql007_events_audit.sql008_billing.sql009_contacts.sql010_rls_policies.sql011_seed_role_templates.sql
4.2 Table-Level Specification
4.3 RLS Policy Baseline
workspaces: member-scoped read, super full read/manage.workspace_memberships: workspace admins manage; users self-read membership rows.themes:branding.editrequired for write, membership required for read.layout_definitions/layout_versions:layouts.editfor write; membership for read.module_installations:modules.install|modules.enable|modules.disablefor write; membership for read.billing_accounts/subscriptions:billing.managefor write/read in scope; super override.events: emitter must be authenticated and scoped; reads scoped by workspace.audit_logs: write by trusted service role only; read by workspace admins and super.
4.4 Tenancy and Integrity Invariants
- All mutable business rows are workspace-scoped unless explicitly global.
- Cross-workspace access is denied-by-default.
layout_versionsare immutable snapshots.eventsandaudit_logsare append-only.- Impersonation must not bypass workspace permission checks.
4.5 Retention Policy (MVP)
events: retain minimum 180 days online.audit_logs: retain minimum 365 days online.- Archival beyond this window is operationally optional in MVP.
5. Contract Pack (OpenAPI + Canonical Types)
5.1 Endpoint Families and Minimum Contracts
5.2 Canonical Types
WorkspaceContext
EffectivePermissions
ModuleManifest
ModuleInstallationState
EventEnvelope
GatewayForwardHeaders
BillingEntitlementState
5.3 Stable Error Model
6. Event + Gateway Operational Semantics
6.1 Event Delivery Behavior
- Ordering guarantee is scoped to
(workspace_id, stream_key)only. - Publisher must provide idempotency key for retry-safe writes.
- Retry policy: exponential backoff, max 5 attempts.
- Terminal failures go to dead-letter store with replay capability.
- Replay requires admin/super authorization in same workspace scope.
- Event envelope schema is validated pre-persist and pre-delivery.
6.2 Event Authorization
- Emitter can publish only declared/allowed event names.
- Subscriber can consume only declared/allowed event names.
- Cross-workspace event reads are forbidden.
- All delivery attempts and failures are auditable.
6.3 Gateway Forwarding Behavior
- Resolve module target from
module_installations + module_registry. - Apply pre-forward checks in this order:
- auth/session
- workspace scope
- permission
- billing entitlement
- module registered/enabled
- target health
- Forward trusted server-issued claims only.
- Default timeout 8s.
- Circuit breaker opens on repeated failures; shell returns
MODULE_TARGET_UNHEALTHY. - Every forward logs correlation id, target, and enforcement decision.
6.4 Impersonation Protections
- Forwarded claims include actor/effective identity separation when impersonating.
- Module cannot self-assert identity.
- Client-supplied identity headers are stripped at gateway edge.
7. Billing Enforcement State Machine
7.1 States
activepast_duegracesuspendedcanceled
7.2 Transition Rules
active -> past_due: Stripe payment failure event.past_due -> grace: grace window begins.grace -> suspended: grace expiry without recovery.past_due|grace|suspended -> active: successful recovery payment.suspended -> canceled: explicit cancellation/termination.active -> canceled: explicit cancellation.
7.3 Entitlement Effects
7.4 Stripe Truth and Reconciliation
- Stripe webhooks are source of truth for billing events.
- Shell stores normalized entitlement snapshots.
- Reconciliation job repairs divergence and is idempotent.
- Every state transition writes
audit_logs.
8. NFR + Security Control Pack
8.1 MVP SLO Targets
- Auth guard decision p95
< 200ms. - Workspace switch p95
< 500ms. - Module route resolution p95
< 300ms. - Gateway overhead p95
< 150ms(excluding module runtime time). - Layout publish/rollback acknowledgment p95
< 2s. - Event enqueue p95
< 250ms.
8.2 Reliability Controls
- Publish and rollback are idempotent by operation key.
- Autosave recovery restores last valid layout draft after interruption.
- Audit log coverage for privileged actions is 100%.
- Dead-letter replay is safe and workspace-scoped.
8.3 Security Controls
- Deny-by-default authorization.
- Server-side enforcement independent of UI.
- Impersonation requires explicit start/stop and audit events.
- Header trust boundary enforced at gateway.
- Cross-workspace access denied unless explicit super scope.
9. Cutover and Validation Runbook
9.1 Blank-Repo Build Sequence
- Bootstrap monorepo + package boundaries.
- Implement auth/session and workspace context.
- Implement tenancy schema + RLS + permission core.
- Implement theme token system + inheritance.
- Implement module manifest validator + registry/install lifecycle.
- Implement event bus baseline.
- Implement gateway baseline.
- Integrate Layout Manager shell touchpoints.
- Implement billing entitlement enforcement.
- Run acceptance suite and dry-run audits.
9.2 Environment Contracts
local: developer auth + seed data + billing sandbox mode.staging: real webhook paths + production-like RLS + full acceptance tests.prod: strict secrets, audit retention enabled, alerting active.
9.3 v1 Backfill Approach (Shell phase)
- Migrate shell-owned entities only.
- Do not migrate module domain records in shell phase.
- Rebuild module installation state from valid manifests.
- Preserve user/workspace/membership continuity.
9.4 Go-Live Checklist
- All acceptance matrix rows passing.
- Billing transition tests passing in staging.
- Impersonation audit verified.
- Module-absent mode verified.
- Rollback drill completed and documented.
10. Master Acceptance Matrix
11. Quality Gates
- No unresolved
TBDin shell-critical sections. - Every endpoint family has request/response/error contracts.
- Every shell-owned entity has schema + RLS policy.
- Every v1 parity item has
replicate/defer/retiredisposition and acceptance method. - Shell/module ownership is unambiguous to independent reviewer.
12. Implementation-Ready Gate
Mark this packREADY only when:
- Quality gates all pass.
- Acceptance matrix has no unresolved ownership or contract gaps.
- Independent architecture review signs shell/module boundary conformance.
- Module-absent mode tests are green.