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>
Phase 2 of the convention pass documented in docs/conventions.md.
Aligns every module-level constant's prefix with the bundler alias
that already identifies the artifact (rule 1 of the convention):
- BUS_* → BUSS_* (libs/buss + arts/buss)
- CONNECTION_* → CONN_* (arts/conn + web consumers)
- SESSION_* → SESS_* (arts/sess + libs/aapp + consumers)
- PERMISSION_* → PERM_* (arts/perm, libs/perm, svrs/perm)
- TIMER_* → TIMR_* (arts/timr + libs/timers)
- CACHE_* → CACH_* (arts/cach + libs/cach + svrs/cach)
- STORAGE_* → STOR_* (arts/stor + consumers)
Mechanical sed pass with `\b<OLD>_` word-boundary anchor — this only
matches at identifier start, never inside (e.g. AAPP_BUS_CONTEXT_KEY
stays untouched because the boundary requirement is between non-word
and word characters).
Out of scope and deferred to phase 2B (per-module decisions, not
bulk-applicable):
- LOGGER_CATEGORY constants in each module's consts.ts must become
the module's own LOG_CATEGORY (BUSS_LOG_CATEGORY = 'buss',
CONN_LOG_CATEGORY = 'conn', etc.) — different rename per module,
not a single sed pattern.
- APP_* → AAPP_* (arts/aapp uses APP_ today; libs/aapp already
uses AAPP_).
- Ad-hoc constants without module prefix (DEFAULT_TIMER_*,
EVENT_*, BROWSER_*, IDENTITY_*, ACTOR_*, REVOKE_SCOPE_*, etc. in
arts/sess/consts.ts; AUTO_REAUTH_* in arts/conn).
Note on web/ files:
- src/web/routes/active/get-started/ai-agents/+page.svelte
- src/web/routes/temp/c2/+page.svelte
- src/web/routes/temp/c2/Curtain.svelte
These three files contain pre-existing user modifications (work in
progress unrelated to this rename) that the bulk sed touched on top
because they referenced renamed identifiers. Excluding them would
break compilation. Their content here is the intersection of both
changes; the user's prior edits to these files are intentionally
bundled in this commit.
Verification: svelte-check 1395 files / 0 errors. Server 1230 tests,
client 19 tests — all green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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>
audit-1-5.md section 2: 46 values were emitted as bare strings
(`'auth_failed'`, `'listener_threw'`, `'check'`) and collided across
artifacts in any aggregated log stream. Each value now carries its
module prefix so the type is self-describing in isolation and never
clashes with another emitter.
- arts/conn/consts.ts (CONNECTION_DIAGNOSTIC_EVENTS) — 15 values → conn.*
- arts/sess/consts.ts (SESSION_DIAGNOSTIC_EVENTS) — 15 values → sess.*
- arts/perm/consts.ts (PERMISSION_CLIENT_DIAGNOSTIC_EVENTS) — 3 → perm.client.*
- svrs/perm/consts.ts (PERMISSION_DIAGNOSTIC_EVENTS) — 3 → perm.server.*
- svrs/perm/consts.ts (PERMISSION_METHOD_*) — 7 → perm.* (aligns with
the client-side counterpart in arts/perm/consts.ts which already used
this scoping)
- libs/timers/consts.ts (TIMER_DIAGNOSTIC_EVENTS) — 3 values → timr.*
The rule was already documented in arts/perm/consts.ts ("scoped with
the artifact prefix `perm.` so that aggregated diagnostic streams do
not collide"); these six files were the modules that hadn't been
brought into compliance.
Real collisions resolved today: `'listener_threw'` (3 emitters: conn
+ sess + timr), `'session_revoked'` and `'session_expired'` (conn
bridge + sess lifecycle).
Consumers reference the constants by symbol (`CONNECTION_DIAGNOSTIC_EVENTS.AUTH_FAILED`,
not `'auth_failed'`), so this is a transparent rename. 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>
Layer-boundary cleanup (audit-1-5.md section 1):
- fend → adom: move apply.ts to libs/dom; FrontendDom is now DomApplier;
fend falls back to bare applyChange instead of constructing ActiveDom
- sium → lang: full split — pure code (consts, types, guards, helpers,
errors, json, plural, plural_rules, diagnostics) moves to libs/lang;
arts/lang keeps engine + active wrappers and re-exports for back-compat
- conn → timr: minimum split — types and public constants move to
libs/timers; conn imports types from $libs/timers; EngineConnectionsOptions.timers
is now required (no more silent createEngineTimers fallback). Tests
updated to construct shared timers per beforeEach
Bus contract finishing touches (continued from prior session):
- subscribe() returns the unsubscribe function directly
- publishCausedBy() propagates correlationId/causationId
- invokeListener hook + Svelte adapter wraps listeners in untrack
- maxReentrancyDepth guard with BusReentrancyLimitError (fatal — bypasses
listener-error trap)
- DEV-mode structuredClone payload check raising BusInvalidPayloadError
- BusListenerFailure carries envelopeId/correlationId/causationId
- createBusRecent active wrapper, bus-context.svelte.ts, APP_EVENT_RUNTIMES
table with assertEventCanFire wired into every publishApp* helper
- App switches to createSvelteEngineBus
audit-1-5.md captures the full ecosystem audit (5 axes); section 1 is
now closed by these changes. Sections 2-5 remain open.
Verification: svelte-check 1395/0 errors; server 1230 tests passed;
client 19 tests passed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>