feat(scaffold): Rust host workspace, TS VM monorepo and DI enforcement #6

Closed
computercrack-sandfortress-ci wants to merge 2 commits from feature/sf-pnt.1-scaffold into develop

Summary

host/                 Rust workspace (edition 2024, unsafe forbidden)
  clippy.toml         lenient (roots, adapters, fakes)
  core/clippy.toml    strict: disallowed-methods/-types for std::{process,fs,env,time,net}, tokio I/O and time
  core/{protocol,ports,caller-resolution,sf-core,supervisor-core,model-gateway-core,forge-gateway-core}
  bins/{sf,supervisor,model-gateway,forge-gateway}   composition roots + smoke test each
  adapters/ testing/  SystemClock / FakeClock
vm/                   npm workspace, strict tsconfig, node --test
  core/{protocol,ports,loop-core,sessiond-core}
  roots/{loop,sessiond}   src/index.ts (compose) + src/main.ts (entry) + smoke test
  testing/                fakes
  eslint.config.js  .dependency-cruiser.cjs
protocol/             ping.schema.json + vectors/ping.json (read by both contract tests)
scripts/check-host.sh, check-host-deps.sh; lefthook.yml (host + vm hooks); module-cut.md "Code layout"

Decisions: directory decides the rules (core vs roots vs testing), so clippy needs one strict file and depcruise path rules. TS tests use node --test with native type stripping (Node 24): no build, no test framework. npm workspaces, not pnpm (missing, no benefit here). Protocol: JSON Schema is the readable definition, vectors are normative; the TS test also validates vectors against the schema (ajv, dev-dependency) so they cannot drift. Everything (fmt, clippy, deps, tests) runs in pre-commit: about 4 s total, so no pre-push stage is needed.

Evidence

  • Before: no code, no checks. After: cargo test --workspace: 22 test binaries ok (protocol contract + 4 root smoke tests); npm --prefix vm run check:all: tsc, eslint, depcruise clean, 4 tests pass (ping contract x2, loop and sessiond smoke).
  • Deliberate violations (temporary files, removed afterwards):
    • Rust core crate using std::fs::read_to_string, std::env::var, std::process::Command::new, std::time::Instant::now: error: use of a disallowed method std::fs::read_to_string (also env::var, Command::new; types Command and Instant), could not compile sf-supervisor-core.
    • Production Rust root depending on sf-testing: forbidden host dependency: sf-cli-bin -> sf-testing (normal).
    • TS core: node:fs import, process.env, Date.now(), dynamic import(); root: process.cwd() outside main.ts. ESLint: 'node:fs' import is restricted, No process global, Inject a Clock, No dynamic import().
    • dependency-cruiser: roots-isolated, production-no-fakes (root and core), core-third-party-allowlist (ajv in a core module), core-no-node-builtins.
    • Real hook: staging a core file with process.env and running git commit aborted in the vm hook (No process global ... exit status 1), commit not created.
  • Note: core.hooksPath=.git/hooks (relative) makes hooks silently not run in linked worktrees (.git is a file there). I ran commits with -c core.hooksPath=<main>/.git/hooks; fix for the maintainer: git config --unset core.hooksPath.

Merge Danger

Door: two-way
Blast Radius: tooling
Suggested squash: feat(scaffold): Rust host workspace, TS VM monorepo and DI enforcement with trailer Refs: sf-pnt.1.

## Summary ``` host/ Rust workspace (edition 2024, unsafe forbidden) clippy.toml lenient (roots, adapters, fakes) core/clippy.toml strict: disallowed-methods/-types for std::{process,fs,env,time,net}, tokio I/O and time core/{protocol,ports,caller-resolution,sf-core,supervisor-core,model-gateway-core,forge-gateway-core} bins/{sf,supervisor,model-gateway,forge-gateway} composition roots + smoke test each adapters/ testing/ SystemClock / FakeClock vm/ npm workspace, strict tsconfig, node --test core/{protocol,ports,loop-core,sessiond-core} roots/{loop,sessiond} src/index.ts (compose) + src/main.ts (entry) + smoke test testing/ fakes eslint.config.js .dependency-cruiser.cjs protocol/ ping.schema.json + vectors/ping.json (read by both contract tests) scripts/check-host.sh, check-host-deps.sh; lefthook.yml (host + vm hooks); module-cut.md "Code layout" ``` Decisions: directory decides the rules (core vs roots vs testing), so clippy needs one strict file and depcruise path rules. TS tests use `node --test` with native type stripping (Node 24): no build, no test framework. npm workspaces, not pnpm (missing, no benefit here). Protocol: JSON Schema is the readable definition, vectors are normative; the TS test also validates vectors against the schema (ajv, dev-dependency) so they cannot drift. Everything (fmt, clippy, deps, tests) runs in pre-commit: about 4 s total, so no pre-push stage is needed. ## Evidence - **Before:** no code, no checks. **After:** `cargo test --workspace`: 22 test binaries ok (protocol contract + 4 root smoke tests); `npm --prefix vm run check:all`: tsc, eslint, depcruise clean, 4 tests pass (ping contract x2, loop and sessiond smoke). - Deliberate violations (temporary files, removed afterwards): - Rust core crate using `std::fs::read_to_string`, `std::env::var`, `std::process::Command::new`, `std::time::Instant::now`: `error: use of a disallowed method std::fs::read_to_string` (also env::var, Command::new; types Command and Instant), `could not compile sf-supervisor-core`. - Production Rust root depending on `sf-testing`: `forbidden host dependency: sf-cli-bin -> sf-testing (normal)`. - TS core: `node:fs` import, `process.env`, `Date.now()`, dynamic `import()`; root: `process.cwd()` outside main.ts. ESLint: `'node:fs' import is restricted`, `No process global`, `Inject a Clock`, `No dynamic import()`. - dependency-cruiser: `roots-isolated`, `production-no-fakes` (root and core), `core-third-party-allowlist` (ajv in a core module), `core-no-node-builtins`. - Real hook: staging a core file with `process.env` and running `git commit` aborted in the vm hook (`No process global ... exit status 1`), commit not created. - Note: `core.hooksPath=.git/hooks` (relative) makes hooks silently not run in linked worktrees (`.git` is a file there). I ran commits with `-c core.hooksPath=<main>/.git/hooks`; fix for the maintainer: `git config --unset core.hooksPath`. ## Merge Danger **Door:** two-way **Blast Radius:** tooling Suggested squash: `feat(scaffold): Rust host workspace, TS VM monorepo and DI enforcement` with trailer `Refs: sf-pnt.1`.
Host workspace with core crates under a strict clippy.toml, one
composition-root binary per process, adapters and fakes. VM npm workspace
with core packages, composition roots, ESLint and dependency-cruiser rules.
Shared protocol source with a ping contract test in both languages.
Checks run in lefthook pre-commit.

Refs: sf-pnt.1
.gitignore and the dependency-cruiser config were never committed because
.git/info/exclude ignores dotfiles. Rename the config to
vm/dependency-cruiser.config.cjs and add .gitignore with -f.

Refs: sf-pnt.1
Author
Collaborator

Superseded: M1 is developed on the integration branch feature/sf-pnt-m1-walking-skeleton (this commit is its base) and reviewed and merged as one PR at the end.

Superseded: M1 is developed on the integration branch `feature/sf-pnt-m1-walking-skeleton` (this commit is its base) and reviewed and merged as one PR at the end.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ComputerCrack/Sandfortress!6
No description provided.