Repository navigation
refactor(daemon): sort src into feature folders - #2282
NicholaiVogel wants to merge 11 commits into
Conversation
Move every file in platform/daemon/src into a folder named for what it does, strip repeated name prefixes, and rewrite imports, worker paths, site tokens, audit lists, and docs to match. Regenerate the event-loop ledger for the new paths. Add a layout test so new files cannot land loose at the source root. Assisted-by: Hermes:claude-opus-5-5
Paths built at runtime from a file's own location (join(__dirname, ...), dirname(dirname(...)), template imports, stack-frame matching, CI path globs, and DB site tokens) were not covered by the import rewrite. Repoint each source-run candidate to the file it reached before the move; bundled dist candidates are unchanged. Assisted-by: Hermes:claude-opus-5-5
dev-daemon.ts is the package dev entry point; return it to the source root beside daemon.ts and index.ts, and align the accessor test expectations with the corrected site-token lines. Assisted-by: Hermes:claude-opus-5-5
|
Important Review skippedToo many files! This PR contains 774 files, which is 674 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 500 files.
|
The embedding isolation workflow and the release workflow run daemon tests by package-relative path; update them to the files' new locations. Assisted-by: Hermes:claude-opus-5-5
Assisted-by: Hermes:claude-opus-5-5
|
@coderabbitai review |
Action not completed
|
The DB foundation and owner-purity guards matched import strings that the move made stale, so equivalent forbidden imports passed. Resolve each import to its source path and check that instead. Also point the architecture docs at the moved files. Assisted-by: Hermes:claude-opus-5-5
The ratchet judged a renamed file's base content against the head SQL owner list, so an owner renamed in the same change lost its exemption at base and gained false raw-SQL budget. Read the owner list from the base revision of the script. Also widen the foundation guard's import scan to every relative path string so side-effect imports, require, and export-from are caught. Assisted-by: Hermes:claude-opus-5-5
Parsing the owner list from the base script could fall back to the head list or read it partially after a harmless reformat. Exempt a file's base side when its old path or any new path is a SQL owner instead. Collect foundation guard imports with the TypeScript parser so unrelated strings are ignored and every import form is seen. Assisted-by: Hermes:claude-opus-5-5
Path-based exemptions mis-handled copies into owners and owner demotions. Count each base file under the base revision's owner list, read from that revision's script with the TypeScript parser, resolving spreads and failing when the list cannot be read. The foundation guard also follows import-equals and parenthesized loaders. Assisted-by: Hermes:claude-opus-5-5
Reading the base owner list by parsing the base script kept missing ways the list could be written. Store the list in scripts/sql-owners.json so each revision's list is read as data, and fail when it is not a string array. The foundation guard now asks Bun's transpiler which modules a file loads at runtime. Assisted-by: Hermes:claude-opus-5-5
Bun's import scanner does not report import.meta.require calls, so collect literal ones alongside it. Point the contributor docs at scripts/sql-owners.json. Assisted-by: Hermes:claude-opus-5-5
Summary
platform/daemon/srchad 263 production files sitting loose at its root, most of them prefixed with what they belong to (transcript-import-*,db-owner-*,ontology-*,memory-*). This PR sorts every file into a folder named for what it does, so the tree reads like a table of contents:Most folders are features (
recall/,dreaming/,sources/,transcripts/, ...). Four are shared plumbing:http/(routes, hooks, MCP),db/(the DB owner, integrity, maintenance),runtime/(process lifecycle, logging, updates), andworkers/(scheduled jobs that have no feature of their own). Repeated name prefixes are dropped once a file sits in its folder, sotranscript-import-commit.tsbecomestranscripts/import/commit.ts. Tests move with the file they cover.This is a move, not a rewrite. No behavior changes are intended.
Changes
join(__dirname, "..", ...),dirname(dirname(...)), stack-frame matching in DB call-site attribution) now points at the same file it reached before the move. The bundleddist/candidates are unchanged. Files:dreaming/tools/acpx-mcp.ts,http/routes/{dashboard,skills,state}.ts,runtime/service/service.ts,db/observability/sync-attribution.ts.scripts/daemon-layout.test.ts(new, wired into the PR baseline guardrails): fails if a production file lands loose at thesrc/root or an unlisted top-level folder appears.src/__tests__/worker-sqlite-poc.ts, a standalone proof-of-concept script with no references anywhere in the repo. This is the one change that isn't a move.Type
feat— new user-facing feature (bumps minor)fix— bug fixrefactor— restructure without behavior changechore— build, deps, config, docsperf— performance improvementtest— test coveragePackages affected
@signet/core@signet/daemon@signet/cli/ dashboard@signet/sdk@signet/connector-*@signet/webpredictorscripts/audits and their tests, CONTRIBUTING, AGENTS.md,docs/,web/docsScreenshots
No UI changes.
Migration Notes (if applicable)
No migrations touched.
Testing
bun testpassesbun run typecheckpassesbun run lintpassesThe full hermetic suite (
bun scripts/run-hermetic-tests.ts ./scripts ./tests ./platform/core ./platform/daemon ./surfaces/cli) ran on this branch and on its base. Thebun testbox stays unticked because the base itself has failures. Every failure on this branch either also fails on the base, or (for the native-memory, notion, and recall-timeline tests) changes from run to run on both branches. Every test file that failed only here was rerun alone on both branches; none of the failures come from this change.Gates run locally:
bun run audit:ratchet,audit:database-ownership,audit:agent-identity,comments:check,bun scripts/audit-event-loop-contract.ts,bun scripts/sync-root-docs.ts --check, and the daemon build. The build still emits the same worker bundle names:db-owner-worker.js,embedding-worker.js,mcp-stdio.js, and the rest.Real daemon: an isolated daemon (scratch workspace,
HOMEand port) was started on base and on this branch, once from source (bun src/daemon.ts) and once from the bundle (dist/daemon.js). All four runs gave identical results:mcp-stdiolists the same 62 tools.To reproduce the main check:
AI disclosure
Assisted-bytags in commits)Notes
memory/is now the shared memory-record model, not a feature.@signet/core. Both are separate follow-ups.