Updated: 2026-04-11
Treat P8-5836 as a sequence of independently releasable pull requests, not one directory-move pull request. Move one deployable module at a time while p8-api continues to package and deploy modules not yet moved.
The migration invariant is:
After every merged step, every supported variant builds, the release is installable, the same Terraform state and AWS resources are used, and rollback to the previous release remains possible.
Do not combine source refactoring, package renaming, route changes, Terraform redesign, or state migration with the moves. Use git mv and retain package names, Lambda names, API routes, IAM names, feature behavior, and state keys.
p8-api/module_conf.yaml owns nine deployable modules:
p8-profile-management
p8-metrics
p8-statistics
p8-audit-trail
p8-announcement
p8-maker-checker
p8-notification
p8-integrations
p8-ui-log-management
Seven product-variant manifests and lockfiles reference workspace paths under p8-api/. Product build/release profiles publish p8-api as one AWS artifact, and p8-auth declares p8-api as a dependent. Each module also has path-sensitive build scripts, Rspack configuration, Terraform sources, provision scripts, OpenAPI files, and feature-file lookups.
The two structurally complex modules are:
p8-maker-checker: shared source plus a package under src/<variant>.
p8-integrations: shared and variant source are mixed; CIX depends on and directly imports Carbon integration code.
Every extraction must preserve:
application/p8-api/<module>/terraform.tfstate;
p8-auth;
p8-api.tar release.
A filesystem move does not justify a Terraform state move. State migration should be a separate ticket if ever needed.
No product code changes.
origin/develop and has unrelated modifications; do not build this migration on that state.
p8_features.conf for every variant.
Exit gate: baseline build/test is green and generated artifacts are saved for comparison. Existing failures are documented.
P8-5852 is a prerequisite. p8-api/features/ contains 59 flags shared by all nine modules; copying it into nine modules would multiply existing duplication.
Implement P8-5852 separately:
p8-variation-values/features/ as the single registry.
Exit gate: p8-api no longer owns feature values, all variants receive intended values, and CI prevents local duplicates.
Rollback: revert the registry PR as one unit; no directories have moved.
p8-metrics as the pilotUse p8-metrics first because it has ordinary handler/build/deployment structure and no stream, schedule, Step Function, or cross-variant source topology.
Perform one complete vertical slice:
git mv p8-api/p8-metrics p8-metrics.
module_conf.yaml into a complete top-level definition with relative_path: p8-metrics.
variants/*/package.json; regenerate affected lockfiles.
p8-metrics to applicable build/release profiles, AWS artifacts, and p8-auth dependents.
p8-metrics from p8-api/module_conf.yaml, aggregate OpenAPI config, and aggregate provision set. Keep p8-api for the other eight.
p8-api-metrics, API routes, Terraform identifiers, and state key.
Pilot validation:
lib.zip, and release package with baseline;
p8-metrics.tar plus reduced p8-api.tar;
p8-api;
Exit gate: mixed topology builds, installs, operates, and rolls back. Do not extract another module first.
Repeat the Step 3 vertical slice. Each module gets its own PR and independently installable release:
p8-profile-management — ordinary API module.
p8-audit-trail — verify every variant-specific OpenAPI specification.
p8-ui-log-management — verify enabled and disabled feature-gated routes.
p8-announcement — verify announcement Step Functions and feature gate.
p8-notification — verify event-source mappings and cleanup behavior.
p8-statistics — verify periodic-metric config, custom copy, and post-provision behavior.
For every PR:
p8-api containing modules not yet extracted;
p8-maker-checkerMove the whole module without flattening:
p8-maker-checker/
src/common/
src/da/
src/bpx/
src/carbon/
src/cix/
src/crypto/
src/imperium/
src/prediction/
Update each variant package’s build, test, TypeScript, Rspack, workspace, and lockfile paths. Preserve shared-source inclusion and deployments/pre_provision.sh runtime YAML staging.
Exit gate: every variant test/build passes, packaged YAML matches baseline, non-production workflows pass, and rollback succeeds.
p8-integrations lastMove the entire module together. Do not split integrations by variant in P8-5836.
Preserve:
Test BPX, Carbon, CIX, and Imperium explicitly. CIX must build and test with Carbon from a clean install.
Exit gate: all variant builds/tests and non-production integration smokes pass, artifacts match baseline, and rollback succeeds.
p8-api shellOnly after all nine module releases succeed:
p8-api.
p8-e2e/scripts/file_scope.sh’s aggregate p8-api.json path with ordinary independent handling.
p8-toolchain, p8-tools/ts-dev-server, npm update scripts, cheat sheets, and architecture docs.
p8-api only when git grep confirms no runtime/build/release dependency. Historical state-key strings remain intentionally.
Exit gate: no aggregate artifact is produced or expected, all nine artifacts install, and old releases remain installable.
git mv; avoid unrelated source edits;
module_conf.yaml independently complete;
p8-auth ordering;
Adapt names and variants per module:
git grep -n 'p8-api/p8-metrics' -- ':!variants/*/package-lock.json'
npm test -w p8-api-metrics
./scripts/build.sh -c node_build -pv crypto -sv crypto --clean 1 -m p8-api-metrics
bash -n p8-metrics/per_commit.sh p8-metrics/deployments/*.sh
terraform fmt -check -recursive p8-metrics/deployments
(
cd p8-metrics/deployments
terraform init -backend=false -input=false
terraform validate
)
for v in da bpx crypto carbon imperium cix prediction; do
./scripts/build.sh -c node_build -pv "$v" -sv "$v" --clean 1
done
Do not run Terraform apply or publish without explicit environment approval.
Keep separate review/revert units:
A module move must not be split so workspace paths point to a missing directory or release profiles expect an unbuildable artifact. Do not put multiple module moves in one PR: independent rollback is worth the lockfile churn.
| Risk | Control |
| — | — |
| Feature behavior changes | Complete P8-5852 and compare effective values by variant. |
| Existing resources recreated | Keep state/names; inspect non-production plan before apply. |
| Mixed release misses a module | Atomically remove aggregate metadata and add independent artifact entries. |
| Independent deploys throttle API Gateway | Generalize shared ID lookup before pilot; test concurrent deployment. |
| Provider-cache race | Pre-warm or serialize provider initialization generically. |
| Package omits APIs/config/hooks | Compare manifests and archive lists with baseline. |
| CIX integrations break | Move integrations last and retain Carbon/CIX topology. |
Unrelated modules break when deleting p8-api |
Move shared ownership and symlinks first. |
| Lockfiles drift | Regenerate and validate all affected variant lockfiles per PR. |
| Rollback fails | Install the previous aggregate release after every canary. |
p8-api has no operational ownership and is removed.