Skip to content

refactor(composition): one wiring file per context, the root only fixes the order - #1083

Merged
kodes-agency merged 2 commits into
mainfrom
kernel-first/composition-split
Nov 4, 2026
Merged

kodes-agency merged 2 commits into
mainfrom
kernel-first/composition-split

Conversation

@kodes-agency

Copy link
Copy Markdown
Owner

What changed

src/composition.ts built the whole container in one 860-line function, so changes to different contexts collided in the same file. Each context's wiring now lives in its own file under src/composition/, and the root runs them in the same order as before.

  • runtime.ts: the shared process inputs (database, pool, logger, Redis, clock, env, provider endpoints, infrastructure) and the boot-time configuration guards.
  • identity-wiring.ts, property-wiring.ts, portal-wiring.ts, guest-wiring.ts, integration-wiring.ts, review-wiring.ts, ai-wiring.ts, inbox-wiring.ts: the arguments each context's build receives.
  • container-capabilities.ts: the object the container exposes.
  • src/composition.ts goes from 1,099 lines to about 340: the construction order, createContainer, createOperatorContainerGraph, and the process claim and singleton helpers. Every exported name is unchanged.

This is a move, not a rewrite. Construction order is unchanged. Callbacks into a context that is built later (Identity into Property, Portal and Integration; Portal into Reporting; Integration into Review) are passed as getters and are first called after construction ends, as the earlier closures were. Nothing a customer or guest sees changes.

Also in this change:

  • Client import protection in vite.config.ts now covers src/composition/** as well as composition.ts, so the moved wiring stays out of the browser bundle. CONTEXT.md and the composition architecture note say so.
  • Tests that read the composition source now read the file that holds the code. The Identity check for the session port is tied to the Identity context call, because the name now also appears elsewhere in the file.
  • The complexity suppression moved with the preamble it describes.

Read first: the getters in src/composition.ts and identity-wiring.ts.

How it was tested

  • Composition characterization tests pass unchanged (32 tests). A targeted unit run over composition, architecture, Identity and the other files that read composition source passes (192 files, 1,671 tests), as does a wider run over auth, worker, testing, API routes, server and the ops and local scripts (334 files, 3,403 tests).
  • Each updated source-reading test fails when the code it guards is removed or renamed in its new file (checked by hand for Review wiring, outbox consumer registration, the AI scope authorizer, the Identity session port, guest contact containment, the lifecycle contributors and the new import-protection pattern).
  • pnpm typecheck, ESLint with zero warnings on the changed files, Prettier, the architecture boundary controls, filename, test-quality, file-length, unchecked-indexed-access and changed-code checks, and a Fallow audit against main all pass.
  • pnpm build and pnpm check:bundles pass: entry chunk 52,328 B of 70,100 B, first-paint closure 320,737 B of 321,000 B, the same as main. All 458 client JS and CSS files are byte-identical to a build of main.
  • The built web server (production mode) and the worker bundle, from main and from this branch, were booted against a private Redis. The health answers and log lines match: the web server builds its container in both, and the worker stops at the same database-dependent step in both. check:security-headers and check:language-verifier pass on this build.

🤖 Generated with Claude Code

…es the order

The composition root built the whole container in one 860-line function, so
changes to different contexts collided in the same file. Each context's wiring
now lives in its own file under src/composition/, and src/composition.ts runs
them in the same order as before.

- runtime.ts: the shared process inputs (database, pool, logger, Redis, clock,
  env, provider endpoints, infrastructure) and the boot-time configuration
  guards.
- identity, property, portal, guest, integration, review, ai and inbox wiring
  files: the arguments each context's build receives.
- container-capabilities.ts: the object the container exposes.

This is a move, not a rewrite. Construction order is unchanged, and the names
src/composition.ts exports are unchanged. Callbacks into a context built later
(Identity into Property, Portal and Integration, Portal into Reporting,
Integration into Review) are passed as getters and first called after
construction ends, as the earlier closures were.

Client import protection now covers src/composition/** as well as
composition.ts, so the moved wiring stays out of the browser bundle. Tests that
read the composition source now read the file that holds the code; the Identity
check for the session port is tied to the Identity context call, because the
name now also appears elsewhere. The complexity suppression moved with the
preamble it describes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / Security Evidence

Commit: f666a47ff95b38301b632fcc583f5188eecc902c

Security evidence gate passed (success)

No security-sensitive scanner-evidence gap detected.

Mode: enforce

Scanned 22 changed file(s). No missing scanner-evidence signal was detected.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / PR Risk Taxonomy

Commit: f666a47ff95b38301b632fcc583f5188eecc902c

PR taxonomy review recommended (neutral)

Detected 2 PR taxonomy bucket(s): CI/CD Recommendation, Cost/Token Risk.

Scanned 22 changed file(s).

Roadmap taxonomy buckets:

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • Runtime config changes may ship without example or template updates
  • Async job or webhook changes may ship without reliability coverage
  • 8 CI or workflow path(s) changed

Paths:

  • src/composition/organization-export-contributors.test.ts
  • src/contexts/ai/infrastructure/jobs/review-analysis-backlog-jobs-policy.test.ts
  • src/contexts/feed/application/notification-delivery-runtime.test.ts
  • src/contexts/identity/runtime-dependency-injection.test.ts
  • src/contexts/review/application/ports/google-review-api.port.test.ts
  • src/shared/architecture/browser-reachability.test.ts
  • src/shared/architecture/guest-contact-containment.test.ts
  • src/shared/architecture/outbox-consumer-registration.test.ts

Cost/Token Risk

AI routing, usage, and token-budget changes should include budget or usage-limit evidence.

Signals:

  • 1 cost/token path(s) changed

Paths:

  • src/contexts/ai/infrastructure/jobs/review-analysis-backlog-jobs-policy.test.ts

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / Reference Set Readiness

Commit: f666a47ff95b38301b632fcc583f5188eecc902c

Reference set readiness gaps detected (neutral)

Reference evidence present for 0/7 areas (0%) across 22 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / Hosted Promotion Readiness

Commit: f666a47ff95b38301b632fcc583f5188eecc902c

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 22 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / Security Evidence

Commit: 0934229f573be9ab64f47ce3cf3539b2804f220e

Security evidence gate passed (success)

No security-sensitive scanner-evidence gap detected.

Mode: enforce

Scanned 22 changed file(s). No missing scanner-evidence signal was detected.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / PR Risk Taxonomy

Commit: 0934229f573be9ab64f47ce3cf3539b2804f220e

PR taxonomy review recommended (neutral)

Detected 2 PR taxonomy bucket(s): CI/CD Recommendation, Cost/Token Risk.

Scanned 22 changed file(s).

Roadmap taxonomy buckets:

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • Runtime config changes may ship without example or template updates
  • Async job or webhook changes may ship without reliability coverage
  • 8 CI or workflow path(s) changed

Paths:

  • src/composition/organization-export-contributors.test.ts
  • src/contexts/ai/infrastructure/jobs/review-analysis-backlog-jobs-policy.test.ts
  • src/contexts/feed/application/notification-delivery-runtime.test.ts
  • src/contexts/identity/runtime-dependency-injection.test.ts
  • src/contexts/review/application/ports/google-review-api.port.test.ts
  • src/shared/architecture/browser-reachability.test.ts
  • src/shared/architecture/guest-contact-containment.test.ts
  • src/shared/architecture/outbox-consumer-registration.test.ts

Cost/Token Risk

AI routing, usage, and token-budget changes should include budget or usage-limit evidence.

Signals:

  • 1 cost/token path(s) changed

Paths:

  • src/contexts/ai/infrastructure/jobs/review-analysis-backlog-jobs-policy.test.ts

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / Reference Set Readiness

Commit: 0934229f573be9ab64f47ce3cf3539b2804f220e

Reference set readiness gaps detected (neutral)

Reference evidence present for 0/7 areas (0%) across 22 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 4, 2026

Copy link
Copy Markdown

ECC Tools / Hosted Promotion Readiness

Commit: 0934229f573be9ab64f47ce3cf3539b2804f220e

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 22 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@kodes-agency
kodes-agency merged commit 935ced3 into main Nov 4, 2026
23 of 25 checks passed
@kodes-agency
kodes-agency deleted the kernel-first/composition-split branch November 4, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant