joinery / docs
🔎 Architecture follow-ups across the workspace
1564 words · updated 6 hours ago
docs/audits/2026-10-21-monorepo.md🔎 Architecture follow-ups across the workspace
Context
This audit holds what was left over from a macro architecture review of the whole workspace on
2026-10-21, after the owner's answers removed what was intended. It is not a full read of one
project. Every file it cites was read, and so was each project's package.json, README and
AGENTS.md, along with the workflows, the hooks and nx.json.
Confirmed means checked against the cited files, and for a missing gate, a grep showing that
nothing in .husky/, .github/ or infrastructure/scripts/ runs it. Likely means reasoned
about a host or a run that wasn't exercised. Line numbers are as of commit.
Several things are deliberately left out:
packages/ui, which is intended boilerplate.- The design lab.
- The Google Cloud move, which is decided and pending.
- The release flow, which is intended.
- The boundary model's
scope:*andtype:integrationrework, already under way. - Work tracked elsewhere:
- #280 covers
@joinery/observability. - #281 covers docs drift.
- #282 covers naming and folder conventions.
- The content audit covers
@joinery/content.
- #280 covers
Bugs
| ID | Where | What goes wrong | Fix | Status |
|---|---|---|---|---|
| B1 | apps/huella-legal/modules/requiredEnv.ts:21, the module's setup | Likely. The gate throws only when process.env.CONTEXT === "production", a variable only Netlify sets. On the host 0030 decided on (Cloud Run, node-server), CONTEXT is unset, so a production build with every required variable missing passes without a word, and the first sign is a page failing at runtime. The check also reads the build environment, while the app's README says every variable is read at startup so one artifact runs anywhere; on a container host those are two different environments | Check the same lists in a Nitro startup plugin, so the runtime environment is what gets checked on any host, and key the build-time failure to a flag the deploy sets rather than to CONTEXT | wont-fix — the gate now keys on NUXT_SITE_ENV, which the deploy sets on any host, and a build-time check is enough on a host that shares build and runtime settings; whether the next host does is tracked in #244 |
Duplication
| ID | Copies | Consolidate into | Status |
|---|---|---|---|
| D1 | The repo invariants, three times: .claude/hooks/check-invariants.sh (blocking, Claude only), apps/developer-portal/tools/lib/invariants.ts (advisory; its header says it is "Duplicated from .claude/hooks/check-invariants.sh"), and the prose rules in the root AGENTS.md under "Things that look reasonable and are wrong here" | One check under infrastructure/scripts (Q1). The hook shells out to it, and the portal reports its result | fixed #405: pnpm invariants:check holds the bans; the hook runs it and the portal reports its --json findings |
| D2 | content and i18n repeat toWordChars (packages/content/src/core/contentKey.ts:5, packages/i18n/src/core/translationsKey.ts:5) and rethrowAsUpstreamError (both src/core/adapters/clients/OfetchHttpClient.ts:5). They also repeat rethrowAsHttpError and throwUnavailableError (packages/content/src/nuxt/runtime/server/utils/useContent.ts:37,51, packages/i18n/src/nuxt/runtime/server/translations.get.ts:45,51), registry.ts, the vendor errors with assertConfigured, and the baseURL check (WordpressProvider.ts:17, TranslationProvider.ts:31). Around the copies the contracts disagree: HttpClient.get returns { data, headers } in content and T in i18n, and an upstream 400/404 passes through in content but is always a 502 in i18n | First align the two contracts in place. Then extract a small vendor kit as a leaf both may depend on: the generic errors, the HttpClient port and ofetch adapter, a registry factory, assertConfigured, the h3 error mapping and the key helper. Each package keeps its own domain errors. The kit needs its own tag row | wont-fix — the contracts were aligned in #283, and the shared kit waits for a third vendor package, per the deferred tables in the content and i18n READMEs |
| D3 | The checkout → pnpm/action-setup → actions/setup-node → pnpm install --frozen-lockfile --ignore-scripts sequence in .github/workflows/ci.yml (two jobs), developer-portal-deploy.yml and release.yml | One composite action under .github/actions/ | fixed #405: .github/actions/install |
| D4 | Ten root package.json scripts (dev, test:coverage, the three issue:*, agents:sync, docs:drift, docs:map, package:check, review:version) each spell out pnpm --dir infrastructure/scripts exec node --disable-warning=ExperimentalWarning src/<name>/index.ts | One entry point in @joinery/scripts that the root scripts call by name, so the Node flags live in one place | fixed #405: the scripts package's cli script holds the Node flags |
Quality
| ID | Where | Issue | Fix | Status |
|---|---|---|---|---|
| Q1 | .claude/hooks/check-invariants.sh, .husky/pre-commit, .github/workflows/ci.yml | Confirmed. Only the Claude PostToolUse hook enforces the code bans in the root AGENTS.md: no lifecycle script, no build script in packages/*, no hand-edited version, no real URL. No Git hook or CI job checks them. A Codex or human edit that adds a postinstall passes every gate, and it works locally while doing nothing in CI, which is the failure the ban exists to prevent. docs/concepts/agent-setup.md says these checks also run in scripts and CI | Port the bans into an infrastructure/scripts check, run it in pre-commit and ci.yml, and have the hook call it. Docs checks stay advisory, per 0025 | fixed #405: pnpm invariants:check runs in the Claude hook, pre-commit and ci.yml |
| Q2 | infrastructure/scripts/src/package-contracts, the root package:check script | Confirmed. pnpm package:check validates every manifest's name, version, module type, exports and peers. No hook, CI job or Nx target runs it, so it only catches what someone remembers to run it for | Run it beside Q1's check in pre-commit and ci.yml | fixed #405: the package contracts are part of pnpm invariants:check |
| Q3 | packages/configs/src/eslint/lib/ (boundaries.ts, coreIsolation.ts, layerIsolation.ts, templateCalls.ts), src/vitest/setup/prepareNuxt.mjs, src/vitest/setup/consoleGuard.ts, src/playwright/server.ts, src/playwright/teardown.ts | Confirmed. Every other project's lint, test and e2e gates come from this package, and it has no spec at all. A regression in the boundary table, the custom templateCalls rule or prepareNuxt weakens every project silently: lint and tests still pass, they just check less | Add RuleTester specs for the custom rules, and a fixture spec proving the boundary config rejects a forbidden edge. Add unit specs for the setup and Playwright helpers, which needs a vitest.config.ts in configs | fixed #231/#232: rule and factory specs, and #405 adds boundaries.spec.ts rejecting a forbidden edge |
| Q4 | infrastructure/scripts/eslint.config.ts, 0004 lines 111–116 | Confirmed. 0004 names an import-direction rule for **/domain/** (no fs, no subprocess, no prompts) as its follow-up. It never landed, and the package's ESLint config is the plain node preset. All nine script folders keep to the layout today, by convention only | Add a no-restricted-imports block for **/domain/** to configs, shaped like layerIsolation.ts, and apply it in the scripts config | fixed #405: eslint.pureDomain, appended by the scripts config |
| Q5 | packages/configs/src/eslint/lib/ignores.ts:1, baseIgnores | Confirmed. "*.config.ts" is in the base ignore list, so no project's nuxt.config.ts, vitest.config.ts, eslint.config.ts or playwright.config.ts is ever linted or formatted. Some carry real logic: huella-legal's nuxt.config.ts holds inline modules and pages:extend hooks. The entry came in with da93fcf ("fix: Eslint configs") and no stated reason | Lint them with a block that isn't type-checked, or write the reason for excluding them into ignores.ts | fixed #405: root config files are linted with the type-aware rules off |
| Q6 | apps/huella-legal/nuxt.config.ts:38-44, :89 and :101-102, the requiredEnv blocks | Confirmed. The app lists the packages' own runtime keys (NUXT_CONTENT_VENDOR_BASE_URL, NUXT_TRANSLATIONS_VENDOR_*). Which keys a vendor needs is package knowledge. Every new app copies the list, and a key renamed inside a package leaves each app checking the old name | Have each package's Nuxt module declare and check the keys its configured vendor needs, so the app lists only its own. Do it together with B1 | fixed #252: dropping @joinery/i18n and hardcoding the WordPress root left the app no package keys to list |
| Q7 | .github/workflows/developer-portal-deploy.yml:44 | Likely. Every push to master runs the whole-workspace pnpm test:coverage, with no paths filter, right after ci.yml has tested the affected projects of the same commit. The workflow passes no NX_CLOUD_ACCESS_TOKEN, so unless the remote cache answers anyway, a docs-only merge re-runs every suite in the repo | Pass the cache token, or path-filter the workflow to what the portal renders | fixed daac93e (#330) |
| Q8 | renovate.json, .github/dependabot.yml | Confirmed. Both dependency bots are configured. Renovate has authored no commit in the history; Dependabot has authored 18, and dependabot-auto-merge.yml is built around it. renovate.json reads as active config, and it isn't | Delete renovate.json, or retire Dependabot if Renovate is the intent | fixed |
| Q9 | apps/huella-legal/package.json:52, idb | Confirmed. It is declared as a dependency, and nothing in the app imports it | Remove it | fixed |
Order
- Q1, Q2 and D1 together. One gate in
scriptsmakes the bans hold for every author. D1 disappears once the hook and the portal both call it. - Q3 next. It pins the presets every other project's gates depend on. Q4 adds a rule, which should arrive with its spec.
- B1 and Q6 before the Cloud Run move. They touch the same module, and Q6 decides where B1's lists come from.
- D2 when the next vendor package or a second consumer appears. The contract alignment can go first, on its own.
- Q7, D3, Q8, D4, Q5 and Q9 are independent and small, so take them in any order.