Repository navigation
feat(build-notes): draft workflow builds in hidden, agent-only build notes - #10193
myxamediyar wants to merge 9 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
[Medium impact] The changes affect Copilot workflow-building and the storage paths for its private notes. The code needs the required folder barrels and exported-helper documentation before merging; no new blocking runtime failure was established. Findings
SummaryAdds hidden, agent-only workflow build notes behind the
|
There was a problem hiding this comment.
All reported issues were addressed across 48 files
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
ff6a245 to
1d34bab
Compare
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 50 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
b094961 to
f0adcf2
Compare
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 50 files
Confidence score: 4/5
- In
apps/sim/lib/build-notes/content.ts, notes can be written withnotes.baselineFileIdnull, leaving an incomplete row that can be evaluated without a baseline. Reject the write and direct callers to runbuild-notes rebasefirst.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/build-notes/content.ts">
<violation number="1" location="apps/sim/lib/build-notes/content.ts:21">
P2: A notes write is accepted while `notes.baselineFileId` is null. Refuse it and direct the caller to run `build-notes rebase` before editing notes, so an incomplete notes row cannot be evaluated without a baseline.
(Based on your team's feedback about requiring a baseline before guarded writes.)</violation>
</file>
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 50 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 50 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
…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
…ghten review findings - spend the evaluation and re-check the baseline inside the write transaction; notes writes spend it too, so a build racing a notes edit is refused - record the baseline from the build's own commit (afterWrite hook) - refuse a Copilot whole-graph replace on a workflow with notes, and a build with no baseline - detect credential switches through salted hashes of withheld values - compare lint findings by block id, as counts - restore build notes with a restored folder; skip the archive step on a schema that predates the table - read the baseline in one snapshot, refuse oversize baselines, anchor the operations fence, accept any list marker for open items
…s monotonic - archive the workflow rows, then build-notes files, then notes rows: the order builds (workflow, notes) and notes writes (file, notes) already take - record a baseline only if it is not older than the recorded one, rolling back its file write otherwise - a failing evaluation withdraws an earlier pass - refuse NUL bytes in notes; hash cleared block data values too
…nt builds and archives - record a passing evaluation only while its baseline is still the recorded one - create notes and baseline files under a shared lock on the live workflow row - hand build-notes files to the workspace when their creator's account goes
…'s evaluation honest
…ck a baseline before creating notes
0763144 to
b11250d
Compare
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 50 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
|
@cubic-dev-ai review this PR |
@myxamediyar I have started the AI code review. It will take a few minutes to complete. |
| const buildNotes = input.dryRun | ||
| ? null | ||
| : await assertBuildNotesAllowWrite({ | ||
| principal, | ||
| workflowId: context.workflowId, | ||
| workspaceId: context.workspaceId, | ||
| workspaceOrganizationId: context.workspaceOrganizationId, | ||
| batch: { operations: input.operations, blockEnabledChanges: input.blockEnabledChanges }, | ||
| }) |
There was a problem hiding this comment.
Approved builds can save partially
After evaluation passes, a credential can be deleted or the caller can lose access without changing the workflow graph. Ordinary Copilot workflows operations apply still passes the new guard for that batch. Then preValidateCredentialInputs removes the credential, and the default atomic: false lets the incomplete graph save and become the baseline.
Require atomic writes whenever buildNotes is present, not only in applyBuildNotes.
| import { | ||
| type BaselineGraph, | ||
| type BaselineSnapshot, | ||
| diffFromBaseline, | ||
| loadCurrentBaselineState, | ||
| parseBaseline, | ||
| } from '@/lib/build-notes/baseline' | ||
| import { isBuildNotesEnabled } from '@/lib/build-notes/feature-flag' | ||
| import { readBaselineText, readBuildNotesFileText, writeBaseline } from '@/lib/build-notes/files' | ||
| import { type BuildNotesBatch, batchHash, notesHash } from '@/lib/build-notes/notes' | ||
| import { buildNotesPath } from '@/lib/build-notes/paths' | ||
| import { | ||
| type BuildNotesRow, | ||
| getLiveBuildNotesForWorkflow, | ||
| spendBuildNotesEvaluation, | ||
| } from '@/lib/build-notes/repository' |
There was a problem hiding this comment.
Required shared exports are missing
The new build-notes folder has more than three exports but no index.ts, and these imports read its individual modules. The import guide requires folders with three or more exports to provide a barrel and callers to use it. The same pattern appears in application/build-notes.ts.
Add the required barrel and update these imports before merging.
Context Used: Import patterns for the Sim application (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| export function buildNotesFileName(workflowId: string, file: BuildNotesFile): string { | ||
| return `${workflowId}${file === 'notes' ? NOTES_SUFFIX : BASELINE_SUFFIX}` | ||
| } | ||
|
|
||
| export function buildNotesPath(workflowId: string, file: BuildNotesFile): string { | ||
| return `${BUILD_NOTES_PREFIX}${buildNotesFileName(workflowId, file)}` |
There was a problem hiding this comment.
Exported helpers lack required documentation
The new buildNotesFileName and buildNotesPath exports have no TSDoc. notesHash is another example. The repository requires TSDoc on exported APIs, so add short comments describing these helpers’ contracts before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| import { | ||
| diffFromBaseline, | ||
| loadCurrentBaselineState, | ||
| parseBaseline, | ||
| } from '@/lib/build-notes/baseline' |
There was a problem hiding this comment.
Required folder barrels are missing
The new build-notes and build-notes/application folders each expose more than three exports but have no index.ts. Callers import their individual files instead. The repository requires a barrel when a folder has three or more exports. Add the barrels and update these imports before merging.
Context Used: Import patterns for the Sim application (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| }) | ||
| } | ||
|
|
||
| export function serializeBaseline(baseline: BaselineGraph): string { |
There was a problem hiding this comment.
Exported helpers lack required TSDoc
New public helpers such as serializeBaseline and parseBaseline have no TSDoc. The same pattern appears on readBuildNotes and buildNotesFileName. The repository requires TSDoc on exported APIs. Document what these helpers accept, return, and reject before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
2 issues found across 50 files
Confidence score: 3/5
apply-workflow-operations.tscan let a matching apply withatomic: falsesave a partial graph as the new baseline after unavailable credentials are removed. Require atomic writes for this path.replace-workflow-state.tscan report a successful dry run that the committed write will reject because dry runs skip the build-notes guard. Run the guard during dry runs or update the contract.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/workflows/application/replace-workflow-state.ts">
<violation number="1" location="apps/sim/lib/workflows/application/replace-workflow-state.ts:143">
P3: The dry run skips the build-notes guard, so Copilot gets a success preview for a replace the committed write will refuse. The dryRun contract says the two responses match. Run the guard for dry runs too, or document the exception.</violation>
</file>
<file name="apps/sim/lib/workflows/application/apply-workflow-operations.ts">
<violation number="1" location="apps/sim/lib/workflows/application/apply-workflow-operations.ts:230">
P2: A matching `workflows operations apply` can pass this guard with `atomic: false`; credential prevalidation can then remove unavailable credentials while saving a partial graph as the new baseline. Require atomic writes whenever `buildNotes` is present.</violation>
</file>
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
Turn on auto-fix | Re-trigger cubic
| batch: { operations: input.operations, blockEnabledChanges: input.blockEnabledChanges }, | ||
| }) |
There was a problem hiding this comment.
P2: A matching workflows operations apply can pass this guard with atomic: false; credential prevalidation can then remove unavailable credentials while saving a partial graph as the new baseline. Require atomic writes whenever buildNotes is present.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/sim/lib/workflows/application/apply-workflow-operations.ts, line 230:
<comment>A matching `workflows operations apply` can pass this guard with `atomic: false`; credential prevalidation can then remove unavailable credentials while saving a partial graph as the new baseline. Require atomic writes whenever `buildNotes` is present.</comment>
<file context>
@@ -214,6 +220,15 @@ export const applyWorkflowOperations = defineAuthorizedWorkflowUseCase({
+ workflowId: context.workflowId,
+ workspaceId: context.workspaceId,
+ workspaceOrganizationId: context.workspaceOrganizationId,
+ batch: { operations: input.operations, blockEnabledChanges: input.blockEnabledChanges },
+ })
</file context>
| batch: { operations: input.operations, blockEnabledChanges: input.blockEnabledChanges }, | |
| }) | |
| batch: { operations: input.operations, blockEnabledChanges: input.blockEnabledChanges }, | |
| }) | |
| if (buildNotes && !input.atomic) { | |
| throw new OrchestrationError('validation', 'Build-notes writes must be atomic') | |
| } |
| if (!input.dryRun) { | ||
| await assertBuildNotesAllowWrite({ | ||
| principal, | ||
| workflowId: context.workflowId, | ||
| workspaceId: context.workspaceId, | ||
| workspaceOrganizationId: context.workspaceOrganizationId, | ||
| }) | ||
| } |
There was a problem hiding this comment.
P3: The dry run skips the build-notes guard, so Copilot gets a success preview for a replace the committed write will refuse. The dryRun contract says the two responses match. Run the guard for dry runs too, or document the exception.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/sim/lib/workflows/application/replace-workflow-state.ts, line 143:
<comment>The dry run skips the build-notes guard, so Copilot gets a success preview for a replace the committed write will refuse. The dryRun contract says the two responses match. Run the guard for dry runs too, or document the exception.</comment>
<file context>
@@ -138,6 +139,15 @@ export const replaceWorkflowState = defineAuthorizedWorkflowUseCase({
async execute({ principal, input, context }): Promise<ReplaceWorkflowStateResult> {
await requireMutableWorkflow(context.workflowId)
+ // Refuses Copilot outright on a workflow with build notes: a replace has no evaluated batch.
+ if (!input.dryRun) {
+ await assertBuildNotesAllowWrite({
+ principal,
</file context>
| if (!input.dryRun) { | |
| await assertBuildNotesAllowWrite({ | |
| principal, | |
| workflowId: context.workflowId, | |
| workspaceId: context.workspaceId, | |
| workspaceOrganizationId: context.workspaceOrganizationId, | |
| }) | |
| } | |
| await assertBuildNotesAllowWrite({ | |
| principal, | |
| workflowId: context.workflowId, | |
| workspaceId: context.workspaceId, | |
| workspaceOrganizationId: context.workspaceOrganizationId, | |
| }) |
Summary
build-notesfeature flag (off by default; global and per-organization rollout)build-notes/<workflowId>.mdbefore it changes the graph; Sim keeps the sanitized graph of its last build beside it inbuild-notes/<workflowId>.baseline.jsonworkflow_build_notestable owns both files (owned-file contextbuild_notes): never listed in Files, reachable only by Copilot (people and API keys get not found), archived and restored with the workflow, never copied by duplicate, fork or exportbuild_notesCopilot service:create,status,evaluate(dry-runs the notes' operations block and lists open<<open:…>>placeholders,[gather]/[ask]items, skipped operations, input errors, and lint the batch adds),apply(builds from the evaluated block, atomically),changes(redacted diff since the baseline, ignoring layout),rebaseoperations applymust be the evaluated batch, from notes unchanged since evaluation, on a graph unchanged since the baseline (credential switches included, through salted hashes of withheld values); the check holds under the workflow lock, where the build spends the evaluation, and the baseline moves to exactly what the build committed. A Copilotstate replaceis refused. A person's edit (editor or API) is never refused; it shows up inchangesworkflow_build_notesand lets the file ownership functions admit thebuild_notescontext (reconcile-file-ownershipreplays them for push-provisioned databases)listWorkflowLintFindingslets evaluation compare a batch's lint with the saved graph'sType of Change
Testing
lib/build-notes/build-notes.integration.ts(19 checks, real Postgres): hidden files and person access, baseline write refusal, evaluation and its parser, exact-batch builds, edited-notes refusal, a person's edit and its reconciliation, lint the batch adds vs. lint already in the graph, content-gate refusal, refused replace, credential switches, folder restore, flag off, archive and restore with file history, archive/build lock order, stale verdicts and baselines, first-baseline races. Disabling the agent-only access check, the apply guard, the archive lock order, the baseline's evaluation withdrawal and the attach-once rule turns their checks redlib/build-notes/agent-path.integration.ts: the whole loop throughsim_clias Chat sends it (24 calls:workflows create,build-notes create/evaluate/apply/status/changes/rebase,files read/edit), with a JSON transcript intest-results/build-notes-agent.json. It caught two bugs fixed here: the template's own example placeholder blocked every evaluation, and lint from a person's unfinished edit blocked the agent's buildsbun run test(3777 files pass),bun run lint,bun run type-check,bun run check:audits,bun run check:migrations origin/staging, block registry check, drizzle-kit generate (no drift)Checklist
test-auditauthoring gate)