Skip to content

Latest commit

 

History

History
81 lines (63 loc) · 8.09 KB

AGENTS.md

File metadata and controls

81 lines (63 loc) · 8.09 KB

takt_shift

A TanStack Start + React WebMCP production-scheduling sandbox, using Better Auth (local email + password), deployed as a long-lived Node process with a SQLite (Drizzle) store.

Public judging access: anyone can open / or /workspace with no credentials and fully use the sandbox. Server functions resolve the user through getSessionUserId(); a visitor without a Better Auth session gets a per-visitor anonymous id minted server-side and carried by an httpOnly cookie, so a refresh keeps the same sandbox row and two concurrent judges never share one. /sign-in redirects into /workspace (Better Auth stays wired at /api/auth/$), and no chrome suggests signing in.

A signed-in human (and a browser agent, through the same UI) can inspect a synthetic factory, create an isolated schedule scenario, optimize it, compare it against the committed baseline, and request human approval. The committed baseline and current scenario persist per session user id (real users get their own row; each anonymous visitor gets their own cookie-backed row).

It is not an MES/ERP. No multi-plant, no shared plant-of-record, no roles, and no code path that commits a schedule without a human click. If a task seems to need one of those, stop and ask.

Repo state

The scheduling sandbox (domain, reducer, WebMCP, UI, verify/) and its Better Auth + Drizzle/SQLite persistence are implemented. / is the public landing; the sandbox is /workspace. Server/SQLite is the source of truth; the client store is only a cache of the last server snapshot. Public judging access and persistence restore are done. Clerk is gone and must not be reintroduced.

Invariants

These hold everywhere; the skills explain how to satisfy them, not whether to.

  • Single mutation path. Manual UI controls and WebMCP handlers dispatch the same commands. No handler mutates scenario state directly. The reducer is the only writer of SandboxState; the database stores what the reducer returned.
  • An agent can never commit. An agent may only request review. Commit — and the schedule-revision increment — happens on a human click.
  • Protected orders never move. DOT-104 and any order flagged protected must be byte-identical before and after any optimization.
  • Overtime cap: 360 minutes. Any schedule exceeding it is invalid, not merely warned about.
  • Determinism. Fixtures and the optimizer are reproducible: same input, same output, always. No Date.now(), Math.random(), crypto, Map/Set iteration order, or locale-dependent sorting in the domain layer.
  • Reset restores the exact original fixture, not a re-derived approximation, then persists that restoration.
  • The domain layer is pure TypeScript — no React, router, network, Node, better-auth, or Drizzle imports.
  • Server is the source of truth. One sandbox row per session user id. The client store is a cache of the last server snapshot.
  • Session resolution is the identity boundary. Server functions call getSessionUserId() first; it returns the session user id, or a per-visitor anonymous id from a server-set httpOnly cookie when no session exists. Never take a userId from the client, and never gate /workspace on a session.
  • Long-lived Node + a SQLite file on a host volume. Host is Coolify on Ubuntu: one app container, persistent directory mount, instances = 1. Dockerize the app, not the database — no Coolify Database resource, no PocketBase, no second container. The .db file is not baked into the image. better-sqlite3 is not for edge/serverless. Do not retarget Cloudflare, Vercel serverless, Turso, or D1 unless asked.

Gates

  • npm only. package-lock.json is authoritative; never introduce another lockfile.
  • src/routeTree.gen.ts is generated (npm run generate-routes) — never edit it manually.
  • npm run check (Biome: tabs, double quotes) must pass.
  • npx tsc --noEmit must pass, including drizzle.config.ts.
  • npx tsx verify/run-all.ts is the suite, and verify/scaffold.test.ts is imported by it. Do not add a test script unless asked.

Skills

Load from .agents/skills/<name>/SKILL.md:

Skill Load when
domain-model touching fixtures, orders, machines, calendars, scenario/revision types, or validation in the pure TS layer
scheduling-engine changing placement, the deterministic optimizer, or constraint checks (protected orders, overtime cap, paint-change minimization)
kpi-and-comparison computing KPIs or diffing a scenario against the committed baseline
scenario-state adding or changing a command, or wiring a manual UI control / client cache
persistence touching Drizzle, SQLite, schema, seed, DATABASE_URL, server-backed dispatch, Docker/Coolify volumes, or the on-disk db
auth-better-auth touching Better Auth, sessions, userId, sign-in/out, or protecting routes / server functions
webmcp-tools adding, renaming, or removing a WebMCP tool, changing tool schemas, or touching registration lifecycle
approval-gate touching review-request, the approval dialog, commit, revision increment, or reset
landing-page touching the public landing, the WebGPU hero, or landing/chrome styling

Taste / image-gen skills may also live under .agents/skills/. They are third-party; do not treat them as product law and do not list them here.

Maintaining this file

Keep it to what's useful in almost every session. Prune rather than append; when detail belongs to one area, move it into that skill and link. Never restate a rule that already lives in a skill. CLAUDE.md is one line (@AGENTS.md) — edit this file only.

TanStack Intent - before editing files, run the matching guidance command.

tanstackIntent:

  • id: "@tanstack/react-start#react-start" run: "npx @tanstack/intent@latest load @tanstack/react-start#react-start" for: "React bindings for TanStack Start: createStart, StartClient, StartServer, React-specific imports, re-exports from @tanstack/react-router, full project setup with React, useServerFn hook."
  • id: "@tanstack/start-client-core#start-core" run: "npx @tanstack/intent@latest load @tanstack/start-client-core#start-core" for: "Core overview for TanStack Start: tanstackStart() Vite plugin, getRouter() factory, root route document shell (HeadContent, Scripts, Outlet), client/server entry points, routeTree.gen.ts, tsconfig configuration. Entry point for all Start skills."
  • id: "@tanstack/start-client-core#start-core/execution-model" run: "npx @tanstack/intent@latest load @tanstack/start-client-core#start-core/execution-model" for: "Isomorphic-by-default principle, environment boundary functions (createServerFn, createServerOnlyFn, createClientOnlyFn, createIsomorphicFn), ClientOnly component, useHydrated hook, import protection, dead code elimination, environment variable safety (VITE_ prefix, process.env)."
  • id: "@tanstack/router-core#router-core" run: "npx @tanstack/intent@latest load @tanstack/router-core#router-core" for: "Framework-agnostic core concepts for TanStack Router: route trees, createRouter, createRoute, createRootRoute, createRootRouteWithContext, addChildren, Register type declaration, route matching, route sorting, file naming conventions. Entry point for all router skills."
  • id: "@tanstack/router-core#router-core/type-safety" run: "npx @tanstack/intent@latest load @tanstack/router-core#router-core/type-safety" for: "Full type inference philosophy (never cast, never annotate inferred values), Register module declaration, from narrowing on hooks and Link, strict:false for shared components, getRouteApi for code-split typed access, addChildren with object syntax for TS perf, LinkProps and ValidateLinkOptions type utilities, as const satisfies pattern."
  • id: "@tanstack/router-plugin#router-plugin" run: "npx @tanstack/intent@latest load @tanstack/router-plugin#router-plugin" for: "TanStack Router bundler plugin for route generation and automatic code splitting. Supports Vite, Webpack, Rspack, and esbuild. Configures autoCodeSplitting, routesDirectory, target framework, and code split groupings."