Skip to content

chore: recover genuine work from mixed tree (i18n, publish pin gate, session recovery, rate-limit health, sonner, hardening) - #308

Merged
elliotBraem merged 3 commits into
mainfrom
cleanup/recovered-work
Oct 6, 2026
Merged

elliotBraem merged 3 commits into
mainfrom
cleanup/recovered-work

Conversation

@elliotBraem

@elliotBraem elliotBraem commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What happened

The working tree on main contained an accidental wholesale revert of the late-V2 line (#296–#306) — workspace prerequisite train, bos.app.ts canonical config, core-ui generated stubs, manifest contract v2, node/pnpm cutover, the MF phantom-chunk fix series, the two-database contract, and builtAt byte-stability — mixed together with genuine new work. This PR re-applies only the genuine work on top of main and drops the revert entirely. The original mixed tree is preserved locally on wip/mixed-cleanup (not pushed).

Net diff: 73 files, +1,272 / −221 (the mixed tree was +2,608 / −4,580).

Kept

  • i18n deepening (everything-dev): ui/locale.ts + ui/message-catalogs.ts; SSR locale negotiation from citynode_locale cookie + Accept-Language (q-value parsing), Vary: Cookie, Accept-Language, request-scoped locale in router context, shared locale selection across the main-UI and auth-bundle runtimes, localized RouterError / API-connection / tenant-validation copy, degraded-compose toast with Reload action, application-startup-error reload screen. Framework-level plumbing — the ui/ surface can adopt it.
  • Publish pin-verification gate (everything-dev): before writing to the registry, every pinned slot's bytes are fetched from its production URL and checked against the pin's SRI; mismatches block the publish.
  • Session recovery (everything-dev): a failing getSession errors instead of caching null as "signed out".
  • Rate limiter /health exemption (host) + integration test, with a bind-probe guard so the 127/8 isolation case skips gracefully on macOS (no lo0 alias).
  • Defensive error formatting (host, every-plugin, better-near-auth): unknown throwables (symbols, objects) stringify safely instead of throwing or printing [object Object].
  • Small correctness: staging block parsed through BosConfigInputSchema, typed server bootstrap await in server.ts, proxiedFetch forwards env/executionCtx, CSP/e2e test type fixes, Effect.sync/void hardening.

Dropped (the accidental revert + drive-bys)

  • workspace.ts / workspace-catalog.ts deletions and the hardcoded 3-package train (ADR 0022 train stays)
  • bos.config.json precedence flip (authored bos.app.ts stays canonical)
  • Core-ui stubs + manifest v2→v1 downgrade (ADR 0023/0024 stays)
  • node→bun re-migration in every-plugin and child scaffolding (pnpm/node per ADR 0026)
  • MF fix-series rollback (@orpc/* re-sharing that broke plugin loading, splitChunks/named-module-ids, self-name resolution, deepest-cause stack logging)
  • builtAt re-introduction in version manifests (byte-stability fix stays)
  • Two-database fallback removal (plugin *_DATABASE_URL → API DB fallback stays)
  • better-near-auth repo-URL revert to citynode.app, @tanstack/intent ^0.0.40 downgrade, skills library_version downgrades and broken metadata.sources
  • Deletions of tests for still-live features (prune-runtime-node-modules, router-server, plugins-ts-form, core-ui-*, remote-self-name, sync-retirement, workspace*)
  • The sonner optional-shared-dep feature (deferred to its own PR per review — the dependencies presence map was caller-coupled API surface)

Verification

  • pnpm run typecheck ✓ (all 10 workspaces)
  • pnpm run lint — 0 errors, 60 warnings (HEAD baseline: 119)
  • Test suites: ui 28 ✓ · api 2 ✓ · host vitest 180 ✓ · everything-dev 976 ✓ · every-plugin 171 ✓ · better-near-auth 129 ✓ · host e2e skips locally as at HEAD
  • 8 changesets included — merging triggers the canonical changesets release flow (version PR)

The working tree contained an accidental wholesale revert of the
late-V2 line (#296-#306: workspace train, bos.app.ts canonical config,
core-ui stubs, manifest v2, node/pnpm cutover, MF fix series,
two-database contract, builtAt byte-stability) layered together with
genuine new work. This commit re-applies only the genuine work on top
of main and drops the revert entirely.

Kept:
- i18n deepening: locale negotiation (cookie + Accept-Language with
  q-values), Vary header, request-scoped SSR locale in router context,
  shared locale across bundle runtimes, degraded-compose toast,
  localized RouterError copy; framework-level plumbing the ui surface
  can adopt
- publish pin-verification gate: block publishes whose pinned slots'
  bytes fail SRI verification against their production URLs
- session recovery: a failing getSession errors instead of caching
  null as signed-out
- rate limiter /health exemption + integration test (bind-probe guard
  for 127/8 aliases absent on macOS)
- sonner as an optional UI shared dependency
- defensive error formatting across host, every-plugin,
  better-near-auth
- staging config parsing through BosConfigInputSchema
- hygiene: typed server bootstrap await, proxiedFetch env forwarding,
  CSP/e2e test type fixes, Effect.sync/void hardening

Dropped (accidental revert): workspace.ts/workspace-catalog.ts
deletions, bos.config.json precedence flip, core-ui stubs + manifest
v1 downgrade, node->bun re-migration (every-plugin and child
scaffolding), MF fix-series rollback, builtAt re-introduction,
two-database fallback removal, better-near-auth citynode.app URL
revert and @tanstack/intent downgrade, skills version downgrades.

8 changesets added for the user-facing work.
const uiSharedDeps = createUiSharedDeps({
role,
workspaceRoot: workspaceRootAbsolute,
dependencies: { ...pkg.dependencies, ...pkg.devDependencies },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure about adding dependencies here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — reverted. The dependencies map was only a presence check (versions still came from resolveSharedVersion), so it was caller-coupled API surface for little value. The sonner optional-shared-dep feature is deferred out of this PR entirely: spec flag, dependencies option, rsbuild pass-through, and tests are all gone (cfe45e2). Will redesign in its own PR. The hydrate degraded-toast's runtime import("sonner") stays — it resolves in the ui workspace, which declares sonner.

collectCatalogs: boolean;
visit?: (link: WalkLink) => Promise<void>;
registerCleanup?: (fn: () => Promise<void>) => void;
registerCleanup?: (this: void, fn: () => Promise<void>) => void;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the this necessary on all of it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No — reverted the whole file in cfe45e2. Good catch beyond the this: void noise: the hunk also carried a slipped-in revert of dispatchEntry (hardcoding join(sourceDir, "bos.config.json") over findConfigPath), which broke authored bos.app.ts projects — a regression hiding inside a hygiene hunk. Both are gone; the file is back to main.

- Revert resolution/session.ts to main: drops the this: void
  annotations flagged in review, and a slipped-in dispatchEntry hunk
  that hardcoded bos.config.json over findConfigPath — a real
  regression for bos.app.ts-authored repos.
- Defer the sonner optional-shared-dep feature (spec flag,
  dependencies option, rsbuild pass-through, tests) — the
  dependencies map was a caller-coupled presence check; redesign in
  its own PR. The hydrate degraded-toast's runtime sonner import
  stays (resolvable in the ui workspace).
…429, client retry

The 300/15min edge budget was too strict for shared egress (NAT/VPN)
and rate-limited clients saw the site crash: raw JSON as the page
document, silently failing queries, and the session check erroring.

Host:
- general tier 300 → 2000 / 15min (RATE_LIMIT_MAX)
- new mutation tier (60/15min, RATE_LIMIT_MUTATION_MAX) for non-GET
  requests outside the transports that own their throttling (oRPC,
  Better-Auth, MCP) — direct REST writes get brute-force protection
  without touching sessions, procedures, or agents
- x-forwarded-for keying trusts only the LAST hop (proxy-appended);
  rotating a spoofed first hop no longer mints unlimited keys
- rate-limited document navigations (Accept: text/html) get a styled
  HTML retry page honoring Retry-After semantics instead of raw JSON;
  API requests keep the JSON body
- GET/HEAD /health stays exempt from both tiers

Client (everything-dev ui/api):
- the oRPC fetch retries 429s up to three times honoring Retry-After
  (capped 2s) — transient saturation self-heals in queries and the
  session check instead of surfacing errors

Tests:
- rewrite the Go regression burst: /health burst asserts the probe
  exemption (zero 429s); the 429 contract moved to /api/ping
- host integration: HTML-vs-JSON 429, mutation-tier boundaries
  (exemptions + disjoint buckets), last-hop xff semantics
- ui unit: retry-until-success and give-up-after-budget
@elliotBraem

Copy link
Copy Markdown
Contributor Author

Investigated the Regression HTTP (dev/start) failures: TestRateLimiting burst 150 GETs at /health expecting 429s — but this PR's /health exemption (the point of the change: infrastructure probes must never consume a client's budget) means probes are never limited. The test asserted the old contract; the exemption was working as designed.

While fixing it, I also addressed the broader UX concern — a rate-limited client used to see the site effectively crash (raw JSON as the page document, silently failing queries, session check erroring). 41e626b retunes the limiter:

  • General tier 300 → 2000/15min — normal browsing (incl. shared NAT/VPN egress) no longer brushes the cap
  • New mutation tier 60/15min for non-GET requests outside /api/rpc/*, /api/auth/*, /api/mcp/* — those transports own their throttling (Better-Auth's core limiter is already on in production); direct REST writes get brute-force protection
  • HTML 429 page for document navigations (Accept: text/html) honoring Retry-After — no more raw-JSON-as-the-site; API requests keep JSON
  • xff last-hop keying — closing the rotate-the-header key-minting bypass
  • Client 429 retry (3 attempts, Retry-After-aware) in the oRPC fetch — transient saturation self-heals before queries/session surface errors

Go TestRateLimiting rewritten for the new contract (probe exemption + /api/ping 429 burst + recovery); verified green locally including the full http regression suite.

@elliotBraem
elliotBraem merged commit c520871 into main Oct 6, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant