You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
7.5 KiB

Reorganize docs: move working/audit files to docs/ and add conventions Working documents and audits were spread across the project root, mixing with standard npm/GitHub files (README, CHANGELOG, CONTRIBUTING, SECURITY, BRAND). Moves them under docs/ for a clean root and adds docs/conventions.md as the canonical document for codebase-wide naming and structure rules. Files moved to docs/ (via git mv, history preserved): - audit-1-5.md (current ecosystem audit) - AUDIT_KIMI.md - AUDIT_OPENCODE.md - AUDIT_claude.md (historical audits from prior tools) - before_0_1.md (pre-0.1 release checklist) - buss.md (bus design doc, no longer live) - NEXT_STEPS.md (roadmap) Files staying in root (npm/GitHub convention): - README.md, CHANGELOG.md, CONTRIBUTING.md, SECURITY.md, BRAND.md References updated to point at docs/: - CHANGELOG.md (line 11) - README.md (line 105) - SECURITY.md (line 3) - src/web/routes/active/security/+page.svelte (line 46) docs/conventions.md captures three rules accepted as binding for the codebase: 1. Module identifier — every artifact and lib uses its 4-letter alias (BUSS, CONN, SESS, PERM, TIMR, LOGR, CACH, STOR, FMTS, FEND, ADOM, AAPP, AUTH, LANG, HTTP, SIUM, ERRS) for both string values and constant name prefixes. Drift from this rule (BUS_*, CONNECTION_*, SESSION_*, …) is being closed in the next audit pass. 2. Constant naming — `<MOD>_<CATEGORY>_<NAME>` strictly. No exceptions (no DEFAULT_TIMER_* style). 3. Category vocabulary — fixed list of category tokens (ERR, EVENT, DIAGNOSTIC_EVENTS, METHOD, STATE, STATUS, KIND, REASON, TYPE, MODE, DEFAULT, LIMIT, ID_PREFIX, LOG_CATEGORY, LOG_MSG, ERROR_MSG, ERROR_NAME, CONTEXT_KEY). Ad-hoc categories (AUTO_REAUTH, AUTO_INVALIDATE, BUFFER_POLICY, CHANNEL_STATE) fold into one of these. The document also formalizes the layer rules and ErrCode shape that will be implemented in upcoming commits. svelte-check 1395/0 errors. No code-side regressions; the moves are file-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
# Active conventions
This document captures the **mandatory naming and structure
conventions** for the Active framework codebase. Every new module,
type, constant, and file must comply. Existing code that drifts from
these rules is treated as audit debt and migrated module by module.
The goal is single-rule homogeneity: a developer learns the convention
once and applies it everywhere. No exceptions without an explicit
decision recorded here.
---
## 1. Module identifier — 4-letter alias
Every artifact and lib that pairs with one is identified by a stable
**4-letter alias** that already lives in `svelte.config.js` as a
bundler alias (`$buss`, `$conn`, `$sess`, …).
The same alias is the canonical module identifier across the codebase:
- **Path scoping in string values** (already enforced after audit
section 2): `'buss.event.published'`, `'conn.auth_failed'`,
`'sess.lifecycle.adopted'`, `'perm.client.remote_check_failed'`.
- **Constant name prefix**: `BUSS_*`, `CONN_*`, `SESS_*`, `PERM_*`,
`TIMR_*`, `LOGR_*`, `CACH_*`, `STOR_*`, `FMTS_*`, `FEND_*`, `ADOM_*`,
`AAPP_*`, `AUTH_*`, `LANG_*`, `HTTP_*`, `SIUM_*`, `ERRS_*`.
Forbidden: full English words like `BUS_*`, `CONNECTION_*`, `SESSION_*`,
`PERMISSION_*`, `TIMER_*`, `LOGGER_*`, `CACHE_*`, `STORAGE_*`,
`FORMATS_*`, `FRONTEND_*`. Drift on this axis is being closed in a
dedicated audit pass.
---
## 2. Constant naming — `<MOD>_<CATEGORY>_<NAME>`
Every categorical module-level constant follows the pattern:
```
<MOD>_<CATEGORY>_<NAME>
```
- **`<MOD>`** — the module's 4-letter alias in caps (rule 1).
- **`<CATEGORY>`** — what kind of constant it is. Picked from the
fixed vocabulary in section 3.
- **`<NAME>`** — the specific value's identifier in
`UPPER_SNAKE_CASE`.
### Examples
```ts
// good
BUSS_DIAGNOSTIC_EVENTS
BUSS_DEFAULT_MAX_LISTENERS_PER_EVENT
BUSS_ERR_DISPOSED
SESS_EVENT_LIFECYCLE_ADOPTED
PERM_METHOD_CHECK
TIMR_STATE_PENDING
CONN_REASON_AUTH_FAILED
CACH_LIMIT_DEFAULT_MAX_ENTRIES
Replace LOGGER_CATEGORY with <MOD>_MODULE single source of truth Phase 2B.1 of the convention pass. Establishes one canonical constant per module — `<MOD>_MODULE = '<alias>'` — as the single source for the module's identifier across logger category, error message prefixes, event scopes, and any other place the module's name is needed. What changed: 1. Renamed all `<MOD>_LOG_CATEGORY` constants to `<MOD>_MODULE` (the value semantics didn't change; only the name). Affected modules: buss, conn, sess, perm (libs+arts+svrs), timr, lang, auth, http, sium, cach, stor, aapp (libs+arts), and the four fmts sub-modules (fmts, fmts.curr, fmts.dates, fmts.nums, fmts.unts). 2. Aligned values with the 4-letter alias where they didn't already: - STOR_MODULE: 'storage' → 'stor' - FMTS_MODULE: 'formats' → 'fmts' - FMTS_CURR_MODULE: 'formats.currency' → 'fmts.curr' - FMTS_DATES_MODULE: 'formats.dates' → 'fmts.dates' - FMTS_NUMS_MODULE: 'formats.numbers' → 'fmts.nums' - FMTS_UNTS_MODULE: 'formats.units' → 'fmts.unts' 3. Unified the duplicate `AAPP_MODULE` declaration: arts/aapp/consts.ts now re-exports from libs/aapp/consts.ts (canonical source). Both files used to declare it independently with different values ('app' vs 'aapp'). 4. Replaced hardcoded `'[<alias>] ...'` literals in error messages with template strings using `<MOD>_MODULE`. Every error-message constant now derives the prefix from the module identifier instead of hardcoding it. Affected files: libs/aapp/consts.ts, arts/aapp/consts.ts, libs/buss/consts.ts, libs/lang/errors.ts, arts/stor/errors.ts, arts/sium/errors.ts, arts/fmts/errors.ts, and the ERROR_PREFIX constants in arts/conn, arts/sess, arts/http, arts/timr. 5. Updated diagnostic event values to use the new module aliases: - STOR_DIAGNOSTIC_EVENTS.ERROR: 'storage.error' → 'stor.error' - All FMTS_*_DIAGNOSTIC_EVENTS values to use 'fmts.X.*' 6. Updated tests that asserted against the old values (storage-integration.test and fmts/curr/test/barrel.test). 7. Updated docs/conventions.md: replaced the LOG_CATEGORY category with the new MODULE category. Added the rule that ERROR_MSG values must use the template `[${<MOD>_MODULE}]`, never a hardcoded literal. Verification: svelte-check 1395 / 0 errors. Server 1230 tests, client 19 tests — all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
STOR_MODULE
Reorganize docs: move working/audit files to docs/ and add conventions Working documents and audits were spread across the project root, mixing with standard npm/GitHub files (README, CHANGELOG, CONTRIBUTING, SECURITY, BRAND). Moves them under docs/ for a clean root and adds docs/conventions.md as the canonical document for codebase-wide naming and structure rules. Files moved to docs/ (via git mv, history preserved): - audit-1-5.md (current ecosystem audit) - AUDIT_KIMI.md - AUDIT_OPENCODE.md - AUDIT_claude.md (historical audits from prior tools) - before_0_1.md (pre-0.1 release checklist) - buss.md (bus design doc, no longer live) - NEXT_STEPS.md (roadmap) Files staying in root (npm/GitHub convention): - README.md, CHANGELOG.md, CONTRIBUTING.md, SECURITY.md, BRAND.md References updated to point at docs/: - CHANGELOG.md (line 11) - README.md (line 105) - SECURITY.md (line 3) - src/web/routes/active/security/+page.svelte (line 46) docs/conventions.md captures three rules accepted as binding for the codebase: 1. Module identifier — every artifact and lib uses its 4-letter alias (BUSS, CONN, SESS, PERM, TIMR, LOGR, CACH, STOR, FMTS, FEND, ADOM, AAPP, AUTH, LANG, HTTP, SIUM, ERRS) for both string values and constant name prefixes. Drift from this rule (BUS_*, CONNECTION_*, SESSION_*, …) is being closed in the next audit pass. 2. Constant naming — `<MOD>_<CATEGORY>_<NAME>` strictly. No exceptions (no DEFAULT_TIMER_* style). 3. Category vocabulary — fixed list of category tokens (ERR, EVENT, DIAGNOSTIC_EVENTS, METHOD, STATE, STATUS, KIND, REASON, TYPE, MODE, DEFAULT, LIMIT, ID_PREFIX, LOG_CATEGORY, LOG_MSG, ERROR_MSG, ERROR_NAME, CONTEXT_KEY). Ad-hoc categories (AUTO_REAUTH, AUTO_INVALIDATE, BUFFER_POLICY, CHANNEL_STATE) fold into one of these. The document also formalizes the layer rules and ErrCode shape that will be implemented in upcoming commits. svelte-check 1395/0 errors. No code-side regressions; the moves are file-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
// bad (will be flagged in audit)
BUS_DIAGNOSTIC_EVENTS // wrong module prefix (rule 1)
DEFAULT_TIMER_SCOPE_SEPARATOR // category before module (rule 2)
PERMISSION_METHOD_CHECK // wrong module prefix (rule 1)
AUTO_REAUTH_USER_IDENTITY_CHANGE // missing module prefix (rule 1)
```
### Sub-categories
When a category needs internal hierarchy, append additional segments
in the `<NAME>` part, not in `<CATEGORY>`:
```ts
// good
BUSS_LISTENER_ERROR_MODE_THROW
SESS_EVENT_LIFECYCLE_ADOPTED
SESS_EVENT_LIFECYCLE_REVOKED
PERM_DEFAULT_REMOTE_FAILURE_BACKOFF_MS
// bad
BUSS_LISTENER_ERR_MODE_THROW // category split across underscores
```
---
## 3. Category vocabulary — fixed list
Only these category tokens are allowed. Adding a new category is a
deliberate decision recorded in this document, not an ad-hoc choice
inside a module.
| Category | Use |
|---|---|
Replace LOGGER_CATEGORY with <MOD>_MODULE single source of truth Phase 2B.1 of the convention pass. Establishes one canonical constant per module — `<MOD>_MODULE = '<alias>'` — as the single source for the module's identifier across logger category, error message prefixes, event scopes, and any other place the module's name is needed. What changed: 1. Renamed all `<MOD>_LOG_CATEGORY` constants to `<MOD>_MODULE` (the value semantics didn't change; only the name). Affected modules: buss, conn, sess, perm (libs+arts+svrs), timr, lang, auth, http, sium, cach, stor, aapp (libs+arts), and the four fmts sub-modules (fmts, fmts.curr, fmts.dates, fmts.nums, fmts.unts). 2. Aligned values with the 4-letter alias where they didn't already: - STOR_MODULE: 'storage' → 'stor' - FMTS_MODULE: 'formats' → 'fmts' - FMTS_CURR_MODULE: 'formats.currency' → 'fmts.curr' - FMTS_DATES_MODULE: 'formats.dates' → 'fmts.dates' - FMTS_NUMS_MODULE: 'formats.numbers' → 'fmts.nums' - FMTS_UNTS_MODULE: 'formats.units' → 'fmts.unts' 3. Unified the duplicate `AAPP_MODULE` declaration: arts/aapp/consts.ts now re-exports from libs/aapp/consts.ts (canonical source). Both files used to declare it independently with different values ('app' vs 'aapp'). 4. Replaced hardcoded `'[<alias>] ...'` literals in error messages with template strings using `<MOD>_MODULE`. Every error-message constant now derives the prefix from the module identifier instead of hardcoding it. Affected files: libs/aapp/consts.ts, arts/aapp/consts.ts, libs/buss/consts.ts, libs/lang/errors.ts, arts/stor/errors.ts, arts/sium/errors.ts, arts/fmts/errors.ts, and the ERROR_PREFIX constants in arts/conn, arts/sess, arts/http, arts/timr. 5. Updated diagnostic event values to use the new module aliases: - STOR_DIAGNOSTIC_EVENTS.ERROR: 'storage.error' → 'stor.error' - All FMTS_*_DIAGNOSTIC_EVENTS values to use 'fmts.X.*' 6. Updated tests that asserted against the old values (storage-integration.test and fmts/curr/test/barrel.test). 7. Updated docs/conventions.md: replaced the LOG_CATEGORY category with the new MODULE category. Added the rule that ERROR_MSG values must use the template `[${<MOD>_MODULE}]`, never a hardcoded literal. Verification: svelte-check 1395 / 0 errors. Server 1230 tests, client 19 tests — all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
| `MODULE` | The module's canonical 4-letter alias as a string constant. **Single source of truth** for the module's identity. Used wherever the module's identifier is needed: logger category, error message prefix, event scope, etc. Every module declares exactly one `<MOD>_MODULE = '<alias>'`. |
Reorganize docs: move working/audit files to docs/ and add conventions Working documents and audits were spread across the project root, mixing with standard npm/GitHub files (README, CHANGELOG, CONTRIBUTING, SECURITY, BRAND). Moves them under docs/ for a clean root and adds docs/conventions.md as the canonical document for codebase-wide naming and structure rules. Files moved to docs/ (via git mv, history preserved): - audit-1-5.md (current ecosystem audit) - AUDIT_KIMI.md - AUDIT_OPENCODE.md - AUDIT_claude.md (historical audits from prior tools) - before_0_1.md (pre-0.1 release checklist) - buss.md (bus design doc, no longer live) - NEXT_STEPS.md (roadmap) Files staying in root (npm/GitHub convention): - README.md, CHANGELOG.md, CONTRIBUTING.md, SECURITY.md, BRAND.md References updated to point at docs/: - CHANGELOG.md (line 11) - README.md (line 105) - SECURITY.md (line 3) - src/web/routes/active/security/+page.svelte (line 46) docs/conventions.md captures three rules accepted as binding for the codebase: 1. Module identifier — every artifact and lib uses its 4-letter alias (BUSS, CONN, SESS, PERM, TIMR, LOGR, CACH, STOR, FMTS, FEND, ADOM, AAPP, AUTH, LANG, HTTP, SIUM, ERRS) for both string values and constant name prefixes. Drift from this rule (BUS_*, CONNECTION_*, SESSION_*, …) is being closed in the next audit pass. 2. Constant naming — `<MOD>_<CATEGORY>_<NAME>` strictly. No exceptions (no DEFAULT_TIMER_* style). 3. Category vocabulary — fixed list of category tokens (ERR, EVENT, DIAGNOSTIC_EVENTS, METHOD, STATE, STATUS, KIND, REASON, TYPE, MODE, DEFAULT, LIMIT, ID_PREFIX, LOG_CATEGORY, LOG_MSG, ERROR_MSG, ERROR_NAME, CONTEXT_KEY). Ad-hoc categories (AUTO_REAUTH, AUTO_INVALIDATE, BUFFER_POLICY, CHANNEL_STATE) fold into one of these. The document also formalizes the layer rules and ErrCode shape that will be implemented in upcoming commits. svelte-check 1395/0 errors. No code-side regressions; the moves are file-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
| `ERR` | Error codes (`ErrCode` values from `$libs/errs`) |
| `EVENT` | Bus or lifecycle event names (string discriminators) |
| `DIAGNOSTIC_EVENTS` | Event values published through `Logger` (catalog object) |
| `METHOD` | Method labels for error messages (`ensureLive(METHOD)`) |
| `STATE` | Tagged-union state discriminators |
| `STATUS` | Tagged-union status discriminators |
| `KIND` | Tagged-union kind discriminators |
| `REASON` | Tagged-union reason discriminators |
| `TYPE` | Tagged-union type discriminators (when none of the above fits) |
| `MODE` | Mode discriminators (e.g. listener error mode) |
| `DEFAULT` | Default values for options |
| `LIMIT` | Maximum / minimum values |
| `ID_PREFIX` | Prefix used by ID factories |
| `LOG_MSG` | Log message strings |
Replace LOGGER_CATEGORY with <MOD>_MODULE single source of truth Phase 2B.1 of the convention pass. Establishes one canonical constant per module — `<MOD>_MODULE = '<alias>'` — as the single source for the module's identifier across logger category, error message prefixes, event scopes, and any other place the module's name is needed. What changed: 1. Renamed all `<MOD>_LOG_CATEGORY` constants to `<MOD>_MODULE` (the value semantics didn't change; only the name). Affected modules: buss, conn, sess, perm (libs+arts+svrs), timr, lang, auth, http, sium, cach, stor, aapp (libs+arts), and the four fmts sub-modules (fmts, fmts.curr, fmts.dates, fmts.nums, fmts.unts). 2. Aligned values with the 4-letter alias where they didn't already: - STOR_MODULE: 'storage' → 'stor' - FMTS_MODULE: 'formats' → 'fmts' - FMTS_CURR_MODULE: 'formats.currency' → 'fmts.curr' - FMTS_DATES_MODULE: 'formats.dates' → 'fmts.dates' - FMTS_NUMS_MODULE: 'formats.numbers' → 'fmts.nums' - FMTS_UNTS_MODULE: 'formats.units' → 'fmts.unts' 3. Unified the duplicate `AAPP_MODULE` declaration: arts/aapp/consts.ts now re-exports from libs/aapp/consts.ts (canonical source). Both files used to declare it independently with different values ('app' vs 'aapp'). 4. Replaced hardcoded `'[<alias>] ...'` literals in error messages with template strings using `<MOD>_MODULE`. Every error-message constant now derives the prefix from the module identifier instead of hardcoding it. Affected files: libs/aapp/consts.ts, arts/aapp/consts.ts, libs/buss/consts.ts, libs/lang/errors.ts, arts/stor/errors.ts, arts/sium/errors.ts, arts/fmts/errors.ts, and the ERROR_PREFIX constants in arts/conn, arts/sess, arts/http, arts/timr. 5. Updated diagnostic event values to use the new module aliases: - STOR_DIAGNOSTIC_EVENTS.ERROR: 'storage.error' → 'stor.error' - All FMTS_*_DIAGNOSTIC_EVENTS values to use 'fmts.X.*' 6. Updated tests that asserted against the old values (storage-integration.test and fmts/curr/test/barrel.test). 7. Updated docs/conventions.md: replaced the LOG_CATEGORY category with the new MODULE category. Added the rule that ERROR_MSG values must use the template `[${<MOD>_MODULE}]`, never a hardcoded literal. Verification: svelte-check 1395 / 0 errors. Server 1230 tests, client 19 tests — all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
| `ERROR_MSG` | Error message strings (technical, dev-facing). Must use a template referencing `<MOD>_MODULE` for the prefix, never a hardcoded literal: `` `[${MOD_MODULE}] ...` ``. |
Reorganize docs: move working/audit files to docs/ and add conventions Working documents and audits were spread across the project root, mixing with standard npm/GitHub files (README, CHANGELOG, CONTRIBUTING, SECURITY, BRAND). Moves them under docs/ for a clean root and adds docs/conventions.md as the canonical document for codebase-wide naming and structure rules. Files moved to docs/ (via git mv, history preserved): - audit-1-5.md (current ecosystem audit) - AUDIT_KIMI.md - AUDIT_OPENCODE.md - AUDIT_claude.md (historical audits from prior tools) - before_0_1.md (pre-0.1 release checklist) - buss.md (bus design doc, no longer live) - NEXT_STEPS.md (roadmap) Files staying in root (npm/GitHub convention): - README.md, CHANGELOG.md, CONTRIBUTING.md, SECURITY.md, BRAND.md References updated to point at docs/: - CHANGELOG.md (line 11) - README.md (line 105) - SECURITY.md (line 3) - src/web/routes/active/security/+page.svelte (line 46) docs/conventions.md captures three rules accepted as binding for the codebase: 1. Module identifier — every artifact and lib uses its 4-letter alias (BUSS, CONN, SESS, PERM, TIMR, LOGR, CACH, STOR, FMTS, FEND, ADOM, AAPP, AUTH, LANG, HTTP, SIUM, ERRS) for both string values and constant name prefixes. Drift from this rule (BUS_*, CONNECTION_*, SESSION_*, …) is being closed in the next audit pass. 2. Constant naming — `<MOD>_<CATEGORY>_<NAME>` strictly. No exceptions (no DEFAULT_TIMER_* style). 3. Category vocabulary — fixed list of category tokens (ERR, EVENT, DIAGNOSTIC_EVENTS, METHOD, STATE, STATUS, KIND, REASON, TYPE, MODE, DEFAULT, LIMIT, ID_PREFIX, LOG_CATEGORY, LOG_MSG, ERROR_MSG, ERROR_NAME, CONTEXT_KEY). Ad-hoc categories (AUTO_REAUTH, AUTO_INVALIDATE, BUFFER_POLICY, CHANNEL_STATE) fold into one of these. The document also formalizes the layer rules and ErrCode shape that will be implemented in upcoming commits. svelte-check 1395/0 errors. No code-side regressions; the moves are file-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
| `ERROR_NAME` | Legacy `Error.name` strings (being replaced by `ERR` codes) |
| `CONTEXT_KEY` | Svelte context keys |
Categories that are **not** in this list (e.g. `AUTO_REAUTH`,
`AUTO_INVALIDATE`, `BACKOFF`, `BUFFER_POLICY`, `CHANNEL_STATE`) must
fold into one of the above. Examples:
- `CONNECTION_AUTO_REAUTH_*` → `CONN_REASON_AUTO_REAUTH_*` if the value
drives a "why this happened" branch, or `CONN_MODE_AUTO_REAUTH_*` if
it configures behavior.
- `CACHE_AUTO_INVALIDATE_*` → `CACH_MODE_AUTO_INVALIDATE_*`.
- `CONN_BUFFER_POLICY_*` → `CONN_MODE_BUFFER_*`.
When in doubt, propose the addition here before introducing it.
---
## 4. Error codes (`ErrCode`) — special case under rule 2
Error codes from `$libs/errs` follow rule 2 with category `ERR`:
```ts
import { code, type ErrCode } from '$libs/errs';
export const BUSS_ERR: ErrCode = code('buss::base'); // family root
export const BUSS_ERR_DISPOSED: ErrCode = code('buss::disposed');
export const BUSS_ERR_INVALID_PAYLOAD: ErrCode = code('buss::invalid_payload');
export const BUSS_ERR_LISTENER: ErrCode = code('buss::listener'); // sub-family root
export const BUSS_ERR_LISTENER_FAILED: ErrCode = code('buss::listener.failed');
```
The string value's path segments mirror the constant's `<NAME>` part:
`BUSS_ERR_LISTENER_FAILED` ↔ `'buss::listener.failed'`.
The `::` separator inside the string distinguishes module from
hierarchy. The constant uses `_` as the syntactic separator (rule 2).
A helper `codeToLangPath(c)` converts `'buss::listener.failed'` →
`'buss.listener.failed'` for the i18n path.
---
## 5. String values inside diagnostic / event constants
Already enforced after audit section 2:
```ts
// good — value carries the module scope
export const CONN_DIAGNOSTIC_EVENTS = {
AUTH_FAILED: 'conn.auth_failed',
RECONNECT_EXHAUSTED: 'conn.reconnect_exhausted'
} as const;
// bad — bare value collides across modules
export const CONN_DIAGNOSTIC_EVENTS = {
AUTH_FAILED: 'auth_failed', // collides with auth.* events
LISTENER_THREW: 'listener_threw' // collides with sess and timr
} as const;
```
Rule: every string value emitted as an event identifier must start
with the module's 4-letter alias (rule 1) followed by `.` and the
value-specific path.
---
## 6. File and folder structure
| Layer | Rule |
|---|---|
| `libs/<mod>/` | Pure contracts: types, constants, error classes, helpers. No Svelte runes, no engine state. |
| `arts/<mod>/` | Runtime engine + `*.svelte.ts` active wrappers. May import from `$libs/<mod>` and from its own files. |
| `arts/<mod>/index.ts` | Public barrel. Re-exports the artifact's surface. |
| `arts/<mod>/test/` | Tests for engine and active wrappers. |
| `svrs/<mod>/` | Server-side counterparts (cookies, db adapters, route handlers). |
| `arts/aapp/` | Composition root. Allowed to import any `$<mod>`. |
**Cross-artifact imports are forbidden** (`arts/X` cannot import
`$Y`). Sole exception: `arts/aapp/`.
---
## 7. When this document is updated
- A new category in section 3 requires a record-of-decision: who, when,
why.
- Module aliases are frozen: a new artifact picks a 4-letter alias
not yet taken; renaming an existing alias is a breaking change.
- Drift found in the codebase that violates these rules is filed as an
audit finding and resolved in a dedicated commit.
Last updated: `2026-05-02` — initial version after audit-1-5.md
sections 1–2 closed.

Powered by TurnKey Linux.