proteum 2.1.9 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.codex/environments/environment.toml +11 -0
  2. package/AGENTS.md +27 -11
  3. package/README.md +30 -11
  4. package/agents/project/AGENTS.md +172 -123
  5. package/agents/project/CODING_STYLE.md +1 -1
  6. package/agents/project/app-root/AGENTS.md +16 -0
  7. package/agents/project/client/AGENTS.md +5 -5
  8. package/agents/project/client/pages/AGENTS.md +13 -13
  9. package/agents/project/diagnostics.md +19 -10
  10. package/agents/project/optimizations.md +5 -6
  11. package/agents/project/root/AGENTS.md +297 -0
  12. package/agents/project/server/routes/AGENTS.md +2 -2
  13. package/agents/project/server/services/AGENTS.md +4 -2
  14. package/agents/project/tests/AGENTS.md +9 -2
  15. package/cli/app/index.ts +31 -7
  16. package/cli/commands/configure.ts +226 -0
  17. package/cli/commands/dev.ts +0 -2
  18. package/cli/commands/diagnose.ts +33 -1
  19. package/cli/commands/explain.ts +1 -1
  20. package/cli/commands/migrate.ts +51 -0
  21. package/cli/commands/orient.ts +169 -0
  22. package/cli/commands/perf.ts +8 -1
  23. package/cli/commands/verify.ts +1003 -49
  24. package/cli/compiler/artifacts/manifest.ts +4 -4
  25. package/cli/compiler/artifacts/routing.ts +2 -2
  26. package/cli/compiler/artifacts/services.ts +12 -3
  27. package/cli/compiler/client/index.ts +65 -19
  28. package/cli/compiler/common/files/style.ts +47 -2
  29. package/cli/compiler/common/generatedRouteModules.ts +31 -38
  30. package/cli/compiler/common/index.ts +10 -0
  31. package/cli/compiler/common/proteumManifest.ts +1 -0
  32. package/cli/compiler/server/index.ts +34 -9
  33. package/cli/context.ts +6 -1
  34. package/cli/index.ts +7 -8
  35. package/cli/migrate/pageContract.ts +516 -0
  36. package/cli/paths.ts +47 -6
  37. package/cli/presentation/commands.ts +100 -10
  38. package/cli/presentation/devSession.ts +4 -6
  39. package/cli/presentation/help.ts +2 -2
  40. package/cli/presentation/ink.ts +10 -5
  41. package/cli/presentation/welcome.ts +2 -4
  42. package/cli/runtime/commands.ts +94 -1
  43. package/cli/scaffold/index.ts +2 -2
  44. package/cli/scaffold/templates.ts +4 -2
  45. package/cli/utils/agents.ts +273 -58
  46. package/client/dev/profiler/index.tsx +3 -2
  47. package/client/router.ts +10 -2
  48. package/client/services/router/index.tsx +6 -22
  49. package/common/dev/connect.ts +20 -4
  50. package/common/dev/console.ts +7 -0
  51. package/common/dev/contractsDoctor.ts +354 -0
  52. package/common/dev/diagnostics.ts +10 -7
  53. package/common/dev/inspection.ts +830 -38
  54. package/common/dev/performance.ts +19 -5
  55. package/common/dev/profiler.ts +1 -0
  56. package/common/dev/proteumManifest.ts +5 -4
  57. package/common/dev/requestTrace.ts +78 -1
  58. package/common/env/proteumEnv.ts +10 -3
  59. package/common/router/contracts.ts +8 -11
  60. package/common/router/index.ts +2 -2
  61. package/common/router/pageData.ts +72 -0
  62. package/common/router/register.ts +10 -46
  63. package/common/router/response/page.ts +28 -16
  64. package/docs/assets/unique-domains-chip.png +0 -0
  65. package/docs/dev-sessions.md +8 -4
  66. package/docs/diagnostics.md +77 -11
  67. package/docs/migrate-from-2.1.3.md +388 -0
  68. package/docs/request-tracing.md +42 -9
  69. package/package.json +6 -1
  70. package/scripts/update-codex-agents.ts +2 -2
  71. package/server/app/container/console/index.ts +11 -1
  72. package/server/app/container/trace/index.ts +370 -72
  73. package/server/app/devDiagnostics.ts +1 -1
  74. package/server/app/index.ts +5 -1
  75. package/server/services/auth/index.ts +9 -0
  76. package/server/services/prisma/index.ts +15 -12
  77. package/server/services/router/http/index.ts +1 -1
  78. package/server/services/router/index.ts +105 -23
  79. package/server/services/router/request/api.ts +7 -1
  80. package/server/services/router/request/index.ts +2 -1
  81. package/server/services/router/response/index.ts +8 -28
  82. package/types/global/vendors.d.ts +12 -0
  83. package/types/vendors.d.ts +12 -0
  84. package/common/router/pageSetup.ts +0 -51
@@ -1,12 +1,13 @@
1
1
  # Diagnostics and Explainability
2
2
 
3
- Proteum exposes two manifest-backed diagnostics surfaces plus one composite request-diagnosis surface:
3
+ Proteum exposes three manifest-backed orientation and diagnostics surfaces plus one composite request-diagnosis surface:
4
4
 
5
+ - `proteum orient`: resolve the likely owner, guidance files, connected boundaries, and next steps before opening code
5
6
  - `proteum explain`: inspect the generated app structure
6
7
  - `proteum doctor`: inspect manifest diagnostics
7
8
  - `proteum diagnose`: combine owner lookup, diagnostics, matching request traces, and buffered server logs for one concrete query or path
8
9
 
9
- These are not separate models for different tools. `explain` and `doctor` share the same generated manifest snapshot, while `diagnose` layers live dev-only request data on top of that same framework view.
10
+ These are not separate models for different tools. `orient`, `explain`, and `doctor` share the same generated manifest snapshot, while `diagnose` layers live dev-only request data on top of that same framework view.
10
11
 
11
12
  Performance inspection is a sibling surface, not a separate instrumentation stack: `proteum perf` and the profiler `Perf` tab aggregate the same dev-only request traces that back `proteum trace`.
12
13
 
@@ -14,8 +15,9 @@ Performance inspection is a sibling surface, not a separate instrumentation stac
14
15
 
15
16
  The canonical snapshot lives in `./.proteum/manifest.json`.
16
17
 
17
- Proteum uses that same manifest in six places:
18
+ Proteum uses that same manifest in seven places:
18
19
 
20
+ - `proteum orient` for owner lookup, guidance resolution, connected-boundary summary, and next-step suggestions
19
21
  - `proteum explain` for human-readable and `--json` output
20
22
  - `proteum doctor` for human-readable and `--json` output
21
23
  - `proteum explain owner <query>` for ownership lookup over the manifest index
@@ -32,6 +34,8 @@ If a command such as `proteum explain`, `proteum doctor`, `proteum diagnose`, or
32
34
  Common usage:
33
35
 
34
36
  ```bash
37
+ proteum orient /api/Auth/CurrentUser
38
+
35
39
  proteum explain
36
40
  proteum explain owner /api/Auth/CurrentUser
37
41
  proteum explain --routes --controllers --commands
@@ -46,14 +50,34 @@ proteum diagnose /
46
50
  proteum diagnose /dashboard --port 3101
47
51
  proteum diagnose /api/Auth/CurrentUser --url http://127.0.0.1:3101
48
52
 
53
+ proteum verify owner /api/Auth/CurrentUser
54
+ proteum verify request /dashboard --port 3101
55
+ proteum verify browser /dashboard --port 3101 --session-email admin@example.com --session-role ADMIN
56
+
49
57
  proteum perf top --since today
50
58
  proteum perf request /dashboard --port 3101
51
59
  proteum perf compare --baseline yesterday --target today --group-by route
52
60
  proteum perf memory --since 1h --group-by controller
53
61
  ```
54
62
 
63
+ `proteum orient --json` emits:
64
+
65
+ - `query`
66
+ - `normalizedQuery`
67
+ - `app`
68
+ - `guidance`
69
+ - `owner`
70
+ - `connected`
71
+ - `nextSteps`
72
+ - `warnings`
73
+
55
74
  `proteum explain --json` emits the selected manifest sections as machine-readable JSON.
56
75
 
76
+ `proteum explain owner <query> --json` keeps the existing owner ranking shape and adds:
77
+
78
+ - `scopeLabel`
79
+ - `originHint`
80
+
57
81
  `proteum doctor --json` emits:
58
82
 
59
83
  - `summary.errors`
@@ -64,6 +88,8 @@ proteum perf memory --since 1h --group-by controller
64
88
  `proteum diagnose` emits a composite response with:
65
89
 
66
90
  - `owner`
91
+ - `orientation`
92
+ - `chain`
67
93
  - `doctor`
68
94
  - `contracts`
69
95
  - `request`
@@ -71,13 +97,31 @@ proteum perf memory --since 1h --group-by controller
71
97
  - `suspects`
72
98
  - `serverLogs`
73
99
 
100
+ `proteum verify owner|request|browser --json` emits:
101
+
102
+ - `action`
103
+ - `target`
104
+ - `orientation`
105
+ - `introducedFindings`
106
+ - `preExistingFindings`
107
+ - `verificationSteps`
108
+ - `result`
109
+
74
110
  `proteum perf` emits trace-derived performance views:
75
111
 
76
112
  - `top`: grouped hot paths with avg, p95, CPU, SQL, render, and heap deltas
77
- - `request`: one traced request waterfall with stage timings, CPU, SQL, render, self time, and payload sizes
113
+ - `request`: one traced request waterfall with stage timings, CPU, SQL, render, self time, payload sizes, chain attribution, and SQL fingerprints
78
114
  - `compare`: grouped baseline vs target deltas
79
115
  - `memory`: grouped heap and RSS drift summaries
80
116
 
117
+ Focused verification defaults to the smallest trustworthy surface first:
118
+
119
+ - `verify owner`: orient the target, then choose request, command, or local owner-scoped diagnostics
120
+ - `verify request`: hit one real request, collect `diagnose`, and classify introduced vs pre-existing findings
121
+ - `verify browser`: only when browser-visible behavior matters, using an app-local isolated Playwright workspace
122
+
123
+ Focused verification fails on introduced blocking findings by default and does not fail on unrelated pre-existing blockers unless `--strict-global` is passed.
124
+
81
125
  ## Dev HTTP Endpoints
82
126
 
83
127
  In `profile: dev`, the running app exposes:
@@ -138,14 +182,36 @@ During `proteum dev`, the bottom profiler is the human-facing UI over the same d
138
182
 
139
183
  Use the profiler when a human needs to browse the same data that an agent or CLI command can already inspect directly.
140
184
 
185
+ ## Runtime Contract Diagnostics
186
+
187
+ `proteum doctor --contracts` now emits additive runtime-focused diagnostics for framework-owned failures that are often misdiagnosed as leaf-component bugs:
188
+
189
+ - `runtime/provider-hook-outside-provider`
190
+ - `runtime/client-only-hook-in-ssr`
191
+ - `runtime/router-context-outside-router`
192
+ - `runtime/connected-boundary-mismatch`
193
+
194
+ Each diagnostic includes:
195
+
196
+ - `code`
197
+ - `message`
198
+ - `filepath`
199
+ - `sourceLocation`
200
+ - `fixHint`
201
+ - `relatedFilepaths`
202
+
203
+ Treat these as framework contract failures first. The fix usually belongs at the provider, router, connected-boundary, or SSR/client split where the contract was broken, not only in the component that happened to throw.
204
+
141
205
  ## Agent Workflow
142
206
 
143
207
  For AI coding agents or automation:
144
208
 
145
- 1. Read `./.proteum/manifest.json` or run `proteum explain --json`.
146
- 2. Run `proteum doctor --json` and `proteum doctor --contracts --json` to inspect framework and generated-artifact diagnostics.
147
- 3. Run `proteum explain owner <query>` when you need to map a route, controller path, or generated artifact back to source.
148
- 4. For concrete request-time behavior, start with `proteum diagnose <path> --port <port>`.
149
- 5. For performance, CPU, SQL, render, or memory questions, use `proteum perf top|request|compare|memory` against the same running dev server.
150
- 6. Use `proteum trace ...` when you need lower-level event detail than `diagnose` or `perf` provides.
151
- 7. Open the profiler only when a human-readable view helps; it should agree with the CLI after refresh.
209
+ 1. Start with `proteum orient <query>` when the target might be generated, connected, framework-owned, or multi-repo.
210
+ 2. Read `./.proteum/manifest.json` or run `proteum explain --json` only after you know which surface matters.
211
+ 3. Run `proteum doctor --json` and `proteum doctor --contracts --json` to inspect framework and generated-artifact diagnostics.
212
+ 4. Use `proteum verify owner <query>` or `proteum diagnose <path> --port <port>` for the smallest trustworthy runtime surface before broad checks.
213
+ 5. Use `proteum verify browser` for browser-visible verification, and only drop to direct Playwright when request-level verification cannot reproduce the issue. Keep auth sourced from `proteum session`, and reserve browser flows for the final verifier agent unless they are the only trustworthy surface.
214
+ 6. For performance, CPU, SQL, render, cache, or connected-boundary questions, use `proteum perf request <requestId|path>` against the same running dev server.
215
+ 7. Use `proteum trace ...` when you need lower-level event detail than `diagnose` or `perf` provides.
216
+ 8. Run global checks second, not first. Unrelated diagnostics should remain visible but non-blocking during focused verification unless strict global mode is required.
217
+ 9. Open the profiler only when a human-readable view helps; it should agree with the CLI after refresh.
@@ -0,0 +1,388 @@
1
+ # Migrating from Proteum 2.1.3
2
+
3
+ This guide covers the breaking changes between `proteum@2.1.3` and the current framework code in this repository.
4
+
5
+ The important conclusion is that the breaking surface is mostly at the app root and tooling contract level, not in day-to-day page, controller, or service authoring. In the repo diff from `2.1.3` to the current `2.1.9` line, I did not find a mandatory rewrite of `Router.page(...)`, controller methods, or normal service method bodies. The required migration is mainly about config files, env, service metadata discovery, and connected-app setup.
6
+
7
+ ## Breaking Changes Summary
8
+
9
+ ### 1. `identity.yaml` is no longer supported
10
+
11
+ `2.1.3` expected a YAML file at the app root:
12
+
13
+ - `identity.yaml`
14
+
15
+ Current Proteum requires a typed TypeScript config:
16
+
17
+ - `identity.config.ts`
18
+
19
+ The file must default-export `Application.identity(...)` from `proteum/config`.
20
+
21
+ ### 2. `proteum.config.ts` is now required
22
+
23
+ `2.1.3` had no app-level setup file for compiler or connected-project config.
24
+
25
+ Current Proteum requires:
26
+
27
+ - `proteum.config.ts`
28
+
29
+ The file must default-export `Application.setup(...)` from `proteum/config`.
30
+
31
+ This is where app-level framework config now lives, especially:
32
+
33
+ - `transpile`
34
+ - `connect`
35
+
36
+ ### 3. `URL_INTERNAL` is now a required env var
37
+
38
+ `2.1.3` required:
39
+
40
+ - `ENV_NAME`
41
+ - `ENV_PROFILE`
42
+ - `PORT`
43
+ - `URL`
44
+
45
+ Current Proteum also requires:
46
+
47
+ - `URL_INTERNAL`
48
+
49
+ The router and SSR runtime now treat the internal base URL as a first-class contract instead of reusing `URL` implicitly.
50
+
51
+ ### 4. `server/services/**/service.json` is no longer part of the contract
52
+
53
+ In `2.1.3`, Proteum still read service metadata from `server/services/**/service.json`.
54
+
55
+ Current Proteum reads the service graph from:
56
+
57
+ - `server/index.ts`
58
+ - typed config exports under `server/config/*.ts`
59
+
60
+ If you still have `service.json` files from a `2.1.3` app, they are obsolete and should be removed.
61
+
62
+ If you used `priority` there, move that value into the typed service config export with `Services.config(...)`.
63
+
64
+ ### 5. Connected apps must be declared explicitly
65
+
66
+ Current Proteum adds an explicit connected-project contract in `proteum.config.ts`.
67
+
68
+ If your app consumes controllers from another Proteum app, you now need:
69
+
70
+ - `connect.<Namespace>.source`
71
+ - `connect.<Namespace>.urlInternal`
72
+
73
+ There is no namespace-based inference. The producer app must also already be on the new contract because Proteum now expects the producer app root to contain:
74
+
75
+ - `identity.config.ts`
76
+ - `proteum.config.ts`
77
+ - generated connected contract files
78
+
79
+ ### 6. `proteum dev` is stricter when connected apps are configured
80
+
81
+ If `connect` is configured, current `proteum dev` verifies the producer app health endpoint before it declares the server ready.
82
+
83
+ That means broken or stale connected-app config is now a startup failure, not just a latent runtime problem.
84
+
85
+ ### 7. Human-facing CLI output changed
86
+
87
+ Current Proteum prints a welcome banner only for the bare `proteum build` and bare `proteum dev` commands, and `proteum dev` now has tracked session files plus `list` and `stop` subcommands.
88
+
89
+ This is not an app-code migration, but it can break scripts that parse mixed stdout/stderr loosely. Prefer `--json` for automation.
90
+
91
+ ## Migration Checklist
92
+
93
+ ### 1. Upgrade the package
94
+
95
+ Update the app dependency to the current Proteum version, then reinstall.
96
+
97
+ ### 2. Replace `identity.yaml` with `identity.config.ts`
98
+
99
+ Create a new root file:
100
+
101
+ ```ts
102
+ import { Application } from 'proteum/config';
103
+
104
+ export default Application.identity({
105
+ name: 'My App',
106
+ identifier: 'MyApp',
107
+ description: 'My Proteum app',
108
+ author: {
109
+ name: 'My Team',
110
+ url: 'https://example.com',
111
+ email: 'team@example.com',
112
+ },
113
+ social: {},
114
+ language: 'en',
115
+ locale: 'en-US',
116
+ maincolor: 'white',
117
+ iconsPack: 'light',
118
+ web: {
119
+ title: 'My App',
120
+ titleSuffix: 'My App',
121
+ fullTitle: 'My App',
122
+ description: 'My Proteum app',
123
+ version: '0.0.1',
124
+ },
125
+ });
126
+ ```
127
+
128
+ Mapping from the old YAML shape is mostly direct:
129
+
130
+ - `name` stays `name`
131
+ - `identifier` stays `identifier`
132
+ - `description` stays `description`
133
+ - `author.*` stays `author.*`
134
+ - `language`, `locale`, `maincolor`, `iconsPack` keep the same meaning
135
+ - `web.*` keeps the same meaning
136
+
137
+ Then remove the old file:
138
+
139
+ - `identity.yaml`
140
+
141
+ ### 3. Add `proteum.config.ts`
142
+
143
+ Create a new root file:
144
+
145
+ ```ts
146
+ import { Application } from 'proteum/config';
147
+
148
+ export default Application.setup({
149
+ transpile: [],
150
+ connect: {},
151
+ });
152
+ ```
153
+
154
+ If your app does not consume another Proteum app and does not need package transpilation, this empty config is enough.
155
+
156
+ If your app compiles workspace or source-distributed packages through Proteum, put them in `transpile`.
157
+
158
+ Example:
159
+
160
+ ```ts
161
+ import { Application } from 'proteum/config';
162
+
163
+ export default Application.setup({
164
+ transpile: ['@acme/components'],
165
+ connect: {},
166
+ });
167
+ ```
168
+
169
+ ### 4. Add `URL_INTERNAL` to `.env`
170
+
171
+ At minimum, a migrated app now needs:
172
+
173
+ ```dotenv
174
+ ENV_NAME=local
175
+ ENV_PROFILE=dev
176
+ PORT=3010
177
+ URL=http://localhost:3010
178
+ URL_INTERNAL=http://localhost:3010
179
+ ```
180
+
181
+ For many local apps, `URL_INTERNAL` can initially match `URL`.
182
+
183
+ Use a different internal URL only when the app is reached differently from server-side code than from a browser.
184
+
185
+ ### 5. Remove `service.json` and move metadata into typed config
186
+
187
+ Delete any legacy files such as:
188
+
189
+ - `server/services/Foo/service.json`
190
+
191
+ Current Proteum derives the root service graph from `server/index.ts`, so the real source of truth is now the code that instantiates root services there.
192
+
193
+ If the old `service.json` carried priority metadata, move it into the typed config export.
194
+
195
+ Old pattern:
196
+
197
+ ```json
198
+ {
199
+ "priority": 5
200
+ }
201
+ ```
202
+
203
+ New pattern:
204
+
205
+ ```ts
206
+ import { Services } from '@server/app';
207
+ import MetricsRouter from '@/server/services/utils/Metrics/router';
208
+
209
+ export const routerMetricsConfig = Services.config(MetricsRouter, {
210
+ priority: 5,
211
+ });
212
+ ```
213
+
214
+ Then make sure `server/index.ts` instantiates the service explicitly:
215
+
216
+ ```ts
217
+ public Router = new Router(this, {
218
+ ...userConfig.routerBaseConfig,
219
+ plugins: {
220
+ metrics: new MetricsRouter(userConfig.routerMetricsConfig, this),
221
+ },
222
+ }, this);
223
+ ```
224
+
225
+ ### 6. Keep `server/index.ts` explicit
226
+
227
+ Current Proteum expects the installed root services and router plugins to be visible directly in `server/index.ts`.
228
+
229
+ The migration target is:
230
+
231
+ - root services are instantiated as class properties on the `Application` subclass
232
+ - router plugins are instantiated inside the `Router` config
233
+ - typed config values come from `server/config/*.ts`
234
+
235
+ If your `2.1.3` app relied on legacy discovery metadata, replace that with explicit code.
236
+
237
+ ## Connected-App Migration
238
+
239
+ This section applies only if one Proteum app consumes controllers from another Proteum app.
240
+
241
+ ### 1. Upgrade the producer app too
242
+
243
+ A current consumer app expects a producer app root that already has:
244
+
245
+ - `identity.config.ts`
246
+ - `proteum.config.ts`
247
+
248
+ So a `file:` connected source pointing at an untouched `2.1.3` producer will fail.
249
+
250
+ ### 2. Declare `connect` explicitly in `proteum.config.ts`
251
+
252
+ Example:
253
+
254
+ ```ts
255
+ import { Application } from 'proteum/config';
256
+
257
+ export default Application.setup({
258
+ connect: {
259
+ Product: {
260
+ source: process.env.PRODUCT_CONNECTED_SOURCE,
261
+ urlInternal: process.env.PRODUCT_URL_INTERNAL,
262
+ },
263
+ },
264
+ });
265
+ ```
266
+
267
+ ### 3. Add the new env vars used by that config
268
+
269
+ Example:
270
+
271
+ ```dotenv
272
+ PRODUCT_CONNECTED_SOURCE=file:../product
273
+ PRODUCT_URL_INTERNAL=http://localhost:3020
274
+ ```
275
+
276
+ Supported source styles in the current contract are:
277
+
278
+ - `file:../relative-producer-app`
279
+ - `github:owner/repo?ref=<ref>&path=proteum.connected.json`
280
+
281
+ ### 4. Expect stricter startup behavior
282
+
283
+ When `connect` is configured, `proteum dev` now checks the producer health endpoint before it reports ready.
284
+
285
+ If startup fails, validate in this order:
286
+
287
+ 1. The producer app has already been migrated.
288
+ 2. `connect.<Namespace>.source` points at the right producer app root.
289
+ 3. `connect.<Namespace>.urlInternal` points at the producer dev server.
290
+ 4. The producer app is running.
291
+ 5. `npx proteum connect --strict` passes in the consumer app.
292
+
293
+ ## Monorepo and Workspace Notes
294
+
295
+ Current Proteum is better at resolving hoisted and workspace installs than `2.1.3`, but old app tsconfig files often still hardcode shallow `node_modules` paths.
296
+
297
+ If your app lives inside a monorepo and TypeScript path resolution starts failing after the upgrade, align `client/tsconfig.json` and `server/tsconfig.json` with the current scaffold shape:
298
+
299
+ - include `../identity.config.ts` and `../proteum.config.ts` in the server tsconfig
300
+ - make sure the `extends` path points to the real visible `proteum/tsconfig.common.json`
301
+ - make sure the `@client/*`, `@common/*`, and `@server/*` aliases point to the real visible Proteum install
302
+ - make sure Preact compat aliases include `react-dom/client` when your app imports it
303
+
304
+ This is usually only needed for workspace or hoisted installs. Standalone apps with a local `node_modules/proteum` often keep working after the config-file migration alone.
305
+
306
+ ## CLI and Workflow Changes
307
+
308
+ These are worth updating even though they are not core app-code migrations.
309
+
310
+ ### Use `--json` for automation
311
+
312
+ Only bare `proteum build` and bare `proteum dev` runs print a banner. For scripts, CI helpers, or editor tooling, prefer:
313
+
314
+ - `npx proteum explain --json`
315
+ - `npx proteum doctor --json`
316
+ - `npx proteum connect --json`
317
+
318
+ ### Use tracked dev sessions
319
+
320
+ Current `proteum dev` supports tracked session management:
321
+
322
+ - `npx proteum dev --session-file var/run/proteum/dev/app.json --replace-existing`
323
+ - `npx proteum dev list --json`
324
+ - `npx proteum dev stop --session-file var/run/proteum/dev/app.json`
325
+
326
+ If your local workflow starts multiple dev servers, this is the current supported model.
327
+
328
+ ### New diagnostics are available
329
+
330
+ These are new capabilities, not migration requirements, but they are the fastest way to validate the upgrade:
331
+
332
+ - `npx proteum connect --strict`
333
+ - `npx proteum explain --connected --controllers`
334
+ - `npx proteum diagnose / --port <port>`
335
+ - `npx proteum perf top --port <port>`
336
+ - `npx proteum trace latest --port <port>`
337
+
338
+ ## Recommended Migration Order
339
+
340
+ 1. Upgrade the package.
341
+ 2. Convert `identity.yaml` to `identity.config.ts`.
342
+ 3. Add `proteum.config.ts`.
343
+ 4. Add `URL_INTERNAL`.
344
+ 5. Delete all legacy `service.json` files.
345
+ 6. Move any legacy service metadata, especially `priority`, into `Services.config(...)`.
346
+ 7. Confirm `server/index.ts` explicitly instantiates every root service and router plugin.
347
+ 8. If the app is connected to another app, migrate the producer app and then add explicit `connect` config.
348
+ 9. If the app is inside a workspace, align tsconfig paths with the actual Proteum install location.
349
+ 10. Run `npx proteum refresh`, then validate with the commands below.
350
+
351
+ ## Validation After Migration
352
+
353
+ Run these from the migrated app:
354
+
355
+ ```bash
356
+ npx proteum refresh
357
+ npx proteum explain --env
358
+ npx proteum doctor --contracts --strict
359
+ npx proteum check
360
+ ```
361
+
362
+ If the app uses connected projects, also run:
363
+
364
+ ```bash
365
+ npx proteum connect --strict
366
+ npx proteum explain --connected --controllers
367
+ ```
368
+
369
+ Then boot the app and verify the live runtime:
370
+
371
+ ```bash
372
+ npx proteum dev --port 3010
373
+ npx proteum diagnose / --port 3010
374
+ npx proteum trace latest --port 3010
375
+ ```
376
+
377
+ ## Short Version
378
+
379
+ If you want the shortest possible migration plan:
380
+
381
+ 1. Replace `identity.yaml` with `identity.config.ts`.
382
+ 2. Add `proteum.config.ts`.
383
+ 3. Add `URL_INTERNAL`.
384
+ 4. Delete `server/services/**/service.json`.
385
+ 5. Move any service `priority` into `Services.config(...)`.
386
+ 6. If you connect apps together, declare `connect.<Namespace>.source` and `connect.<Namespace>.urlInternal` explicitly.
387
+
388
+ That is the minimum needed to move a real `2.1.3` app onto the current Proteum contract.
@@ -1,13 +1,18 @@
1
1
  # Request Tracing
2
2
 
3
- Proteum ships with a dev-only in-memory request trace buffer so routing, controller execution, SSR, API, Prisma SQL, render behavior, and request-time performance can be inspected without attaching a debugger or scattering temporary logs through the runtime.
3
+ Proteum ships with one request-instrumentation system with two runtime shapes:
4
+
5
+ - retained dev traces for `proteum trace`, `proteum perf`, the dev-only HTTP endpoints, and the bottom profiler
6
+ - reduced request-local profiling for `request.profiling` and the router `request.finished` hook
7
+
8
+ The same API and SQL instrumentation feeds both shapes. Dev trace keeps the in-memory buffer and event timeline. Reduced profiling keeps only the finalized request/API/SQL snapshot and releases it after the `request.finished` hook runs.
4
9
 
5
10
  ## Scope
6
11
 
7
- - tracing is available only when the app runs with `profile: dev`
12
+ - retained dev tracing is available only when the app runs with `profile: dev`
8
13
  - traces are exposed through `proteum trace`, `proteum perf`, and the dev-only `__proteum/trace` and `__proteum/perf` HTTP endpoints
9
14
  - `proteum diagnose` is a separate composite surface that reads the same framework diagnostics plus one matching request trace and buffered server logs; see [diagnostics.md](diagnostics.md)
10
- - production requests are not traced by this feature
15
+ - `ENABLE_PROFILER=true` enables reduced request-local profiling in any environment, including production
11
16
 
12
17
  ## Main Commands
13
18
 
@@ -34,9 +39,9 @@ Before reproducing a bug or starting a new test pass:
34
39
  Typical debugging flow:
35
40
 
36
41
  ```bash
37
- proteum trace arm --capture deep --port 3103
38
- # reproduce the failing request once
39
- proteum trace requests --port 3103
42
+ proteum orient /dashboard
43
+ proteum diagnose /dashboard --hit /dashboard --port 3103
44
+ proteum perf request /dashboard --port 3103
40
45
  proteum trace show <requestId> --port 3103
41
46
  ```
42
47
 
@@ -44,14 +49,16 @@ Use `--url http://host:port` when the dev server is reachable on a non-standard
44
49
 
45
50
  If the request under test is protected and login UX is not the feature under test, mint an auth cookie with `proteum session <email> --role <role>` before reproducing the request. This keeps the trace focused on the protected behavior instead of the login flow.
46
51
 
47
- If you already know the failing path and want a one-shot suspect list before reading raw events, start with `proteum diagnose <path> --port <port>` and drop into `proteum trace show <requestId>` only when the lower-level event stream is still needed.
52
+ If you already know the failing path and want a one-shot suspect list before reading raw events, start with `proteum diagnose <path> --port <port>` and `proteum perf request <path> --port <port>` first, then drop into `proteum trace show <requestId>` only when the lower-level event stream is still needed.
48
53
 
49
- Trace summaries include `sql=<count>`. Detailed trace output includes both a `Calls` section for API/fetcher activity and a `SQL` section for captured Prisma queries.
54
+ Use ad hoc database queries or one-off scripts only after `orient`, `diagnose`, `perf request`, and `trace show` still leave the request chain unclear.
55
+
56
+ Trace summaries include `sql=<count>`. Detailed trace output includes both a `Calls` section for API, cache, or fetcher activity and a `SQL` section for captured Prisma queries.
50
57
 
51
58
  `proteum perf` is a grouped view over the same trace store:
52
59
 
53
60
  - `top` ranks routes, concrete paths, or controllers by avg, p95, CPU, SQL, render, self time, and heap delta
54
- - `request` shows one traced request waterfall with stage timings plus the hottest calls and SQL
61
+ - `request` shows one traced request waterfall with stage timings plus the hottest calls, SQL, chain attribution, connected boundary, and SQL fingerprints
55
62
  - `compare` shows baseline-vs-target regressions between trace windows such as `yesterday` and `today`
56
63
  - `memory` shows grouped heap and RSS drift trends
57
64
 
@@ -65,6 +72,7 @@ Depending on capture mode, traces can include:
65
72
  - route resolution start, match, and deep-mode skip reasons
66
73
  - controller start and result shape
67
74
  - synchronous SSR fetcher calls, API batch fetchers, and async request traces
75
+ - cache hits and cache writes observed during request handling
68
76
  - Prisma SQL queries with caller method/path, optional fetcher attribution, SQL text, params, kind, operation, and timing
69
77
  - created router/context keys
70
78
  - setup output keys and page data summaries
@@ -72,6 +80,14 @@ Depending on capture mode, traces can include:
72
80
  - render start/end timings and document output sizes
73
81
  - per-request CPU usage deltas plus heap and RSS snapshots before and after the request
74
82
  - normalized request errors
83
+ - additive owner, service, cache, and connected-boundary metadata propagated from route/controller resolution into downstream calls and SQL
84
+
85
+ Reduced request-local profiling keeps the finalized request summary plus API and SQL rows only:
86
+
87
+ - `request.profiling` exists before the router `request` hook runs
88
+ - `request.profiling.apiCalls` and `request.profiling.sqlQueries` start empty and are populated during request handling
89
+ - the router `request.finished` hook receives that same object after status, duration, API calls, and SQL queries are finalized
90
+ - when only reduced profiling is enabled, finished requests are released immediately after `request.finished` instead of being retained in the global trace buffer
75
91
 
76
92
  ## SQL Tracing
77
93
 
@@ -87,6 +103,21 @@ Prisma query tracing covers both ORM operations and raw queries.
87
103
 
88
104
  This currently covers SQL issued through Proteum's Prisma service, including raw helpers that flow through the same Prisma client.
89
105
 
106
+ Each traced SQL entry can now include:
107
+
108
+ - `fingerprint`: stable normalized SQL shape for repeated-query comparison
109
+ - `ownerLabel` and `ownerFilepath`: route/controller ownership propagated from the request
110
+ - `serviceLabel`: the inferred service boundary when available
111
+ - `connectedNamespace`: the connected producer namespace when the request crossed an app boundary
112
+
113
+ `proteum diagnose` and `proteum perf request` collapse those lower-level records into a compact request chain:
114
+
115
+ - route or controller
116
+ - service
117
+ - cache branch when used
118
+ - connected app boundary when used
119
+ - SQL fingerprints
120
+
90
121
  ## Capture Modes
91
122
 
92
123
  - `summary`: smallest capture, focused on request lifecycle and high-signal events
@@ -121,6 +152,7 @@ export TRACE_REQUESTS_LIMIT=200
121
152
  export TRACE_EVENTS_LIMIT=800
122
153
  export TRACE_CAPTURE=resolve
123
154
  export TRACE_PERSIST_ON_ERROR=true
155
+ export ENABLE_PROFILER=true
124
156
  ```
125
157
 
126
158
  Notes:
@@ -131,6 +163,7 @@ Notes:
131
163
  - `eventsLimit` defaults to `800`
132
164
  - `proteum dev` removes auto-persisted crash traces from `var/traces/` when the dev session stops
133
165
  - explicit `proteum trace export` files under `var/traces/exports/` are left in place
166
+ - `ENABLE_PROFILER` reuses the same request instrumentation path but skips the retained global buffer and event timeline when dev trace is otherwise off
134
167
 
135
168
  ## Memory Model
136
169
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proteum",
3
3
  "description": "LLM-first Opinionated Typescript Framework for web applications.",
4
- "version": "2.1.9",
4
+ "version": "2.2.1",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/proteum.git",
7
7
  "license": "MIT",
@@ -16,6 +16,10 @@
16
16
  "proteum": "cli/bin.js"
17
17
  },
18
18
  "dependencies": {
19
+ "@babel/generator": "^7.29.0",
20
+ "@babel/parser": "^7.29.0",
21
+ "@babel/traverse": "^7.29.0",
22
+ "@babel/types": "^7.29.0",
19
23
  "@inkjs/ui": "^2.0.0",
20
24
  "@prisma/adapter-mariadb": "7.2.0",
21
25
  "@prisma/client": "7.2.0",
@@ -69,6 +73,7 @@
69
73
  "preact": "^10.27.1",
70
74
  "preact-render-to-string": "^6.6.1",
71
75
  "prompts": "^2.4.2",
76
+ "react": "^19.2.0",
72
77
  "react-apexcharts": "^2.1.0",
73
78
  "replace-once": "^1.0.0",
74
79
  "responsive-loader": "^3.1.2",