Skip to content

Commit 382e9c6

Browse files
Copilothotlong
andcommitted
docs: update CHANGELOG.md and ROADMAP.md for system object architecture unification
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 798cccc commit 382e9c6

2 files changed

Lines changed: 58 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- **ObjectSchema `namespace` property** — New optional `namespace` field on `ObjectSchema` for logical domain
12+
classification (e.g., `'sys'`, `'crm'`). When set, `tableName` is auto-derived as `{namespace}_{name}` by
13+
`ObjectSchema.create()` unless an explicit `tableName` is provided. This decouples the logical object name
14+
from the physical table name and enables unified routing, permissions, and discovery by domain.
15+
- **SystemObjectName constants** — Extended with all system objects: `ORGANIZATION`, `MEMBER`, `INVITATION`,
16+
`API_KEY`, `TWO_FACTOR`, `ROLE`, `PERMISSION_SET`, `AUDIT_LOG` (in addition to existing `USER`, `SESSION`,
17+
`ACCOUNT`, `VERIFICATION`, `METADATA`).
18+
- **plugin-auth system objects** — Added `SysOrganization`, `SysMember`, `SysInvitation`, `SysApiKey`,
19+
`SysTwoFactor` object definitions with `namespace: 'sys'`. Existing objects (`SysUser`, `SysSession`,
20+
`SysAccount`, `SysVerification`) migrated to use namespace convention.
21+
- **plugin-security system objects** — Added `SysRole` and `SysPermissionSet` object definitions.
22+
- **plugin-audit** — New plugin package with `SysAuditLog` immutable audit trail object definition.
23+
- **StorageNameMapping.resolveTableName()** — Now supports namespace-aware auto-derivation
24+
(`{namespace}_{name}` fallback when no explicit `tableName` is set).
25+
26+
### Changed
27+
- **System object naming convention** — All system objects now use `namespace: 'sys'` with short `name`
28+
(e.g., `name: 'user'` instead of `name: 'sys_user'`). The `sys_` prefix is auto-derived via
29+
`tableName` = `{namespace}_{name}`. File naming follows `sys-{name}.object.ts` pattern.
30+
- **plugin-auth object exports** — New canonical exports use `Sys*` prefix (e.g., `SysUser`, `SysSession`).
31+
Legacy `Auth*` exports are preserved as deprecated re-exports for backward compatibility.
32+
- **sys_metadata object** — Migrated to `namespace: 'sys'`, `name: 'metadata'` convention (tableName
33+
auto-derived as `sys_metadata`).
34+
1035
### Changed
1136
- **i18n route self-registration** — Moved i18n REST endpoint registration from `RestServer` to
1237
`I18nServicePlugin` (and kernel fallback). The i18n plugin now self-registers `/api/v1/i18n/*`

ROADMAP.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -307,24 +307,48 @@ The following renames are planned for packages that implement core service contr
307307
### System Object Naming Convention (`sys_` Prefix)
308308

309309
> **Adopted:** 2026-02-19
310+
> **Updated:** 2026-03-11 — Namespace-based architecture with auto-derivation
310311
> **Scope:** All system kernel objects in `SystemObjectName` constants.
311312
312-
All system kernel objects use the `sys_` prefix to clearly distinguish platform-internal objects from
313+
All system kernel objects use the `sys` namespace to clearly distinguish platform-internal objects from
313314
business/custom objects, aligning with industry best practices (e.g., ServiceNow `sys_user`, `sys_audit`).
314315

315-
| Constant Key | Protocol Name | Description |
316-
|:---|:---|:---|
317-
| `SystemObjectName.USER` | `sys_user` | Authentication: user identity |
318-
| `SystemObjectName.SESSION` | `sys_session` | Authentication: active session |
319-
| `SystemObjectName.ACCOUNT` | `sys_account` | Authentication: OAuth / credential account |
320-
| `SystemObjectName.VERIFICATION` | `sys_verification` | Authentication: email / phone verification |
321-
| `SystemObjectName.METADATA` | `sys_metadata` | System metadata storage |
316+
Objects now declare `namespace: 'sys'` and a short `name` (e.g., `name: 'user'`). The physical table name
317+
`sys_user` is auto-derived as `{namespace}_{name}` by `ObjectSchema.create()`.
318+
319+
| Constant Key | Protocol Name | Plugin | Description |
320+
|:---|:---|:---|:---|
321+
| `SystemObjectName.USER` | `sys_user` | plugin-auth | Authentication: user identity |
322+
| `SystemObjectName.SESSION` | `sys_session` | plugin-auth | Authentication: active session |
323+
| `SystemObjectName.ACCOUNT` | `sys_account` | plugin-auth | Authentication: OAuth / credential account |
324+
| `SystemObjectName.VERIFICATION` | `sys_verification` | plugin-auth | Authentication: email / phone verification |
325+
| `SystemObjectName.ORGANIZATION` | `sys_organization` | plugin-auth | Authentication: organization (multi-org) |
326+
| `SystemObjectName.MEMBER` | `sys_member` | plugin-auth | Authentication: organization member |
327+
| `SystemObjectName.INVITATION` | `sys_invitation` | plugin-auth | Authentication: organization invitation |
328+
| `SystemObjectName.API_KEY` | `sys_api_key` | plugin-auth | Authentication: API key for programmatic access |
329+
| `SystemObjectName.TWO_FACTOR` | `sys_two_factor` | plugin-auth | Authentication: two-factor credentials |
330+
| `SystemObjectName.ROLE` | `sys_role` | plugin-security | Security: RBAC role definition |
331+
| `SystemObjectName.PERMISSION_SET` | `sys_permission_set` | plugin-security | Security: permission set grouping |
332+
| `SystemObjectName.AUDIT_LOG` | `sys_audit_log` | plugin-audit | Audit: immutable audit trail |
333+
| `SystemObjectName.METADATA` | `sys_metadata` | metadata | System metadata storage |
334+
335+
**Object Definition Convention:**
336+
- File naming: `sys-{name}.object.ts` (e.g., `sys-user.object.ts`, `sys-role.object.ts`)
337+
- Export naming: `Sys{PascalCase}` (e.g., `SysUser`, `SysRole`, `SysAuditLog`)
338+
- Object schema: `namespace: 'sys'`, `name: '{short_name}'` (no `sys_` prefix in name)
339+
- Table derivation: `tableName` auto-derived as `sys_{name}` unless explicitly overridden
322340

323341
**Rationale:**
324342
- Prevents naming collisions between system objects and business objects (e.g., a CRM `account` vs. `sys_account`)
325343
- Aligns with ServiceNow and similar platforms that use `sys_` as a reserved namespace
326344
- ObjectStack already uses namespace + FQN for business object isolation; the `sys_` prefix completes the picture for kernel-level objects
327345
- Physical storage table names can differ via `ObjectSchema.tableName` + `StorageNameMapping.resolveTableName()` for backward compatibility
346+
- Namespace-based auto-derivation eliminates manual `tableName` boilerplate and ensures consistency
347+
348+
**Plugin Architecture:**
349+
- Each plugin (plugin-auth, plugin-security, plugin-audit) owns and registers its own `sys` namespace objects
350+
- Plugins remain decoupled and optional — consumers aggregate all `sys` objects at runtime
351+
- Object definitions follow the ObjectSchema protocol with `isSystem: true`
328352

329353
**Migration (v3.x → v4.0):**
330354
- v3.x: The `SystemObjectName` constants now emit `sys_`-prefixed names. Implementations using `StorageNameMapping.resolveTableName()` can set `tableName` to preserve legacy physical table names during the transition.
@@ -333,7 +357,7 @@ business/custom objects, aligning with industry best practices (e.g., ServiceNow
333357
- v3.x: **Bug fix**`AuthManager.createDatabaseConfig()` now wraps the ObjectQL adapter as a `DBAdapterInstance` factory function (`(options) => DBAdapter`). Previously the raw adapter object was passed, which fell through to the Kysely adapter path and failed silently. `AuthManager.handleRequest()` and `AuthPlugin.registerAuthRoutes()` now inspect `response.status >= 500` and log the error body, since better-auth catches internal errors and returns 500 Responses without throwing.
334358
- v3.x: **Bug fix**`AuthPlugin` now defers HTTP route registration to a `kernel:ready` hook instead of doing it synchronously in `start()`. This makes the plugin resilient to plugin loading order — the `http-server` service is guaranteed to be available after all plugins complete their init/start phases. The CLI `serve` command also registers `HonoServerPlugin` before config plugins (with duplicate detection) for the same reason.
335359
- v3.x: **Bug fix** — Studio `useApiDiscovery` hook no longer hardcodes auth endpoints as `/api/auth/...`. The `discover()` callback now fetches `/api/v1/discovery` and reads `routes.auth` to dynamically construct auth endpoint paths (falling back to `/api/v1/auth`). The session endpoint is corrected from `/session` to `/get-session` to align with better-auth's `AuthEndpointPaths.getSession`.
336-
- v4.0: Legacy un-prefixed aliases will be fully removed.
360+
- v4.0: Legacy un-prefixed aliases and `Auth*` export names will be fully removed.
337361

338362
---
339363

0 commit comments

Comments
 (0)