Repository navigation
Conversation
|
✅ Gizmo reviewed 96b22fa — posted 1 inline comment(s) this pass. Open findings: 🟡 3 minor Change walkthroughThis PR adds Command family and operations. The family gains a dev-logs command wired through Seam. Incidental data-lines work in the delta. Docs and tests. local-dev.md, the ADR index, the guides, and the core-concepts skill are updated consistently with the implementation (labelling, grouping rationale, failure-code table). Coverage spans unit tests over the operations double, executor-level tests for every failure code, real-emulator tests for |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
| if (address !== undefined && services.length === 0) { | ||
| const { kind } = await locateRecorded(current, address); | ||
| throw new CliStructuredError( | ||
| 'DEV.NO_LOGS', | ||
| `"${address}" is a ${kind}, and only services have logs.`, | ||
| { | ||
| why: `A service's logs are what its process writes to stdout and stderr; a ${kind} runs none of your code.`, | ||
| fix: 'Pass the address of a service, or no address for every service.', | ||
| meta: { address, kind }, | ||
| }, | ||
| ); | ||
| } | ||
| const [first] = services; | ||
| if (first === undefined) continue; |
There was a problem hiding this comment.
🟡 Minor · error-handling — DEV.NO_LOGS can be raised for a service address when the emulator has lost the instance, with a contradictory message
In logSources, services comes from attachment.endpoints(), which reads the compute emulator's instance registry. When the address names a recorded service whose instance the emulator no longer has (the 'missing' condition that ADR/local-dev.md handles as "a node its emulator lost… prisma dev creates it again"), services.length === 0 and the operation throws DEV.NO_LOGS with locateRecorded's kind — producing "gateway" is a service, and only services have logs., a self-contradictory message a script cannot branch on correctly. devUrl handles the identical state as DEV.NOT_RUNNING (see notRunning in this file). The emulator-not-running case is checked afterwards and never reached for such an address. Fix: when locateRecorded(current, address) reports a node whose condition is not present (or kind is service), raise DEV.NOT_RUNNING (or an emulator-specific code) instead of DEV.NO_LOGS.
There was a problem hiding this comment.
Fixed in 05cd866, with one correction to the premise. endpoints() on the Prisma Cloud attachment lists services from the directory's record (nodeInstancesOf → appNodes → readRecord), not from the emulator's registry. So a service the emulator lost is still listed, and it reads as an empty log rather than as DEV.NO_LOGS. Core still shouldn't rely on how a target builds that list, and the ordering point stands: an address whose emulator was down hit NO_LOGS before the reachability check. An unlisted address is now checked first. Emulator down gives DEV.EMULATOR_UNREACHABLE, a node its emulator lost gives DEV.NOT_RUNNING (via the existing notRunning, same as devUrl), and only then DEV.NO_LOGS. Tested in dev-current.test.ts.
| sources: readonly LogSource[], | ||
| input: DevLogsInput, | ||
| tail: number, | ||
| ): Promise<LogLine[]> { | ||
| const lines: LogLine[] = []; | ||
| for (const { attachment, services } of sources) { | ||
| const { readLogs } = attachment; | ||
| if (readLogs === undefined) throw logsUnsupported(); | ||
| const wanted = new Set(services); |
There was a problem hiding this comment.
🟡 Minor · error-handling — A non-follow read interrupted by Ctrl-C surfaces as DEV.EMULATOR_FAILED rather than a settled interrupt
readLines awaits every source's readLogs before executeDevLogs returns ok, which is the documented reason failures surface as results. But each call is wrapped in fromTarget, which converts any non-structured error — including an AbortError from input.signal firing mid-read, e.g. the CLI's own Ctrl-C while a slow read is in flight — into DEV.EMULATOR_FAILED. The command would then return a failure for a run the user deliberately interrupted. Low impact since the engine settles interrupted runs from its own signal record, but wrapping an abort as an emulator failure misnames the cause; consider rethrowing when input.signal?.aborted before calling toStructured.
There was a problem hiding this comment.
Agreed, fixed in 05cd866. readLines no longer goes through fromTarget. When readLogs rejects and input.signal has aborted, it stops with the lines read so far and returns ok, so the host settles the interrupt from its own signal record. Any other rejection is still DEV.EMULATOR_FAILED. Both cases are tested in dev-current.test.ts.
…eat an aborted read as an interrupt Review feedback on #378: - devLogs inferred "not a service" from the attachment not listing an address. The Prisma Cloud attachment lists services from the directory's record, so a lost service is still listed, but core should not rely on that, and an address whose emulator is down reached DEV.NO_LOGS before the reachability check. Now an unlisted address is checked first: emulator down -> DEV.EMULATOR_UNREACHABLE, node lost -> DEV.NOT_RUNNING, and only then DEV.NO_LOGS. - A non-follow read rejected because the caller's signal aborted (Ctrl-C) was wrapped as DEV.EMULATOR_FAILED. It now ends with the lines read so far and leaves settling the interrupt to the host. Signed-off-by: Shane Neubauer <[email protected]>
There was a problem hiding this comment.
New findings: none · trace
Still open from previous reviews: 🟡 2 minor
The local-target attachment could only follow logs, so a caller wanting
the last N lines and an exit had no way to know when the backlog ended.
The compute emulator already serves a non-follow GET of an instance's
log; the client gains readLogs() over it, and the Prisma Cloud
attachment gains readLogs({ tail }), which reads each service's log and
keeps its last lines.
readLogs is optional on LocalTargetAttachment so a target from before it
existed still loads; core refuses a non-follow read when it is absent
rather than silently following forever.
Signed-off-by: Shane Neubauer <[email protected]>
devLogs reads the logs of the app `prisma dev` last ran from a directory, through the same current() record dev url and dev stop use, so it needs no entry module. The existing log() operation takes an entry and only follows, which makes it the wrong base for a command that sits beside dev url/dev stop. By default it returns each service's last 100 lines (the default `prisma service logs` uses for a deployed service) and ends; follow: true streams new lines until the signal aborts, through the same merge log() uses. Failures reuse dev url's codes (DEV.NOT_STARTED_HERE, DEV.ADDRESS_UNKNOWN, DEV.EMULATOR_UNREACHABLE) and add DEV.NO_LOGS for an address that is not a service and DEV.LOGS_UNSUPPORTED for a target without readLogs. A crash-looping service is read, not refused: its log is exactly what the user needs. The operations double gains devLogs so hosts can test the command. Signed-off-by: Shane Neubauer <[email protected]>
`dev logs [address]` prints the services' log lines on stdout (labelled [address] unless one address was named), everything else on stderr, and each line as an output frame with data.service under --json. It takes --tail and --follow like `prisma service logs`, so the local and deployed log commands read the same. `prisma dev` prints `logs: prisma dev logs` after the URLs, plus a run-command remediation for agents, because it deliberately does not stream service output itself (9cb1288) and nothing told users where that output went. Signed-off-by: Shane Neubauer <[email protected]>
ADR-0056 amends ADR-0050 (logs were script-only because their place in the command tree was undecided) and ADR-0043 (a seventh control operation): local logs live at `prisma dev logs`, beside dev url and dev stop, leaving `prisma service logs` to mean deployed services. The running-locally guide's Logs section leads with the command and keeps the operation for code; getting-started, deploying, local-dev.md and the core-concepts skill stop telling users that logs need a script. Signed-off-by: Shane Neubauer <[email protected]>
The detach proof now checks the front door's `logs: prisma dev logs` line in the real `prisma dev --json` output, then reads the fixture's own console.log output through devLogs: one service's tail, every service's lines labelled, a followed stream that starts with the tail, and DEV.NO_LOGS for the database's address. This is the real-emulator coverage the prisma CLI's e2e exclusion for `dev logs` points at. Signed-off-by: Shane Neubauer <[email protected]>
…eat an aborted read as an interrupt Review feedback on #378: - devLogs inferred "not a service" from the attachment not listing an address. The Prisma Cloud attachment lists services from the directory's record, so a lost service is still listed, but core should not rely on that, and an address whose emulator is down reached DEV.NO_LOGS before the reachability check. Now an unlisted address is checked first: emulator down -> DEV.EMULATOR_UNREACHABLE, node lost -> DEV.NOT_RUNNING, and only then DEV.NO_LOGS. - A non-follow read rejected because the caller's signal aborted (Ctrl-C) was wrapped as DEV.EMULATOR_FAILED. It now ends with the lines read so far and leaves settling the interrupt to the host. Signed-off-by: Shane Neubauer <[email protected]>
main added command-stdout.test.ts, which inventories every command file. dev logs prints its data lines through output events, so it passes the two stdout checks; it only needed adding to the inventory. Signed-off-by: Shane Neubauer <[email protected]>
commit: |
There was a problem hiding this comment.
New findings: 🟡 1 minor · trace
Still open from previous reviews: 🟡 2 minor
| test('reads every command source', () => { | ||
| expect(sources.map((source) => source.name).sort()).toEqual([ | ||
| 'deploy.ts', | ||
| 'dev-logs.ts', |
There was a problem hiding this comment.
🟡 Minor · consistency — Core CLI test reaches into packages/9-public by relative path, inverting the package layering
The inventory test in command-stdout.test.ts:26 asserts the exact file set of two directories — its own ../commands, and packages/9-public/composer-cli/src/family, reached by a hard-coded six-level relative path (lines 8-9). That makes the only file under packages/0-framework to reference 9-public (grep-verified), inverting the repo's layering: the innermost framework package's unit tests now fail whenever the outermost public package adds, renames or moves any .ts file in src/family, and a checkout that trims 9-public breaks @internal/cli's tests through no change of its own. The public package's half of the contract already has a natural home — packages/9-public/composer-cli/test/emulator-list.test.ts in this same PR asserts the mounted command keys.
Recommended fix
Keep this test scoped to its own package's ../commands directory, and assert the data-line contract for emulator-list.ts in packages/9-public/composer-cli/test/ against that package's own src/family files, so each layer's tests depend only on its own tree.
|
Closing without merging for now. We're pausing this and will come back to it later. The branch |
Linked issue
Refs #253 (which dropped
logfrom the family). Relitigates ADR-0050's "logs are a script" call. Needs sign-off from whoever owned the 2026-08-21 PM review before merge.Summary
A
console.login aprisma devservice currently goes nowhere a user can find:devdeliberately doesn't stream service output, and reading it means writing alog()script ortail -f'ing a file under~/.prisma-composer. This addsprisma dev logs [address]besidedev url/dev stop, and makes thedevfront door say where the logs are.prisma dev logs [address]: each service's last 100 lines, then exit.--tail <n>and--followmatchprisma service logs. Log lines go to stdout, prefixed[address]unless one address is given.--jsonemits one output frame per line withdata: { service, line }.logs: prisma dev logsafter the URLs, and adds arun-commandremediation for agents.devLogsoperation on@prisma/composer/control. LikedevUrl/devStop, it finds the app throughcurrent(), so it needs no entry module.log()stays unchanged.LocalTargetAttachment.readLogs({ tail }), backed by the compute emulator's existing non-followGET /instances/<id>/logs. It's optional so an older app-side@prisma/composer-prisma-cloudfails withDEV.LOGS_UNSUPPORTEDinstead of following forever. This can happen because the CLI's Composer and the app's can be different versions.DEV.NO_LOGS(the address is a database or bucket) andDEV.LOGS_UNSUPPORTED. Otherwise it reusesDEV.NOT_STARTED_HERE,DEV.ADDRESS_UNKNOWNandDEV.EMULATOR_UNREACHABLE.local-dev.mdand the core-concepts skill are updated.Testing performed
pnpm build && pnpm typecheck && pnpm lint && pnpm lint:deps: all pass.bun testin@internal/cli(301 pass) and@internal/local-target. Real-emulator tests forreadLogsindev-emulatorsand the target'slocal-target-attach.test.ts.@prisma/integration-tests: all pass.local-dev-detachgains a step that checks the front-door line in realprisma dev --jsonoutput, then reads the fixture's ownconsole.logthroughdevLogs: one service's tail, all services labelled, a followed stream, andDEV.NO_LOGSfor the database.create-prismaNext app with aconsole.login a route handler. Itsprisma dev logs app --tail 20showed the handler's line.--followpicked up a new request live. Against the published 0.33.0 target, it givesDEV.LOGS_UNSUPPORTED.initdb(storage, auth, email, streams, prisma-cloud) fail on my machine because Homebrew's libpq has nopostgresbinary.Checklist
git commit -s).Notes for the reviewer
prisma service logs, and a command that ends by itself suits agents. Without--follow, lines are grouped by service in address order rather than interleaved. The per-service logs have no timestamps, so any interleaving would be invented.prisma dev --logs(inline streaming). The engine buffers command output while the converge child owns the terminal, so it needs its own design. ADR-0056 says so.prisma dev logsprisma-cli#369 mountsdev logs; it goes green once this publishes and the pins bump.