Skip to content

Commit bb66231

Browse files
os-zhuangclaude
andauthored
refactor(audit): move sys_attachment ownership audit → storage (ADR-0052 P0b) (#1954)
A file↔record link belongs with the storage domain, not the compliance ledger. `plugin-audit` stops registering `sys_attachment`; `service-storage` now contributes it (definition stays in platform-objects). Both plugins are always-on, so the object stays available — no behavior change. Audit sheds one of its dumping-ground objects, moving toward a pure append-only ledger. `sys_notification` is intentionally NOT moved: it is mid-migration to an event model (migrate-sys-notification-to-event.ts, ADR-0030) and touching it now would collide with that in-flight work. - plugin-audit: drop SysAttachment from registered objects + import - service-storage: depend on platform-objects, import + register SysAttachment - ADR-0052 §6 P0b updated (sys_attachment done; sys_notification deferred) Verified in the showcase: sys_attachment still resolves (meta + data 200), no double-registration; plugin-audit 18/18 + service-storage 48/48 tests pass. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7505274 commit bb66231

5 files changed

Lines changed: 23 additions & 12 deletions

File tree

docs/adr/0052-audit-is-not-the-activity-feed.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,13 @@ rather than written twice.
281281
human-readable summaries. Smallest change, biggest daily payoff, no migration —
282282
it only improves the *render* of rows the writer already emits. **This ADR
283283
ships P0a.**
284-
- **P0b — ownership, no behavior change.** Move `sys_attachment` → storage,
285-
`sys_notification` → messaging (code already concedes these). Make
286-
"collaboration/activity is a platform primitive" an explicit capability rather
287-
than an audit side-effect; keep it default-available so no UI regresses.
284+
- **P0b — ownership, no behavior change.**`sys_attachment` registration moved
285+
`plugin-audit``service-storage` (both always-on, so it stays available; the
286+
definition stays in `platform-objects`). `sys_notification` is **deferred** — it
287+
is mid-migration to an event model (`metadata/.../migrate-sys-notification-to-event.ts`,
288+
ADR-0030), so moving it now would collide with that in-flight work. Still TODO:
289+
make "collaboration/activity is a platform primitive" an explicit capability
290+
rather than an audit side-effect; keep it default-available so no UI regresses.
288291
- **P1 — kill the split-brain + milestone templates (§5b.2).** Choose the
289292
canonical collaboration backend (§5), migrate/alias `sys_comment`, repoint
290293
ChatterPanel, surface reactions/threads. Add declarative object-level milestone

packages/plugins/plugin-audit/src/audit-plugin.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import type { Plugin, PluginContext } from '@objectstack/core';
44
import type { IDataEngine } from '@objectstack/spec/contracts';
55
import { SysAuditLog, SysActivity, SysComment } from './objects/index.js';
6-
// Registered here but still owned by platform-objects (the plugin contributes
7-
// them to the kernel without owning the definition yet):
8-
// - sys_notification — reworked by ADR-0030 messaging (notification→event).
9-
// - sys_attachment — a file↔record link belonging with service-storage's
10-
// sys_file; moves in the storage-domain decomposition, not this audit move.
11-
import { SysNotification, SysAttachment } from '@objectstack/platform-objects/audit';
6+
// `sys_notification` is contributed here but owned by platform-objects; it is
7+
// being reworked by ADR-0030 messaging (notification→event), so it stays put
8+
// until that migration lands. `sys_attachment` moved to @objectstack/service-
9+
// storage (ADR-0052 §3 ownership: a file↔record link belongs with storage, not
10+
// the compliance ledger).
11+
import { SysNotification } from '@objectstack/platform-objects/audit';
1212
import { installAuditWriters, type MessagingEmitSurface } from './audit-writers.js';
1313

1414
/**
@@ -37,7 +37,7 @@ export class AuditPlugin implements Plugin {
3737
scope: 'system',
3838
defaultDatasource: 'cloud',
3939
namespace: 'sys',
40-
objects: [SysAuditLog, SysActivity, SysComment, SysAttachment, SysNotification],
40+
objects: [SysAuditLog, SysActivity, SysComment, SysNotification],
4141
// ADR-0029 D7 — contribute the Audit Logs entry into the Setup app's
4242
// `group_diagnostics` slot. The plugin owns sys_audit_log (K2).
4343
navigationContributions: [

packages/services/service-storage/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"dependencies": {
2121
"@objectstack/core": "workspace:*",
2222
"@objectstack/observability": "workspace:*",
23+
"@objectstack/platform-objects": "workspace:*",
2324
"@objectstack/spec": "workspace:*"
2425
},
2526
"peerDependencies": {

packages/services/service-storage/src/storage-service-plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import type { S3StorageAdapterOptions } from './s3-storage-adapter.js';
1414
import { StorageMetadataStore } from './metadata-store.js';
1515
import { registerStorageRoutes } from './storage-routes.js';
1616
import { SystemFile, SystemUploadSession } from './objects/index.js';
17+
// ADR-0052 §3 ownership: `sys_attachment` (a file↔record link) belongs with the
18+
// storage domain, not the audit/compliance ledger. Definition stays in
19+
// platform-objects; storage now contributes (registers) it instead of audit.
20+
import { SysAttachment } from '@objectstack/platform-objects/audit';
1721
import { SwappableStorageService } from './swappable-storage-service.js';
1822

1923
/**
@@ -170,7 +174,7 @@ export class StorageServicePlugin implements Plugin {
170174
version: '1.0.0',
171175
type: 'plugin',
172176
scope: 'system',
173-
objects: [SystemFile, SystemUploadSession],
177+
objects: [SystemFile, SystemUploadSession, SysAttachment],
174178
});
175179
} catch {
176180
// manifest service may not be available in all environments

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)