Commit ebe3a2d
refactor(phase-2-d): sibling-orchestrator import β import type (6 sites)
Phase 2-D executes the audit's #1 blocker for the sibling-orchestrator
boundary, applying the same proven mechanical pattern as Phase 2-B.
Original audit framing predicted a 3-hour "extract nominal interfaces"
structural refactor. Post-2-C survey found that most consumer sites
already use the orchestrator class only as a type annotation β
TypeScript's structural typing means `import type { AIChatService }`
IS the interface. No nominal `IAIChatService` extraction needed.
Scope shrunk from 3 hours to 50 minutes (6 lines source change).
Converted (6 files):
- src/server.ts β AIChatService (ServerOptions field type)
- src/api/ai.ts β AIChatService (3 cast sites)
- src/api/other.ts β AIChatService (1 cast site)
- src/services/gateway/ChannelBridge.ts β AIChatService + CompleteRequest
- src/services/ContentIntelligenceService.ts β AIChatService (field + ctor)
- src/api/boson.ts β BosonService (return-type annotation)
Documented "keep concrete" exceptions (6 sites, intentional value-use
at architectural boundaries): src/index.ts bootstrap instantiations
(AIChatService, BosonService), internal sibling instantiations
(BosonServiceβIdentityService, AgentKitExecutorβParticleWalletProvider,
ToolExecutorβAgentKitExecutor), and api/wallet.ts static-method
consumer (deferred β would need ProposalStore service extraction).
Strongest validation outcome possible: BYTE-IDENTICAL compiled JS for
every modified file. SHA-256 hashes of all 6 dist/*.js files are
literally the same pre vs post. TypeScript was already eliding the
unused-as-value imports; adding `import type` makes the intent
explicit in source and future-proofs against verbatimModuleSyntax: true.
This is stronger than Phase 2-B's spot-check proof (every modified
file matched, not just samples).
Why bother if the JS is identical?
1. Explicit intent in source where reviewers/audits can see it
2. Resilience to future TypeScript flag changes (verbatimModuleSyntax)
3. Audit machine-readability: grep `^import {.*ClassName}` no longer
matches these 6 sites β blocker is gone in source, not just compiled
After this commit, the audit's mechanical-pattern blockers (#1
concrete-class consumer imports + #2 ambient global singletons) are
functionally exhausted for consumer modules in pc2-node/src.
Remaining audit-derived work is architectural (mega-orchestrator
splits, mutable-global lifecycle), not mechanical.
Validation:
- tsc --noEmit clean
- npm run build:backend clean
- npm run test:unit 7/7 in 53.8ms
- ReadLints zero errors on 6 modified files
- SHA-256 byte-identical for all 6 dist/*.js files
Held behind Mac launcher 48-72h soak gate before release-branch merge.
See PHASE-2-D-SIBLING-ORCHESTRATOR-TYPE-ONLY.md for the full execution
log and CAPSULE_READINESS_REPORT.md Β§5.8 for audit-score impact.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 8ff9e8b commit ebe3a2d
11 files changed
Lines changed: 423 additions & 7 deletions
File tree
- .cursor/tasks/OPTIMISATION-AND-REFACTORING-2026-05
- pc2-node/src
- api
- services
- gateway
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1049 | 1049 | | |
1050 | 1050 | | |
1051 | 1051 | | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1052 | 1112 | | |
1053 | 1113 | | |
1054 | 1114 | | |
| |||
Lines changed: 89 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments