Repository navigation
refactor(workflow-code): source pipeline plan/commit split, one findings bound, CLI source-dir split - #10238
Merged
Conversation
…ls package The coerce/validate rules, row checks, select resolution and currency, date and ttl parsing move from @sim/workspace-code/table-cells to @sim/table-cells. isSupportedCurrencyCode has one owner there; the copy in workspace-code kinds/table.ts is gone. Display and clock helpers move into apps/sim: lib/table/currency-format.ts (formatter cache is now an lru-cache with a max) and lib/table/ttl-picker.ts. workspace-code drops its zod dependency, and check:boundaries holds the new package pure.
expectLinearGrowth (@sim/testing/helpers/scaling) times a step at n and 8n and fails anything quadratic. It replaces workflow-code's scaling.test-helpers (and its package export) and the chat-content scalingRatioOver4x helper.
…ft check Replaces the expectedDraft flag-and-assert pair: the deploy and the chat replace each pass their publish to withExpectedDraft, which returns its result and throws WorkflowDraftChangedError when the check refused it. The chat replace passes its own workflow context instead of resolving it a second time.
…factory and refusal class
- @sim/workflow-code/diagnostics: one DiagnosticSeverity, SeverityOf and severityOf
(severity.ts), a diagnostic() factory that fills severity from the code (factory.ts),
and refusalClass/refusalClassifier beside the edit refusals (refusals.ts)
- DIAGNOSTIC_CODES declares every code once; print's codes are a subset type of
compile's, and DiagnosticCode is never if a code is declared twice
- workspace-code keeps only its own codes plus the three it shares with workflow
source (E_APPLY_STALE, E_LIMIT_EXCEEDED, E_NAME_TAKEN); WorkspaceDiagnosticCode is
never if an own code is also a workflow code; its refusalClass is the shared
classifier with its locked and size-limit codes
- hand-built { code, severity } literals in canonicalize, print, materialize, lock,
source-meta and structured/variables use the factory; Reporter and workspace
diagnostic() use the shared severityOf
- OpenAPI/cli-api: the workspace enum lists the three shared codes after its own
…truncation marker - diagnostics/bound.ts: boundDiagnostics (per-severity, per-code warning, total and text limits; errors that class a refusal kept first; one I_FINDINGS_TRUNCATED counting what was left out), boundFindingText, FINDING_LIMITS, findingsTruncated - I_FINDINGS_TRUNCATED is declared once in workflow-code and shared by workspace source; W_TOO_MANY_WARNINGS is gone (Reporter records I_FINDINGS_TRUNCATED where its warning caps cut, counted in the warning slot as before) - Reporter keeps its caps as a work bound (frames, did-you-mean hints, message text) and reads the numbers from FINDING_LIMITS; the MAX_WARNINGS/MAX_INFOS exports go - edges: workflow source routes (apply, plan, create, v2 and internal get) and the SOURCE_REJECTED renderers bound through boundSourceFindings; the workspace plan (capFindings replaced by boundFindings, same 1,000 total and class-first rule) and read answer; the CLI findingsOutput cuts finding text - OpenAPI/cli-api: W_TOO_MANY_WARNINGS removed from the workflow enum
… and commit Move runSourceApply and source-evaluate.ts into lib/workflows/application/source-pipeline: load, plan, outcome, commit and effects, with evaluate/ split by phase (compile, resolve, refusals, gates, finalize). The public source use cases take exactly the wire input; the workspace apply plans and commits each workflow through internal workflowSourceUpdate and workflowSourceCreate pairs instead of planOnly/evaluated/shared/withinCreate/pendingResources and a caller-minted workflowId. A commit refuses a plan made for another workflow or principal. isResourceKind is imported from @sim/workflow-code.
The three v2 source routes answer through presentSourceOutcome, which picks exactly the fields the response schema exposes, instead of handing the use case's result to the schema.
…nd a barrel layout, files, written, dir-kind, write-back and command-lock modules; every ./source-dir import resolves to the barrel unchanged. The three printed-path filters share refusedSourcePaths.
Directory readers and writers move out of the command files: workflow-dir.ts (readBase, readLock, readSourceFiles, requireEntry, WORKFLOW_TREE and the get and create writers), source-check.ts (the check pipeline both check commands share), parseKinds/ONLY_KINDS_HELP into workspace-source-dir.ts and destructiveChanges into source-status.ts.
…geError The 50 SimApiError(message, 0, ...) calls the source commands raised for their own refusals become SourceDirError (the directory, its records, a path it would send or write) or CliUsageError (flags and arguments). Both extend SimApiError with status 0, so the message, code, exit status and the unreachable-server rule are unchanged; telemetry now names the class.
…ry workflow directory source-write.ts owns preview, refusal exit, plan stop, confirmation and the interrupt-deferred send and save; workflow apply/create and workspace apply each supply a flow, and the deploy step stays workflow-only after it. Behaviour change: workflows source get/apply/create now hold .sim/command.lock on a standalone workflow directory too (withSourceCommandLock), so a second command on it exits 10 (SOURCE_DIR_BUSY) instead of interleaving its writes.
…row table sourceExitCodeRows is the one table the directory guides and each write or get command's --help (sourceExitCodesHelp) are built from, so a renumbered code cannot leave a stale digit in either. The busy clause joins each list instead of a separate line; the guides and the remaining help lines interpolate the constants. Words are unchanged; the help reflows to 100 columns, and the CLI docs regenerate (whitespace collapses there, so only the busy clause moves).
…tic factory The apply-side findings the pipeline raises (workflow mismatch, stale, catalog moved, kept credential, claimed lock id, block and variable deletes, meta limits, name taken, probable rename) take their severity from the code through diagnostic(), as the package's findings already do.
…hable redeployment fallback
…owns the replan rule The workspace commit use cases took a plan or the submission to plan again, told apart by shape, and the adapter decided which (commitsAsPlanned). The plan now records when it resolved a stand-in id and keeps the submission it was planned from; planForCommit plans it again at commit time. The adapter reads a plan only through summarizePlan, so SourcePlan's layout no longer reaches lib/workspace-source.
boundAnswerFindings owns the marker text and the refusal-first rule for both domains; the workspace passes WORKSPACE_ANSWER_BOUND. The workspace bound moves out of buildWorkspacePlan into the GET, plan and apply presenters and v2WorkspaceSourceErrorPolicy, so a workflow refused at commit inside a workspace apply, and findings an apply's writes add, are bounded too. When the edge cuts a list it replaces the stages' own I_FINDINGS_TRUNCATED with one marker whose counts exclude them. Route tests replace the helper test.
…lans, and refuses an apply
…n, the create-name check at plan, and per-session plan binding
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
Contributor
[High impact] The PR changes shared workflow-source paths, CLI source operations, and table-cell code. Fix the read-only plan path before merging; preserving the original principal check is also worthwhile. FindingsSummarySplits workflow source work into load, plan, preview, commit, and effects.
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 174 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
planForCommit replanned a stand-in plan as the committing principal and only then let commitSource check the binding, which the replanned plan always passed. Check the original binding first, and throw a typed, coded PlanBindingError for both bindings so tests assert the code. Also: the stand-in filter on replan is load-bearing (without it a resource the apply never created is written under its stand-in id); say so and test it. Drop boundTo.principalKind (only a log line read it) and the unused SourceSubmission export.
…n answer bounds Each edge bounded its findings with no test that fails when it stops; exercise them through the route. Rename the workspace POST case to the plan-time refusal it actually models: a commit refusal is caught mid-apply and answered 200 with failed.
Only the workspace check's bound was tested. Row writes naming 25 undeclared columns are CLI-side findings the compile does not cap, so the default workflow bound is what lists 20 of them.
mkdir resolves '..' after following links while the cleanup climbs the lexical path, so a dir holding '..' removed an empty folder the lock never created and left one it did. Resolve first so both walk one path, remove created folders on the error paths after mkdir too, and test an empty pre-existing parent, which the climb must stop at.
apply and create skipped the refresh only on --dry-run, so a plan (no terminal, no --yes) could rewrite .sim/sdk before previewing, and fail on a read-only directory instead of answering. Skip it in every read-only mode.
A lock codeFile of 'functions/' passed the prefix check, and its recursive removal took the whole folder, files no lock named included. Apply the codeFile path rule before pruning.
The embedded branch read every failure as a missing file, so a run stopped during a read carried on as if the file were absent. Rethrow once the run's signal has aborted; the host reader still names no missing-file error, so other failures keep reading as missing.
SourceDirError and CliUsageError carry status 0 and often a null code, which noAnswer reads as a request with no answer: a status whose own directory refused a read reported the server unreachable, and a write whose save-back was refused got the answer-lost hint. Give both a LocalRefusal base and exclude it from both checks.
… it reads The source names the credential by its stored id, not by a key; the key a commit would allocate comes from the stored reference. The check goes red when a dry run allocates, so only its name was wrong.
…ules workflow-source-check.ts reads workspace declarations through it, so the claim that the two command families never import each other holds only for their command modules.
A get exits 13 without a login or with a refused credential, but only the writes named it (in their shared section).
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wave 2 of the workflows and workspace as code cleanup. Behaviour is the same except where noted below.
Source pipeline
planForCommitand no longer through the adapter. The adapter reads a plan only throughsummarizePlan.Findings
boundAnswerFindingsis now the single bounding policy. It is applied at every answer edge, including:check.I_FINDINGS_TRUNCATEDis the only marker, andW_TOO_MANY_WARNINGSis removed.CLI
source-dir.tsis split into asource-dir/folder.runSourceWriteflow. Refusals are typed asSourceDirErrorandCliUsageError.Other
@sim/table-cells.@sim/testinggets a shared linear-growth helper.withExpectedDraftruns a publish under its draft check.Contract changes
--dry-runandplanwork on a read-only standalone directory. A write to one is refused up front.error_namevalues follow the typed CLI errors.Testing
check:audits,check:test-types, docs compatibility and lint.