feat(audit): declarative field-change activity via trackHistory (ADR-0052 §5b)#1948
Merged
Conversation
…0052 §5b) The activity writer already captures the field diff but renders a flat "Updated <object>" summary. Add a per-field `trackHistory` flag (spec) and wire the audit-writer to render tracked changes legibly — "Stage: Proposal → Closed Won" — using the field label and select option labels. Opt-in per field (cf. Salesforce Feed Tracking / ServiceNow field auditing / Dataverse column auditing). Reintroduces the pruned `auditTrail` concept WITH a runtime consumer, satisfying enforce-or-remove (ADR-0049). Apps can now DECLARE their timeline instead of hand-coding hooks/flows that insert sys_activity rows. - spec: trackHistory?: boolean on the field schema - plugin-audit: renderTrackedChangeSummary + getFieldDefs; update summary uses it, falling back to the generic text when no tracked field changed - tests: 2 new cases (renders label/option diff; falls back when untracked) - docs: ADR-0052 §5b "Declarative activity, not per-app code" Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 90 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
The liveness ratchet (ADR-0049) correctly flagged the new `trackHistory` field property as undeclared surface. It has a runtime consumer (plugin-audit audit-writers), so classify it `live` with evidence. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Platform-layer P0a from ADR-0052 §5b ("Declarative activity, not per-app code"). Lets apps declare their activity timeline instead of hand-coding hooks/flows that
insertsys_activityrows.The audit-writer already computes the field diff (
diff(before, after)→ stored in the activitymetadata) but renders a flat, useless"Updated crm_opportunity"summary. This adds a per-field opt-in flag and renders the diff it already has, legibly.trackHistory?: booleanon the field schema. Reintroduces the concept of the prunedauditTrailflag, but with a runtime consumer — satisfying enforce-or-remove (ADR-0049).audit-writers.ts): when a changed field declarestrackHistory: true, the activity summary becomes"Stage: Proposal → Closed Won"(field label + select option labels; multiple changes joined by;). Falls back to the generic"Updated <object>"when no tracked field changed — no behavior regression.Prior art
Same posture as Salesforce Feed Tracking / Field History Tracking, ServiceNow dictionary Audit + Activity Formatter, Dataverse per-column auditing + Timeline: declarative per-field opt-in → platform auto-generates the human-readable change entry; imperative code reserved for genuinely semantic events.
Verification
@objectstack/plugin-auditbuild (ESM+CJS+DTS) ✓, 16/16 tests pass (2 new: renders label/option diff; falls back when only untracked fields change).@objectstack/specbuild ✓.Why this matters
The hand-coded activity hooks/actions in hotcrm#396 are exactly what this declarative layer subsumes. Once this ships and HotCRM adopts it,
stage/status/prioritygettrackHistory: trueand theopportunityActivityHook(and most hand-coded activity) is deleted. Follow-on tiers (object-level milestone templates; event-bus projection for email/call/meeting) are specified in ADR-0052 §5b.2–3.🤖 Generated with Claude Code