Skip to content

Commit 57112f7

Browse files
committed
docs: split playbookitem explanation and add pseudocode
1 parent 6978486 commit 57112f7

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,30 @@ Playbook {
430430

431431
**Purpose**: A single append-only event that creates, refines, or deprecates a logical playbook entry.
432432

433-
PlaybookItems are modeled as an append-only event log so tools can evolve guidance without rewriting history: changes become auditable, mergeable, and safe under concurrent edits. Each PlaybookItem is an immutable event in the log (once written, it is never edited or deleted; changes are represented by appending a new event). Events with the same `targetId` form a single logical “thread” (one playbook entry evolving over time), where each event captures a state change or refinement. When a tool updates or deprecates an entry, it appends a new event (with a new `eventId`) that references the same thread via `targetId`, and points to the most recent prior event in that thread via `prevEventId`—creating a verifiable chain and enabling conflict detection if two updates fork from the same predecessor. Consumers can reconstruct the “latest state” per `targetId` by following the thread. `eventId` uniquely identifies the event itself; `targetId` identifies the evolving entry.
433+
PlaybookItems are modeled as an append-only event log so tools can evolve guidance without rewriting history: changes become auditable, mergeable, and safe under concurrent edits. Each PlaybookItem is an immutable event in the log (once written, it is never edited or deleted; changes are represented by appending a new event).
434+
435+
Events with the same `targetId` form a single logical “thread” (one playbook entry evolving over time). Each update appends a new event (with a new `eventId`) that references the thread via `targetId`, and points to the most recent prior event in that thread via `prevEventId`—creating a verifiable chain and enabling conflict detection if two updates fork from the same predecessor. Consumers can reconstruct the “latest state” per `targetId` by following the thread.
436+
437+
```javascript
438+
// Pseudocode: append a new event to an existing thread
439+
function appendPlaybookEvent(playbook, targetId, patch) {
440+
const prev = findLatestEventForTarget(playbook.items, targetId);
441+
442+
const evt = {
443+
eventId: newEventId(),
444+
targetId: targetId,
445+
operation: "update",
446+
prevEventId: prev.eventId,
447+
createdAt: nowRFC3339(),
448+
...patch
449+
};
450+
451+
playbook.items.push(evt);
452+
playbook.updated = evt.createdAt;
453+
}
454+
```
455+
456+
`eventId` uniquely identifies the event itself; `targetId` identifies the evolving entry.
434457

435458
**Required fields (by operation)**:
436459

0 commit comments

Comments
 (0)