Knowledge
Search knowledge... ⌘K
Knowledge · Guidelines · architecture
Si Location Server Default
All SI functions (filesystem, network, DB, external API) execute server-side by default. Client-side SI is an explicit opt-in that requires a declared reason. This prevents accidental data leakage, bundle bloat from server-only deps, and security issues from exposing API keys or auth tokens to the browser.
Metadata
architecture
Procedures
Showing 3 of 4
- SIL-001 Every SI function in package.yml MUST have si_location: server | client | both
server — runs in +page.server.ts, API handler, SSR context, or Go HTTP handler client — runs in browser (+page.ts universal load, fetch in component, event handler) both — universal SvelteKit load (+page.ts runs on server first, then client on navigation) Omission = model defect. PD functions are exempt (pure, no I/O). Example package.yml export: - name: loadDictionary layer: MD execution_model: mode: sync si_location: server description: Reads YAML from disk — SSR onlycode-review
- SIL-002 si_location: client or both REQUIRES a non-empty si_location_reason
The reason must explain WHY server-side is insufficient for this function. Acceptable reasons: - Bandwidth: "Loading 500+ items on first render wastes network; paginate client-side" - Real-time: "WebSocket / SSE must persist in browser after hydration" - User-triggered: "Search depends on user input — SSR cannot prefetch" - Reduced TTI: "Heavy dataset loaded lazily after initial paint" Unacceptable reasons (will be rejected in code review): - "Easier to implement" - "SSR is complex" - "" (empty)
code-review
- SIL-003 server-declared functions must not appear in client-only contexts
si_location: server means the function MUST NOT be called from: - +page.svelte script blocks (runs in browser after hydration) - Svelte component $effect() or event handlers - Client-side stores (writable/readable that run in browser) - +page.ts (universal load — runs client-side on navigation) Violations are caught at build time when the function imports server-only modules (fs, path, etc.) but may silently fail if using abstract interfaces. Code review must check the call sites, not just the declaration.
code-review