Implementation Plan: Nx Workspace & Module Boundaries

Phase 3 Artifact — Establishes workspace enforcement per ENGINEERING.SOP.md Phase 3.

Purpose

Establish and continuously enforce the Nx workspace + module-boundary rules that implement the One Kernel, Multiple Shells topology and prevent accidental cross-context coupling. This plan is foundational and unblocks downstream plans by making “illegal imports” fail fast in CI and locally.


Pre-Flight Validation

STOP. Before implementing, validate all input specifications.

ADR Validation

Check Requirement Pass
ADR-033 exists docs/specs/shared/adr/033-kernel-shell-architecture.md [x]
ADR-034 exists docs/specs/shared/adr/034-nx-module-boundary-enforcement.md [x]
ADR-030 exists docs/specs/shared/adr/030-vibespro-foundation-integration.md [x]
Has Context section All ADRs explain the problem domain [x]
Has Decision section All ADRs list concrete choices [x]
Has Constraints section MUST/MUST NOT statements present [x]

PRD Validation

Check Requirement Pass
PRD-023 exists docs/specs/shared/prd/023-sea-platform-integration.md [x]
Has Satisfies: ADR-033, ADR-034, ADR-030 Traces to decisions [x]
REQ-060, REQ-062, REQ-066 defined Testable requirements [x]

SDS Validation

Check Requirement Pass
SDS-048 exists docs/specs/shared/sds/048-platform-ui-integration.md [ ]
Schema valid just sds-validate <file> [ ]
Has metadata.satisfies Lists PRD-023 [ ]

Pipeline Verification

1
2
# This plan is workspace-level; no SEA-DSL compilation needed
just ci-quick  # Verify lint + specs pass

Provenance Chain

graph TD
    ADR33[ADR-033: Kernel-Shell Architecture] --> PRD23[PRD-023: SEA™ Platform Integration]
    ADR34[ADR-034: Nx Module Boundary Enforcement] --> PRD23
    ADR30[ADR-030: VibesPro™ Foundation Integration] --> PRD23
    PRD23 --> SDS48[SDS-048: Platform UI Integration]
    SDS48 --> C0A[C0A: Boundary Constraints]
    SDS48 --> C0D[C0D: Context Tagging]

    style ADR33 fill:#e1f5ff
    style ADR34 fill:#e1f5ff
    style ADR30 fill:#e1f5ff
    style PRD23 fill:#fff4e1
    style SDS48 fill:#e8f5e9
ADR ID PRD ID SDS Element Cycle
ADR-033 PRD-023 REQ-060 Kernel-Shell topology C0D
ADR-034 PRD-023 REQ-062 ESLint boundary rules C0A
ADR-034 PRD-023 REQ-066 CI enforcement C0B
ADR-030 PRD-023 REQ-062 VibesPro™ choke-point C0D

Implementation Order

Required sequence per ENGINEERING.SOP.md Phase 3.

  1. Define architectural layers — Kernel (libs/sea/), Shells (apps/)
  2. Enforce dependency constraints — ESLint @nx/enforce-module-boundaries
  3. Introduce ports — All external interaction via port interfaces
  4. Centralize contracts — libs/shared/contracts as shared types home
  5. Validate enforcementjust ci-lint fails on violations

Proposed Cycles (Worktree-First)

Each cycle = one branch + one worktree. Waves enable parallel work.

Cycle Worktree Branch Wave Implements
C0A ../SEA-p0-c0A cycle/p0-c0A-boundaries 1 ESLint boundary constraints
C0B ../SEA-p0-c0B cycle/p0-c0B-workspace-targets 1 Nx workspace targets
C0C ../SEA-p0-c0C cycle/p0-c0C-codegen-paths 1 Affected codegen detection
C0D ../SEA-p0-c0D cycle/p0-c0D-context-tagging 2 Lib tagging (depends on C0A)

Starting a Cycle

1
2
just cycle-start 0 0 A boundaries
cd ../SEA-p0-c0A

Wave 1 (Parallel)

Wave 2 (Depends on Wave 1)

Worktree Lifecycle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 1. Start cycle
just cycle-start 0 0 A boundaries
cd ../SEA-p0-c0A

# 2. Make changes
# Edit eslint.config.js, nx.json

# 3. Verify locally
just ci-lint
just ci-quick

# 4. Complete cycle
just cycle-complete 0 0 A
gh pr create --base dev

# 5. After merge, cleanup
cd ~/projects/SEA™
just cycle-worktree-remove 0 0 A

Nx Generators to Use

From develop-software.md § Generators.

Generator Command When to Use
Bounded Context just generator-bc <name> New domain context
Adapter just generator-adapter <name> <ctx> New port+fake+real
1
2
3
4
5
# Context scaffolding
just generator-bc vibespro

# Adapter pair
just generator-adapter authz sea

Expected Filetree

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/
├── eslint.config.js                     # [C0A] Boundary constraints (ADR-034)
├── nx.json                              # [C0A] Workspace plugins/defaults
├── tools/
│   ├── nx/workspace/project.json        # [C0B] workspace targets
│   └── run_codegen_affected.sh          # [C0C] affected detection
├── libs/
│   ├── sea/                             # scope:sea (kernel)
│   │   ├── domain/                      # type:domain
│   │   ├── ports/                       # type:ports
│   │   ├── application/                 # type:application
│   │   └── adapters/                    # type:adapters
│   ├── vibespro/                        # scope:vibespro
│   │   └── public-api/                  # type:public-api (choke-point)
│   └── shared/                          # scope:shared
│       ├── contracts/                   # type:contracts
│       └── testing/                     # type:testing
└── apps/                                # type:shell

Validation & Verification

Pre-Merge Checks

Post-Implementation Verification


Dependencies Introduced


Risks & Mitigations

Risk Likelihood Impact Mitigation
Boundary rules block legitimate imports Medium High Start strict; add type:public choke-points intentionally (ADR-030)
Inconsistent docs vs Nx wiring High Medium Single source of truth: wire targets to match docs
Affected codegen misses changes Medium High Align watcher paths + determinism check

Rollback Strategy

  1. Immediate: Revert enforcement changes (ESLint + Nx target wiring)
  2. Fallback: Temporarily relax constraints to libs/sea/** only

Open Questions

  1. tools/run_codegen_affected.sh watches specs/<ctx>/ but repo uses docs/specs/ — standardize paths? yes
  2. Repo docs say workspace:check but code has codegen-affected — rename for consistency? yes
  3. Tag policy for shells (type:shell) — where should apps live? yes

References

Do not duplicate content from these documents.

Document Purpose
develop-software.md Full workflow, just commands
ENGINEERING.SOP.md Phase 3 acceptance criteria
tdd-cycles.md Worktree workflow
Traceability Matrix ADR→PRD→SDS chains

Linked Specifications

Type ID Document
ADR ADR-033 Kernel-Shell Architecture
ADR ADR-034 Nx Module Boundary Enforcement
ADR ADR-030 VibesPro™ Foundation Integration
PRD PRD-023 SEA™ Platform Integration
SDS SDS-048 Platform UI Integration