You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "chihumyum (via GitHub)" <gi...@apache.org> on 2026/08/31 06:03:55 UTC
[PR] refactor(desktop): move Module Hub controller below AppShell [maka]
chihumyum opened a new pull request, #4315:
URL: https://github.com/apache/maka/pull/4315
## Summary
- add a hand-authored `controllerOwners` architecture policy that pins a controller implementation and symbol to one feature-owned JSX Provider
- make the policy monotonic against `main`: an owner contract cannot be removed or redirected, and its call count may only retire from `1` to `0`
- move `useModuleHubController` from `AppShellContent` into `ModuleHubProvider`
- keep AppShell event intents on a stable command port while Scheduled Tasks, the Skills catalog revision, and the Module Hub Host subscribe at their actual readers
- remove the raw controller from the production feature entry and retain it only through the testing seam
- add deterministic render-scope, command-port cleanup, architecture provenance, and production Provider-to-Host coverage
This intentionally keeps the root guard and the first protected migration in one atomic PR: the migration never lands without its anti-regression contract, and the contract lands with a real registered owner.
Refs #3439
## Performance evidence
I measured the ownership change in one Electron renderer instance with an isolated temporary profile. The run alternated legacy/scoped blocks in 7 paired rounds, with 30 awaited state updates per block. CDP CPU profiling used a 100 microsecond sampling interval; Performance metrics were sampled around each block.
| Metric | Legacy owner / 30 updates | Scoped owner / 30 updates | Change | Per update |
| --- | ---: | ---: | ---: | ---: |
| Busy JavaScript | 235.323 ms | 12.955 ms | -94.5% | 7.844 ms -> 0.432 ms |
| ScriptDuration | 230.511 ms | 12.457 ms | -94.6% | 7.684 ms -> 0.415 ms |
| TaskDuration | 357.148 ms | 98.100 ms | -72.5% | 11.905 ms -> 3.270 ms |
All 7/7 paired blocks favored the scoped owner.
This is a controlled scope benchmark: it isolates the same state update at the former AppShell owner versus the new Provider owner. It is not a claim that end-user interactions or the whole application are 94% faster; Module Hub updates are also less frequent than session switching.
The permanent, non-wall-clock regression test uses the real controller twice with identical fake services. A Scheduled Tasks update causes the legacy shell, unrelated subtree, and reader to render once; after scoping, the shell and unrelated subtree stay at zero while only the reader renders. It also verifies that a Skills refresh wakes only the Composer revision reader and that stale command-port cleanup cannot detach a newer controller target.
The temporary benchmark probes and driver were removed from the final diff.
## Ownership guarantee
The previous debt ledger could ratchet hook/import/token counts, but it could not prove controller provenance or unique runtime ownership. The new contract additionally checks:
- the exact controller import binding and call site inside the registered Provider
- direct named Provider export and JSX-only use
- directory and `/index` public-entry imports
- aliases, namespace imports, re-exports, private/intermediary barrels, runtime loads, and same-name hooks from another module
- production/testing separation and the absence of the raw controller from the public feature entry
- base monotonicity and generator preservation, without auto-blessing newly observed ownership
This is a cooperative static architecture guard, not a hostile-code proof against mechanisms such as `eval`. Future controller migrations should register their owner in `controllerOwners`; direct new stateful hooks in AppShell remain blocked by the existing AppShell hook/debt ratchets.
## Verification
- `npm run check:renderer-architecture -- --write --base upstream/main` — 71/71 checker fixtures and real checkout passed
- `npm run check:app-shell-hooks` — 42 hooks / 81 call sites, exact inventory passed
- `npm run typecheck`
- `npm run rebuild`
- `npm --workspace @maka/desktop test` — 1,719/1,719 passed
- `npm --workspace @maka/desktop run build-storybook`
- `npm --workspace @maka/desktop run smoke:storybook` — 238/238 stories passed
- `npm run lint`
- `npm run format:check`
- `npm run astryx:surface-inventory:write`
- `npm run astryx:surface-inventory` — 230 files, 1 exclusion
- `git diff --check`
- `git merge-tree --write-tree upstream/main HEAD`
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: OpenAI Codex designed and implemented the ownership boundary and guardrail, added tests, built and ran the temporary performance harness, performed independent code audits, and prepared this PR. Both commits include `Generated-by: OpenAI Codex` trailers.
## Checklist
- [x] Tests cover the change and fail without it
- [x] Lint, format, typecheck and the affected suites pass locally
Does this PR entail a change in behavior?
- [x] Yes — Module Hub state no longer re-renders AppShell-wide consumers; there is no intended user-visible UI change
- [ ] No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5512604406
@Astro-Han Rebased onto current main b714a3921 and resolved the generated renderer-architecture/Astryx inventory conflicts. The new exact head is e95a965e4.
Local validation passed: renderer architecture 80/80 against upstream/main, AppShell hook scope, Astryx inventory and fixtures, format, lint, full workspace typecheck, Desktop production build, and the Module Hub boundary/provider tests 6/6. Could you take another look when the new CI run settles? Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #4315:
URL: https://github.com/apache/maka/pull/4315
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5527847677
@Astro-Han could you take a look at the follow-up when you have a moment? This PR gates #4491 and #4498 (both register in `controllerOwners` once it lands), so it is the one to merge first.
Since your approval the branch gained one commit, `5efcc07a2` ("type the Module Hub reader boundaries"), which addresses the three P3s: typed `render` props replace `cloneElement` on both boundaries (readers' props are required again), the duplicated source-string provenance assertions are gone in favour of `controllerOwners`, and `stories.ts` is deleted with `ModuleHubHostView` exported from the public entry (details in my earlier comment above). Everything else is rebases: the branch now sits on `main` `68cda0b54` with the ledger and Astryx inventory regenerated. Exact head: `5efcc07a2c5f8066f3ea6b4649b24d466f28756f`.
Local verification on this head with Node 24: desktop `test:dist`, `typecheck` (four projects), lint, format, `check:renderer-architecture --base upstream/main`, `check:app-shell-hooks`, Astryx inventory, Knip, ASF headers, `git diff --check` — all green.
Posted by Claude Code on behalf of the PR author.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5542939550
Rebased onto `main` `ece69ab3e`. Two things in this rebase were not mechanical, so noting them for the re-review:
- **Checker merge with #4581.** `main`'s analyzer now skips type-only imports and counts only runtime specifiers; this PR's guard collects import bindings, local exports, and module loads in the same visitor. The merge keeps #4581's counting lines and this PR's collection beside them (the collection already ignored `importKind === 'type'`). The combined fixture suite is 98/98 (78 from `main` + this PR's 20), and `check:renderer-architecture --base upstream/main` passes.
- **Restored the `controllerOwners` entry.** An earlier rebase resolved the ledger conflict from `main`'s side and the regenerator kept that (empty) policy, so the Module Hub registration you reviewed had been silently dropped from the pushed heads since. It is back, byte-identical to the entry at `e95a965e4`, and the guard now validates a real owner again. Nothing else in the ledger is hand-edited.
Exact head: `7a45ed15404517f5182b480c01dbd94c5addbace`. Full local verification on it with Node 24: desktop `test:dist`, `typecheck` (four projects), lint, format, architecture check against `upstream/main`, `check:app-shell-hooks`, Astryx inventory, Knip, ASF headers, `git diff --check` — all green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5489424645
@Astro-Han Hi, can you take a look? Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5528499149
The run on `646766361` failed only in Desktop e2e, on `prompt-rail.spec.ts:370` ("manual transcript scrolling keeps exactly the visible prompt current"), with the rest of the job green. That spec exercises transcript scrolling, which this PR does not touch, and it was changed on `main` today by #4417. On this head the whole file passes locally three times in a row (`--repeat-each 3`, 33/33). Re-pushed with identical content to re-run the job; exact head `f1eec1537a7b0a71a2be98b784ba7916f3e8d6d5`.
Posted by Claude Code on behalf of the PR author.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5492628737
Working on it! The new head also need a rebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5514544993
Rebased again onto current `main` (`ad18da42c`, #4455) and regenerated the Astryx inventory, which was the only conflict; nothing else changed. Exact head: `0ddea0d3213b71d44e9a71c43b77411e5caf0811`.
Same local verification on this head with Node 24: desktop `test:dist`, `typecheck` (four projects), lint, format, `check:renderer-architecture --base upstream/main`, `check:app-shell-hooks` (41 hooks / 77 call sites), Astryx inventory, Knip, ASF headers, `git diff --check` — all green.
Automated update from Claude Code on behalf of the PR author.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5528181318
Rebased once more onto `main` `b9748a773` (#4576 landed right after the previous push; the ledger was the only conflict and was regenerated). Exact head: `646766361c70e73ebefa1a891073a8f7f9226a40`; the full local verification is green on it. The follow-up commit to look at is unchanged in content.
Posted by Claude Code on behalf of the PR author.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5514453850
Follow-up to the review, pushed as a separate commit on top of the rebase onto `main` (`c86da40d7`). Exact head: `b8152e2fd611a2559d6ba0876a0a94e0cbc15b55`.
- **P3-1 (cloneElement):** both boundaries now take a typed `render(value, children)` prop instead of cloning their child. The Session rail site passes `scheduledTasks` to `SessionNavigationProvider` explicitly; the Composer site delegates to `renderComposerMentionsProvider(surface)` in `composer-mentions.tsx`, where `skillCatalogRevision` is a required prop again (the `= 0` default is gone). Dropping either wire is now a compile error. `children` is the element AppShell already built and is forwarded untouched, so the bail-out you traced is unchanged; `module-hub-provider.test.ts` renders the boundaries the same way.
- **P3-2 (three mechanisms):** the two `provider.includes(...)` source-string assertions and the `productionEntry.includes('useModuleHubController')` check are gone from `module-hub-boundary.test.ts`; `controllerOwners` is the provenance authority. The boundary-presence string checks went with them, since the compiler now enforces that wiring.
- **P3-3 (third seam):** `stories.ts` is deleted. `ModuleHubHostView` could not move to `testing.ts`: the Desktop node suite imports `testing.js`, and `module-hub-host` pulls page modules that `dist/main` does not carry, so every module-hub test failed to load. It is exported from the public entry next to `ModuleHubHost` instead; the story takes the view from `index` and the fakes from `testing`, and the boundary regex is back to `index|testing`.
- The comment you asked for is on `createModuleHubCommandPort`, saying why the cleanup's identity check is load-bearing.
Two small changes keep `app-shell.tsx` under the token ratchet after the typed wiring (main 15,725; now 15,712): `openSession` is the shell's existing stable `openSessionInChat` callback rather than a fresh arrow, and the conditional spread for `openSkillsFolder` is a plain conditional prop. Behavior is unchanged. The arrow was one of the inputs that re-ran the connect effect on every shell render; `appendComposerText` still is, which is why the guard comment stays.
Local verification on this head with Node 24: desktop `test:dist` 1973/1973, `typecheck` (four projects), lint, format, `check:renderer-architecture --base upstream/main`, `check:app-shell-hooks` (41 hooks / 77 call sites), Astryx inventory, Knip, ASF headers, `git diff --check` — all green.
Automated update from Claude Code on behalf of the PR author.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5542949424
@Astro-Han the branch is current against `main` again at `7a45ed154`, with the two non-mechanical rebase notes in the comment above (the #4581 checker merge and the restored `controllerOwners` entry). Ready for your re-look whenever convenient; a formal review request is not something this account can set on apache/maka, so this mention stands in for it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
Re: [PR] refactor(desktop): move Module Hub controller below AppShell [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #4315:
URL: https://github.com/apache/maka/pull/4315#issuecomment-5542960937
Working on it!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org