Skip to content

Commit 58752fe

Browse files
committed
Revise and condense server specification docs
Major rewrite and condensation of ObjectOS server specification documentation. Simplifies and shortens content for audit-compliance, automation rules, integration/ETL, permission governance, plugin manifest, and workflow engine. Removes the overview (index.mdx), adds a new kernel-architecture page, and updates meta.json navigation. Focuses on protocol summaries, configuration patterns, and key concepts for each subsystem.
1 parent 9d8ffe0 commit 58752fe

9 files changed

Lines changed: 147 additions & 1090 deletions

File tree

Lines changed: 15 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,23 @@
11
---
22
title: Audit & Compliance
3-
description: The Protocol for Accountability. Field History Tracking, System Audit Trails, and Data Retention Policies.
3+
description: The Protocol for Accountability and Forensic Logging.
44
---
55

6+
For enterprise software, "Who did what and when" is non-negotiable.
67

7-
In the enterprise world, "Who changed this?" is the most expensive question to leave unanswered.
8+
## 1. Field History Tracking
9+
Configured per-field in the Object Schema.
10+
* **Track Old/New:** Records the previous and new value.
11+
* **Retention:** Definitions for how long to keep history (e.g., "10 Years").
812

9-
ObjectOS treats **Auditability** as a first-class citizen. Unlike frameworks where you have to manually write logs in your controllers, ObjectOS implements **Kernel-Level Auditing**. If a mutation passes through the ObjectOS engine, it *will* be logged, regardless of whether it came from the UI, the API, or a background job.
13+
## 2. Setup Audit Trail
14+
Logs all changes to **Metadata** (Schema).
15+
* "User A changed the validation rule on Project."
16+
* "User B deleted the 'Salary' field."
1017

11-
## 1. Data History Tracking (Field-Level)
18+
## 3. Login History
19+
Logs every authentication attempt.
20+
* **Context:** IP Address, Browser, Location, Status (Success/Fail).
1221

13-
This mechanism tracks value changes within business records. It answers: *"Did the Deal Amount change from $10k to $5k, and who did it?"*
14-
15-
### Configuration (Declarative)
16-
You do not need to write code to enable this. You simply flag the object or specific fields in the Schema.
17-
18-
```yaml
19-
# objects/deal.object.yml
20-
name: deal
21-
label: Sales Deal
22-
enable_audit: true # Master switch
23-
24-
fields:
25-
name:
26-
type: text
27-
28-
amount:
29-
type: currency
30-
track_history: true # Track changes to this specific field
31-
32-
stage:
33-
type: select
34-
track_history: true
35-
36-
description:
37-
type: textarea
38-
track_history: false # Do not track large text blobs (save space)
39-
40-
```
41-
42-
### The History Protocol
43-
44-
When a transaction commits, the Audit Engine calculates the **Delta** and writes to the `object_history` storage.
45-
46-
```json
47-
{
48-
"event_id": "evt_001",
49-
"timestamp": "2026-01-20T10:00:00Z",
50-
"actor": "user_123",
51-
"ip_address": "192.168.1.1",
52-
"object": "deal",
53-
"record_id": "deal_abc",
54-
"changes": [
55-
{
56-
"field": "amount",
57-
"old_value": 10000,
58-
"new_value": 5000
59-
},
60-
{
61-
"field": "stage",
62-
"old_value": "negotiation",
63-
"new_value": "closed_won"
64-
}
65-
]
66-
}
67-
68-
```
69-
70-
## 2. Setup Audit Trail (Metadata-Level)
71-
72-
Beyond data, you must track changes to the **System Configuration**. This prevents "Shadow IT" modifications where an admin silently lowers security settings.
73-
74-
ObjectOS automatically logs operations on:
75-
76-
* **Schema:** Creating/Deleting Objects or Fields.
77-
* **Security:** Changing Permission Sets or Sharing Rules.
78-
* **Logic:** Modifying Workflows or Triggers.
79-
* **Users:** Password resets, Role assignments.
80-
81-
### Example Log Entry
82-
83-
> **User:** Alice (Admin)
84-
> **Action:** Permission Profile Update
85-
> **Target:** Sales Rep Profile
86-
> **Change:** `lead.export_permission` changed from `false` to `true`.
87-
88-
## 3. Login & Access Logs
89-
90-
For security compliance, access events are tracked separately.
91-
92-
* **Login Success/Failure:** Tracks Timestamp, User, IP, User-Agent, and Auth Method (Password vs. SSO).
93-
* **API Access:** (Optional) Can be configured to log every API call for high-security environments (Warning: High Volume).
94-
95-
## 4. Storage & Retention Policies
96-
97-
Audit logs grow rapidly. ObjectOS provides a **Retention Protocol** to manage lifecycle cost-effectively.
98-
99-
### Architecture
100-
101-
Audit data is **never** stored in the same table as the transactional data.
102-
103-
* **Hot Storage (Last 30 days):** Stored in the primary SQL DB for instant UI access.
104-
* **Cold Storage (Archive):** Offloaded to low-cost object storage (S3/Parquet) or a dedicated Log Service (Elasticsearch/Splunk).
105-
106-
### Policy Configuration
107-
108-
```yaml
109-
# config/audit_retention.yml
110-
policies:
111-
- object: deal
112-
retention_period: 3650 # 10 Years (Financial Regulation)
113-
archive_after: 90 # Move to Cold Storage after 90 days
114-
115-
- object: task
116-
retention_period: 180 # 6 Months
117-
purge_after: 180 # Hard delete
118-
119-
```
120-
121-
## 5. Compliance Features (GDPR/HIPAA)
122-
123-
### The "Right to be Forgotten" (GDPR)
124-
125-
When a user requests deletion, ObjectOS provides a `System.anonymize` utility.
126-
127-
* It scrubs PII (Personally Identifiable Information) from the `users` table.
128-
* **Critical:** It does *not* delete the Audit Log rows (for legal integrity), but it masks the `actor` ID or replaces the name with "Anonymized User", ensuring historical integrity while respecting privacy.
129-
130-
### Immutability
131-
132-
The Audit Engine is designed to be **Append-Only**.
133-
134-
* The API does not expose `UPDATE` or `DELETE` endpoints for the `audit_log` object.
135-
* Even System Admins cannot delete audit trails via the standard UI/API (requires direct database access, leaving its own trace).
136-
137-
## 6. Snapshotting (Time Travel)
138-
139-
For advanced scenarios, ObjectOS supports **Full Document Snapshotting**. Instead of storing diffs, it stores the entire JSON version of the record at every save.
140-
141-
* **Use Case:** Legal Contracts or Medical Records where you need to "View Record exactly as it looked on Jan 1st, 2024".
142-
* **Config:** `enable_versioning: true`.
143-
144-
## Summary
145-
146-
ObjectOS Audit Protocol ensures that your application is "Enterprise Ready" out of the box.
147-
148-
1. **Zero Code:** Just add `track_history: true`.
149-
2. **Granular:** Tracks specific fields, not just "Modified Date".
150-
3. **Governance:** Tracks the Admins (Setup Audit Trail).
151-
4. **Lifecycle:** Automates archiving and purging to manage database growth.
22+
## 4. System Log
23+
Debug logs for developers (Triggers, Flows).
Lines changed: 17 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,164 +1,31 @@
11
---
22
title: Automation Rules
3-
description: The Protocol for Server-Side Logic. Database Triggers, Scheduled Jobs, and No-Code Automation Flows.
3+
description: The Protocol for Lightweight, Event-Driven Logic.
44
---
55

6+
Automation Rules differ from Workflows in that they are typically strictly **Event-Driven** and stateless.
67

7-
While Workflows guide a record through a lifecycle, **Automation Rules** handle the immediate logic and side effects of data changes.
8-
9-
ObjectOS divides automation into three categories:
10-
1. **Triggers (Code):** High-performance, synchronous TypeScript hooks for data integrity.
11-
2. **Flows (Low-Code):** Declarative, asynchronous event chains (IFTTT style).
12-
3. **Scheduled Jobs:** Time-based execution (CRON).
13-
14-
## 1. Database Triggers (Synchronous Logic)
15-
16-
Triggers are the "Reflexes" of the system. They intercept database operations **before** or **after** they happen. They execute within the same database transaction as the mutation.
17-
18-
### Trigger Definition
19-
20-
Triggers are defined in TypeScript files next to your Object definitions.
8+
## 1. Triggers (Code)
9+
Server-side scripts (TypeScript/Python) that run in the transaction transaction.
2110

2211
```typescript
23-
// triggers/order.trigger.ts
24-
import { Trigger } from '@objectos/types';
25-
26-
export const validateDiscount: Trigger = {
27-
name: 'validate_order_discount',
28-
object: 'order',
29-
on: ['create', 'update'],
30-
when: 'before', // Runs before writing to DB
31-
32-
handler: async ({ doc, previousDoc, session, broker }) => {
33-
// 1. Logic: Discount cannot exceed 20% unless authorized
34-
if (doc.discount > 0.20 && !session.hasRole('manager')) {
35-
throw new Error("Discounts > 20% require Manager approval.");
12+
// project.trigger.ts
13+
export const beforeInsert = async (ctx) => {
14+
if (ctx.doc.amount > 10000) {
15+
ctx.doc.status = 'High Value';
3616
}
37-
38-
// 2. Logic: Auto-calculate final price
39-
doc.final_price = doc.list_price * (1 - doc.discount);
40-
}
4117
}
42-
4318
```
4419

45-
### Key Capabilities
46-
47-
* **Validation:** Throwing an error aborts the entire transaction.
48-
* **Computation:** Modifying `doc` directly updates the data being saved.
49-
* **Snapshot Access:** You have access to `doc` (new state) and `previousDoc` (old state) to detect changes (e.g., `if (doc.status !== previousDoc.status)`).
50-
51-
## 2. Automation Flows (Declarative Logic)
52-
53-
For logic that doesn't require hard coding, ObjectOS supports **Automation Flows**. These are defined in YAML (or built via a Visual Builder) and run **asynchronously** after the transaction commits.
54-
55-
### The Flow Protocol
56-
57-
```yaml
58-
# automations/notify_high_value_deal.yaml
59-
name: notify_high_value_deal
60-
label: Notify VP on Big Deals
61-
trigger:
62-
type: data.changed
63-
object: deal
64-
condition: "doc.amount > 1000000 && doc.stage == 'closed_won'"
65-
66-
actions:
67-
- type: notification.send
68-
params:
69-
recipient: "role:vp_sales"
70-
subject: "Big Win: ${doc.name}"
71-
message: "Deal closed for ${formatCurrency(doc.amount)}!"
72-
73-
- type: record.create
74-
params:
75-
object: "audit_log"
76-
data:
77-
event: "big_deal_alert"
78-
deal_id: "${doc._id}"
79-
80-
```
81-
82-
### Flow Components
83-
84-
* **Trigger:** What starts the flow? (`data.changed`, `user.login`, `webhook.received`).
85-
* **Condition:** A logical expression (Expression Language) that must be true.
86-
* **Actions:** A sequential list of tasks (Send Email, Call API, Create Record).
87-
88-
## 3. Scheduled Jobs (CRON)
89-
90-
Enterprise systems need to do things when no one is watching. ObjectOS includes a distributed **Job Scheduler**.
91-
92-
### Protocol Definition
93-
94-
```yaml
95-
# jobs/monthly_invoicing.job.yml
96-
name: generate_monthly_invoices
97-
cron: "0 0 1 * *" # Run at midnight on the 1st of every month
98-
timeout: 3600 # 1 hour max
99-
retries: 3
100-
101-
task:
102-
action: "finance.batch_generate_invoices"
103-
params:
104-
period: "last_month"
105-
106-
```
107-
108-
* **Distributed:** In a cluster, the OS ensures the job runs on only **one** node (via Redis locks).
109-
* **Resilient:** Failed jobs are automatically retried based on the policy.
110-
111-
## 4. Server-Side Scripting API
112-
113-
Whether writing Triggers or Custom Actions, you interact with the ObjectOS Kernel via the standard **Broker API**. This ensures your code is safe and upgrade-proof.
114-
115-
### The Broker Object
116-
117-
The `broker` is your gateway to the rest of the OS.
118-
119-
```typescript
120-
// Inside a Trigger or Service
121-
async function handler({ broker, session }) {
122-
123-
// 1. Data Access (Respects Permissions)
124-
const user = await broker.call('data.find', {
125-
object: 'user',
126-
id: 'u1'
127-
}, { session });
128-
129-
// 2. Cross-Service Calls
130-
await broker.call('mail.send', { ... });
131-
132-
// 3. Emit Custom Events
133-
broker.emit('custom.event', { foo: 'bar' });
134-
}
135-
136-
```
137-
138-
### The "Sudo" Mode
139-
140-
Sometimes you need to bypass permissions (e.g., a system background job).
141-
142-
```typescript
143-
// Create a System Session (Super Admin)
144-
const sudoSession = session.sudo();
145-
146-
await broker.call('data.update', { ... }, { session: sudoSession });
147-
148-
```
20+
## 2. Validation Rules (No-Code)
21+
Boolean expressions that block a save if they return `true`.
22+
Defined in the Object Schema (`validation` property).
14923

150-
## 5. Comparison: Trigger vs. Flow vs. Workflow
24+
## 3. Auto-Response Rules
25+
Logic for sending immediate email replies (e.g., "Thanks for your Ticket").
15126

152-
| Feature | Database Trigger | Automation Flow | Workflow (BPM) |
153-
| --- | --- | --- | --- |
154-
| **Protocol** | TypeScript | YAML / JSON | YAML / BPMN |
155-
| **Timing** | Synchronous (Blocking) | Asynchronous (Background) | Long-Running (Days/Weeks) |
156-
| **Transactional** | Yes (Can Rollback) | No (Committed) | No |
157-
| **Use Case** | Data Integrity, Calculations | Notifications, Sync | Approvals, Lifecycle |
158-
| **Complexity** | High (Code) | Low (Config) | Medium (State Machine) |
27+
## 4. Assignment Rules
28+
Logic for changing the `owner` of a record (e.g., "Round Robin" assignment for Leads).
15929

160-
:::tip Best Practice
161-
Always prefer **Triggers** for data integrity (e.g., "Price cannot be negative").
162-
Always prefer **Workflows** for human processes (e.g., "Manager must approve").
163-
Use **Flows** for everything in between (e.g., "Send email on update").
164-
:::
30+
## 5. Escalation Rules
31+
Logic for time-based updates (e.g., "If Case not solved in 4h, notify Manager").

0 commit comments

Comments
 (0)