Four tools, one for each moment of a change. Each feeds the next, and production feeds the plan.
Plan
@newt-js/plan
The change, agreed before a line is written.
Framework
@newt-js/core
Opinionated DDD, batteries included. The lint holds the shape.
Review
@newt-js/review
The branch, drawn against its plan.
Monitor
@newt-js/monitor
Production, in the domain’s own words.
↺What production shows becomes the next plan
@newt-js/plan
First, the plan. Before a line is written.
The agent proposes the story in steps: the modules it touches, the use cases and events it adds, how they meet. It is checked against the code and the rules, and you agree to it before the code exists.
stories/12.plan.json
Add due dates to cards
Steps
1
A card has a due date
card.setDueDate saves the date and emits card.dueDateSet.
2
Its reminder is scheduled
card.dueDateSet triggers reminder.scheduleFor.
Rules
✓notifications listens to boards; boards knows nothing of notifications.
✓scheduleFor is idempotent: a changed date never leaves two reminders.
@newt-js/core
All the artifacts. Each in its place.
Routes, use cases, entities, repositories, events, workers and schedulers, following what happens in a task app when someone deletes one.
01 / 08RouteThe API only reaches a use case. It never touches the database.
02 / 08Use caseWhat can be asked of the card module: it loads, lets the entity decide, and saves.
03 / 08EntityThe card keeps its own rules: it marks itself deleted and records what happened.
04 / 08RepositorySaves the cards and what they tell in one transaction: all of it, or nothing.
05 / 08EventIt leaves through the outbox, written with the change: it is never lost.
06 / 08WorkerAnother module listens. Each reaction is a job, retried until it succeeds.
07 / 08Use caseThe worker only calls a use case of its own module: the card’s files go with it.
08 / 08SchedulerOnce an hour, the module sweeps uploads left halfway, through the same kind of worker.
/** A card of a board. */export class Card extends Entity<typeof CardSchema> { reposition(position: number): void { this.change({ position }) } delete(author: CardAuthor): void { this.markAsDeleted() this.trackEvent(new Card_Deleted({ ...this.toDTO(), ...author, })) }}
export class Card_Repository extends TableRepository<Card, CardRow, BoardsBase> { /** The cards and what they tell: at once. */ async persistOrder( cards: Card[], columnIds: string[], ) { const columns = [...new Set(columnIds)] await this.save(cards, each => this.write(each), { guard: columns.map(columnId => `cards:${columnId}`), after: async () => { for (const columnId of columns) { const positions = (await this.inColumn(columnId)) .map(card => card.position) if (positions.some((position, index) => position !== index)) this.conflict() } }, }) }}
/** The card as it was, and who deleted it. */type CardDeletion = CardDTO & CardAuthorexport class Card_Deleted implements DomainEvent<CardDeletion> { static readonly eventName = 'card.deleted' readonly name = Card_Deleted.eventName readonly occurredAt = now().toISOString() constructor( readonly payload: CardDeletion, ) {}}
/** Each a saved job, safe to run again. */export function registerAttachmentWorkers( attachments: Attachment_Module, deps: Attachment_Deps,) { deps.card.events.deleted.subscribe( ({ workspaceId, id }) => attachments.removeOfCard(workspaceId, id), { strategy: 'handler', queue: '…removeOfCard.on.card.deleted', }, ) …}
export class Attachment_Module extends Module { /** From a worker: the card went, files go. */ @UseCase() async removeOfCard( workspaceId: string, cardId: string, ) { await runInWorkspace(workspaceId, () => this.removeAll(() => this.repo.find({ cardId }))) } private async removeAll(find: …) { const found = await find() found.forEach(a => a.remove()) if (found.length > 0) { await this.repo.persist(...found) } }}
export class Attachment_Module extends Module { /** Told once an hour. */ readonly hourly private constructor(base: BoardsBase, …) { … this.hourly = base.schedules.define( 'attachment.hourly', '0 * * * *') } /** Uploads left halfway, over an hour ago. */ @UseCase() async sweepPending(): Promise<void> { … }}// attachment.workers.tsattachments.hourly.subscribe( () => attachments.sweepPending(), { strategy: 'handler', queue: '…' },)
@newt-js/review
The branch, against its plan. You review what matters.
When the agent is done, the branch is held against the plan by what is in the code: what is done, what is missing, and what nobody planned. That 47-file pull request, in a few lines.
Add due dates to cards #21247 files · +3,184 −412
Review: Add due dates to cards
2 things to look at.
The plan’s steps
1.A card has a due date· done
2.Its reminder is scheduled· half done (1/2)
Against the plan
✗ missingnotifications/reminder.scheduleFor
+ not plannedboards → notifications
✓ doneboards/card.setDueDate
✓ doneboards/card.dueDateSet
Rules
!notifications/digest reads the card table of boards.
@newt-js/monitor
An APM that speaks your domain. Not your URLs.
Traces, errors and latency, like any APM, but told by context, module and use case, not by endpoint and SQL query. Every request in production, on the map of your system.
askslistens toused byHover a module
backoffice
what the staff sees
boards
boards, columns and cards
auth
accounts, workspaces and access
This is a task app, drawn from what its modules declare. Between contexts, arrows only point down; inside each, a module always stands left of what it uses. None goes back.
Principles
“Let the machine write. Let a person decide the shape.”
Why every system an AI writes must be supervisable, backend or not, and what it takes.