goateddev

Writing safely: plan, then apply

centrex plan putRoutingQueue --params '{"path":{"queueId":"..."},"body":{"name":"Support Tier 1"}}'
centrex apply <planId>
  • plan writes nothing. What it shows depends on the write:

    • PUT or PATCH: reads the current resource with the GET on the same path and shows the fields that change as before and after. A PUT replaces the whole resource, so the fields its body leaves out are listed as removed (read-only fields and fields the body definition does not declare excepted). The body is validated against its definition first: types and enums for both, required fields for a PUT only; a mismatch is refused, naming each field.
    • Creating POST (a POST to a collection that has a GET on <path>/{id}, like postRoutingQueues): validates the payload against the body shape (required fields, types, enums) and echoes it; a bad payload is refused.
    • For all three, a top-level body field the definition does not declare is listed in the plan’s warnings.
    • Action POST (any other POST, like postConversationDisconnect): reads the resource it acts on and describes the call.
    • DELETE: reads and shows the whole resource.
    • When no GET reads the current state (postFlowsActionsPublish, putConversationTags), or the GET answers 403 or 404: says so (stateKnown: false, with stateError naming the GET, status and code when it answered), echoes the call and payload, and apply writes without the staleness check. A DELETE whose GET answers 404 is refused: there is nothing to delete.

    It lists the permissions the operation requires, saves the plan in the org’s plans/ folder and prints the planId. Values under secret field names (apiKey, password, token, secret, credential…) are redacted in the plan file and listed in secretFields by dotted path (body.apiKey); give them again to apply (centrex apply <planId> --secrets '{"body.apiKey":"..."}', or the secrets argument of the MCP apply tool). They are sent with the write and never saved or logged. A change to a secret-named field the plan touches is still detected at apply: the plan keeps a SHA-256 digest of its value, never the value.

  • apply <planId> re-reads the resource and refuses when any field the plan touches (or the resource’s version) has changed since the plan, naming the field, or when a resource to delete or act on is gone. Otherwise it writes, re-reads to confirm (a created resource by its returned id; a deleted one must answer 404), appends one JSON line to the org’s apply-log.jsonl and marks the plan applied. The result says confirmed: true when the re-read shows the write; otherwise confirmed: false with warnings (a deleted resource that still reads, a re-read that failed, a write with no GET to re-read it). The write went through either way, and the plan is applied. A plan is applied once and expires 30 minutes after it is made. An apply first claims the plan (its file moves to plans/applying/), so two applies of the same plan at once write once: the second is refused. When the write fails, the plan goes back to pending. A refusal (unknown, expired, already applied or being applied, stale, read-only mode, secrets missing) writes nothing and also appends one record, with "result": "refused" and the reason.

  • execute refuses every write operation.

  • With CENTREX_READ_ONLY=1, plan and apply refuse every write.

Flow files: export and publish

Centrex exports an Architect flow as YAML and publishes a YAML file, without Archy.

centrex exec postFlowsExportJobs --params '{"body":{"flows":[{"flow":{"id":"<flowId>"}}]}}'
centrex plan postFlowsJobs --params '{"body":{"file":"main-ivr-inboundcall-3.yaml"}}'
centrex apply <planId>
  • Export is a read and needs no plan. execute registers the export job of one flow (by flow.id, or flow.name and flow.type; the published version unless flow.version is given; YAML only), polls it, downloads the file and writes it to <org folder>/flows/<name>-<type>-<version>.yaml, private to the user. An existing file is never overwritten: the same content is left as it is (written: false), a different one gets a numbered name (-2, -3…). The result gives the file path and its hash, not the YAML.

  • Plan takes body.file: a YAML file inside the org’s folder (a bare name is looked up in flows/). It reads the flow’s name and type from the file and shows:

    • target: update of the existing flow with that name and type, or create. A changed name creates a new flow and leaves the original as it is; the first warning says so in capitals.
    • diff: a line diff against the published flow, exported at that moment (base keeps its version and hash).
    • validation: what validated the file, or ran: false with a note. No validation ships yet, so today every plan says that none ran; a problem in the file surfaces as an error of the publish job.
    • warnings: that publishing replaces a live flow at once.

    The plan file keeps a frozen copy of the file and its SHA-256. Editing the file afterwards changes nothing: apply publishes the copy the plan froze. Values under secret field names are redacted in that copy and listed in secretFields as flow.L<line>.<key>; give each one again to apply as the text written in the file after the key.

  • Apply refuses when the flow is no longer what the plan saw (another published version, another content, a flow that appeared or disappeared). Then it registers the job with createStubs: false (always: a reference the flow cannot resolve must fail the job, not create resources), uploads the file, polls the job, and checks that the flow has a newer published version (for a new flow: that it exists with that name and type). A failed job is a FlowJobFailedError with the job’s messages; nothing is published and the plan stays pending. A job still running after five minutes is reported as applied but confirmed: false, with the job id to follow.

  • Signed URLs. The download and the upload go to a storage host through signed URLs, the only calls Centrex makes outside the login and API hosts. They are made only for a URL that postFlowsJobs or getFlowsExportJob has just returned, over https, with no token and no header but the ones the API returned for the upload, and without following redirects. A signed URL is never written to a plan, the apply log, a result or an error.

Never allow-list apply

Centrex does not try to prove that a human approved a plan. The human gate is your client’s permission prompt on apply (the centrex apply command, or the apply tool of the MCP server). Never add apply to the client’s allow-list (for example Claude Code’s permissions.allow): an allow-listed apply lets the agent write to the org without anyone seeing the plan. Read-only actions (search, describe, execute, status, plan) can be allow-listed.