Skip to content

Commit 8c5bce0

Browse files
authored
refactor(move): daemon diagnostics scope into daemon-contracts (#3294) (#3297)
* refactor(move): move daemon diagnostics scope into the daemon-contracts folder The helper is a daemon-process contract shared with daemon-registration ownership, the same on-disk/wire vocabulary #2559 relocated to the shared below-both placement. It now lives under src/daemon-contracts/, where the layering graph derives its daemon-contracts zone from the folder instead of the per-file ROOT_MODULE_ZONES row. Importers re-point to the new path. * chore(gates): drop the moved daemon-diagnostics-scope row from ROOT_MODULE_ZONES The file now lives under src/daemon-contracts/, so topFolder derives its daemon-contracts zone from the folder and the per-file row is redundant. The drift test proves the declaration matches the tree either way. * docs(adr): record the daemon-diagnostics-scope move with its PR link * docs(adr): drop the landed diagnostics-scope move from the outstanding follow-up The follow-up bullet still listed daemon-diagnostics-scope.ts among the outstanding moves, contradicting this PR's moved row and intro. The bullet now records only this file's move as completed; the runtime assembly pair stays outstanding under #3294, which is that pair's own PR to update. Scope words track the single landed move: the folder derives its zone, this move completes this file's collocation.
1 parent c273835 commit 8c5bce0

6 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎docs/adr/0033-collocation-decision-table.md‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ already owns the operations behind the vocabulary.
119119
`#3288` assigns every process-root module a logical zone in
120120
`scripts/layering/root-module-zones.ts` (`daemon-contracts` rank 2, `command-runtime` rank 3,
121121
`platform-runtime` rank 4, …) while leaving the files physically in place. Per the maintainer
122-
design decision, that reclassification is **not** completed collocation: the physical moves for
123-
`daemon-diagnostics-scope.ts`, `runtime-command-surface.ts`, and `runtime-factory.ts` remain
124-
outstanding and are tracked as #3294 (child of #3276). The other rows below are keeps: the
122+
design decision, that reclassification is **not** completed collocation: the physical moves under
123+
#3294 (child of #3276) replace each file's row with folder-derived ownership.
124+
`daemon-diagnostics-scope.ts` has moved into `src/daemon-contracts/`; `runtime-command-surface.ts`
125+
and `runtime-factory.ts` remain outstanding. The other rows below are keeps: the
125126
daemon ⇄ client shared files (`daemon-policy-file.ts`, `provider-credential-fingerprint.ts`,
126127
`request-progress-protocol.ts`) trace to #2559, which relocated the shared contracts **to the
127128
process root** so the client stops importing `src/daemon/` at all; R78 keeps any client→daemon
@@ -132,7 +133,7 @@ constrain a relocation, they are not independent proof the placement is optimal.
132133

133134
| File | Decision | Reason |
134135
| --- | --- | --- |
135-
| `src/daemon-diagnostics-scope.ts` | move (outstanding, #3294) | Confirmed as an outstanding physical move, not reconsidered. Importers: `daemon/server/daemon-runtime.ts` and `daemon-registration-owner.ts` (static, line 25). #3288's `daemon-contracts` assignment classifies it only; #3294 owns the physical move and the row deletion from `ROOT_MODULE_ZONES`. |
136+
| `src/daemon-diagnostics-scope.ts` | moved → `src/daemon-contracts/daemon-diagnostics-scope.ts` ([#3297](https://github.com/callstack/agent-device/pull/3297)) | Physical move landed: the helper now lives under the folder that derives its `daemon-contracts` zone, so `topFolder` replaces the per-file `ROOT_MODULE_ZONES` row and an internal rename needs no ownership-table edit. |
136137
| `src/daemon-policy-file.ts` | keep | Daemon ⇄ client shared contract from #2559, declared `daemon-contracts` by #3288 — the shared-below-both ownership the spine needs, since daemon-client (rank 5) dynamically imports it. |
137138
| `src/daemon.ts` | keep | Entry point (`internal/daemon` bundle entry); composition roots stay in root by umbrella §4. |
138139
| `src/platform-runtime-apple-runner-owner.ts` | retain for this batch | `platform-runtime-*` composition seam: R13's exact-importer rule and the ADR 0022 R76 inventory key on its path, so relocation requires coordinated ownership changes to both declarations — the rules constrain the move, they do not independently prove the placement. |
@@ -164,10 +165,12 @@ files have no seam (published facade, public-type collision, root dependency fac
164165

165166
## Follow-ups (tracked on #3281)
166167

167-
- Physical root-pass moves remain **outstanding** per the maintainer design decision:
168-
`daemon-diagnostics-scope.ts`, `runtime-command-surface.ts`, and `runtime-factory.ts` move
169-
under [#3294](https://github.com/callstack/agent-device/issues/3294) (child of #3276).
170-
#3288's zone assignments classify these files; reclassification is not completed collocation.
168+
- Physical root-pass moves under [#3294](https://github.com/callstack/agent-device/issues/3294)
169+
(child of #3276): `daemon-diagnostics-scope.ts` has moved into `src/daemon-contracts/`
170+
([#3297](https://github.com/callstack/agent-device/pull/3297)); `runtime-command-surface.ts` and
171+
`runtime-factory.ts` remain **outstanding** under #3294. The folder derives its zone, replacing
172+
the moved file's `ROOT_MODULE_ZONES` row; #3288's zone assignment alone was classification, and
173+
this move completes that file's collocation.
171174

172175
## Refuted alternatives
173176

‎scripts/layering/root-module-zones.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export const ROOT_MODULE_ZONES: Readonly<Record<string, readonly string[]>> = {
2424
// On-disk and wire contracts a daemon process shares with its clients (#2559): the client
2525
// reaches the daemon over the network, so both sides read these from below.
2626
'daemon-contracts': [
27-
'src/daemon-diagnostics-scope.ts',
2827
'src/daemon-owner-cleanup.ts',
2928
'src/daemon-policy-file.ts',
3029
'src/daemon-process.ts',

src/daemon-diagnostics-scope.test.ts renamed to src/daemon-contracts/daemon-diagnostics-scope.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path from 'node:path';
44
import { afterEach, beforeEach, test } from 'vitest';
55
import { emitDiagnostic } from '@agent-device/host-kit/diagnostics';
66
import { withDaemonDiagnosticsScope } from './daemon-diagnostics-scope.ts';
7-
import { mkdtempForTestSync } from './__tests__/test-utils/tmp-dir.ts';
7+
import { mkdtempForTestSync } from '../__tests__/test-utils/tmp-dir.ts';
88

99
let dir: string;
1010
let logPath: string;
File renamed without changes.

‎src/daemon-registration-owner.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
type ProcessLockAcquisition,
2323
} from '@agent-device/host-kit/file';
2424
import { emitDiagnostic } from '@agent-device/host-kit/diagnostics';
25-
import { withDaemonDiagnosticsScope } from './daemon-diagnostics-scope.ts';
25+
import { withDaemonDiagnosticsScope } from './daemon-contracts/daemon-diagnostics-scope.ts';
2626
import type { DaemonCodeOrigin } from '@agent-device/host-kit/code-signature';
2727
import {
2828
resolveDaemonPaths,

‎src/daemon/server/daemon-runtime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import type { DaemonInvokeFn } from '../daemon-request.ts';
3939
import type { SessionRef, SessionState } from '../session-state.ts';
4040
import type { RuntimeHintValues } from '@agent-device/contracts/application-lifecycle-runtime';
4141
import { createDaemonIdleReap } from './daemon-idle-reap.ts';
42-
import { withDaemonDiagnosticsScope } from '../../daemon-diagnostics-scope.ts';
42+
import { withDaemonDiagnosticsScope } from '../../daemon-contracts/daemon-diagnostics-scope.ts';
4343
import { createSessionIdleExpiry } from './daemon-session-idle-expiry.ts';
4444
import { resolveSessionIdleExpiryMs } from '../session-idle-expiry.ts';
4545
import { finalizeDaemonLeases } from './daemon-lease-finalizer.ts';

0 commit comments

Comments
 (0)