Skip to content

Commit ff6a245

Browse files
committed
feat(build-notes): draft workflow builds in hidden, agent-only build notes
Behind the build-notes feature flag, Chat drafts a workflow build in build-notes/<workflowId>.md before it changes the graph, and Sim keeps the sanitized graph of its last build beside it as build-notes/<workflowId>.baseline.json. - workflow_build_notes owns both files; they never appear in Files and only Copilot reaches them - build_notes service: create, status, evaluate (dry-run of the notes' operations block plus open placeholders and items), apply, changes, rebase - a Copilot apply or state replace on a workflow with notes must be the evaluated batch, from unchanged notes, on a graph unchanged since the baseline; a person's edit is never refused and shows up in changes - evaluation holds a build only for lint its batch adds - archive and restore carry the notes; the file ownership functions admit the build_notes context
1 parent 8e2ed5e commit ff6a245

48 files changed

Lines changed: 35968 additions & 19 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { z } from 'zod'
2+
3+
const target = z.object({
4+
workspaceId: z.string().min(1).max(100).optional(),
5+
workflowId: z
6+
.string()
7+
.trim()
8+
.regex(/^[A-Za-z0-9_-]{1,100}$/, 'workflowId must be a workflow id')
9+
.describe('The workflow the notes belong to.'),
10+
})
11+
12+
/**
13+
* A workflow's build notes: the agent's hidden scratchpad at build-notes/<workflowId>.md, with
14+
* the graph Sim last recorded beside it at build-notes/<workflowId>.baseline.json.
15+
*/
16+
export const mothershipBuildNotesInputSchema = z.discriminatedUnion('action', [
17+
target.extend({ action: z.literal('create') }).strict(),
18+
target.extend({ action: z.literal('status') }).strict(),
19+
target.extend({ action: z.literal('evaluate') }).strict(),
20+
target.extend({ action: z.literal('apply') }).strict(),
21+
target.extend({ action: z.literal('changes') }).strict(),
22+
target.extend({ action: z.literal('rebase') }).strict(),
23+
])

‎apps/sim/lib/api/contracts/mothership-management-tools.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ const examples = {
6262
},
6363
{ action: 'update', releaseId: 'release-1', expectedRevision: '2', version: '1.5.0' },
6464
],
65+
build_notes: [
66+
{ action: 'create', workflowId: 'wf-1' },
67+
{ action: 'status', workflowId: 'wf-1' },
68+
{ action: 'evaluate', workflowId: 'wf-1' },
69+
{ action: 'apply', workflowId: 'wf-1' },
70+
{ action: 'changes', workflowId: 'wf-1' },
71+
{ action: 'rebase', workflowId: 'wf-1' },
72+
],
6573
}
6674

6775
describe('management tool provider contract', () => {

‎apps/sim/lib/api/contracts/mothership-management-tools.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { z } from 'zod'
2+
import { mothershipBuildNotesInputSchema } from '@/lib/api/contracts/mothership-build-notes'
23
import { mothershipChangelogInputSchema } from '@/lib/api/contracts/mothership-changelog'
34
import { mothershipDashboardsInputSchema } from '@/lib/api/contracts/mothership-dashboards'
45
import { mothershipTestsInputSchema } from '@/lib/api/contracts/mothership-tests'
@@ -36,6 +37,14 @@ export const managementToolContracts = [
3637
'Publish and edit the selected workspace\u2019s changelog. publish takes a title, a markdown body, the changes (one line each, with the workflowId, deploymentVersionId, and chatId they came from when known), and bump: major, minor, or patch for how significant the release is, with a one-line bumpReason. The server computes the version from the workspace\u2019s highest one; never write a version number on publish. It returns the release with its revision and changelog/<id>.md, the body file: edit the body there with the file tools, for example to add impact charts once there is data. update changes the title, bumpReason, version label, or the whole change list, and requires expectedRevision from get, list, or publish so a concurrent edit is never overwritten. A deployment ships in one release: a deploymentVersionId already in another release is rejected. list pages newest first; get returns one release with its revision and its changelog/<id>.md path.',
3738
inputSchema: mothershipChangelogInputSchema,
3839
},
40+
{
41+
id: 'build_notes',
42+
route: 'sim',
43+
scope: 'all',
44+
description:
45+
'A workflow\u2019s build notes: the hidden scratchpad the agent drafts a build in before changing the graph. Nobody else sees or edits it; a later chat reads it to explain how the workflow was built. create writes build-notes/<workflowId>.md from a template and records the current graph as build-notes/<workflowId>.baseline.json; edit the notes with the file tools, never the baseline. evaluate dry-runs the notes\u2019 operations block and lists what still blocks a build: open placeholders, items marked [gather] or [ask], dry-run skips, input errors and lint. Once evaluate passes, apply builds from exactly that block, atomically; a workflows operations apply of a different batch, notes edited since, or a graph changed outside the agent is refused until the notes pass evaluation again. Each build spends the evaluation. status says whether notes exist, passed evaluation, and whether the workflow was saved since the baseline; changes lists what changed since the baseline; after reconciling the notes, rebase records the current graph as the new baseline.',
46+
inputSchema: mothershipBuildNotesInputSchema,
47+
},
3948
{
4049
id: 'workspaces',
4150
route: 'sim',

‎apps/sim/lib/api/contracts/workspace-files.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export const workspaceFileRecordSchema = z.object({
239239
contentUpdatedAt: z.coerce.date().nullable().optional(),
240240
revision: z.string().optional(),
241241
storageContext: z.enum(['workspace', 'mothership']).optional(),
242-
vfsNamespace: z.enum(['uploads', 'tests', 'changelog']).optional(),
242+
vfsNamespace: z.enum(['uploads', 'tests', 'changelog', 'build-notes']).optional(),
243243
share: shareRecordSchema.nullable().optional(),
244244
})
245245

0 commit comments

Comments
 (0)