Skip to content

feat(cloud): a configuration home for the Fargate lane, and register it when set - #11556

Merged
chenmingwei23 merged 1 commit into
mainfrom
feat/fargate-config-home-11328
Sep 20, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
feat/fargate-config-home-11328

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

The Fargate launch engine landed, but nothing could reach it. FargateLaunchEngine,
its task definition, its identity model and its RunTask placement all exist under
src/kiro_crew/cloud/fargate/, and yet on main today:

engine_for('aws_fargate') -> KeyError 'aws_fargate'

Two things were missing. There was nowhere for an operator to write down the values
the engine refuses to guess (cluster, subnets, security groups, digest-pinned image,
the model-credential secret), and the provisioner seam still shipped exactly one
lane, so no request could name provider_id=aws_fargate and get an engine back.

Why it matters

This is the step that turns the Fargate work from code in the tree into a lane a
launch can go through. Until it lands, every earlier piece is unreachable by
construction: cloud.json has no section that mentions Fargate, and the only
provisioner the core offers is aws_ec2.

It also decides what an operator sees when they get the configuration half-right.
Registering the lane unconditionally would put a row in front of them that rejects
every launch made through it, at launch time, for a mistake that was visible when
they saved the file.

What changed (motivation -> approach -> change)

Goal: give the Fargate lane a configuration home, and register the lane exactly
when that home is filled in.

RFC of record: docs/request-for-change/rfc-remote-instance-on-fargate.md
(status: in-progress, already on main).

FargateConfig in cloud/config.py holds the placement, the image and the
secrets, read out of the existing cloud.json.

  • Incomplete means absent, not present-and-refusing. is_complete() demands a
    cluster, at least one subnet, at least one security group, a digest-pinned image,
    a known CPU architecture, and a secret that names the model credential. Anything
    else makes from_mapping return None, and that is what leaves the lane
    unregistered.
  • The credential requirement is part of that, because the engine enforces it.
    taskdef._refuse_absent_credential refuses a task definition that delivers no
    secret under KIRO_API_KEY, and the engine derives each secret's destination
    variable from the final segment of its canonical name. So a block carrying every
    placement field and no credential secret is the offered-and-refusing state in its
    most likely form, and the gate this PR ships is where it is cheapest to catch.
    Only the NAME is judged here; whether the ARN is that name plus one service
    suffix stays the engine's verification and is not duplicated.
  • One malformed secret entry voids the whole block, not just that entry. A task
    that starts with one variable missing is harder to diagnose than one that never
    starts.
  • Secrets are stored as (name, ARN) pairs, not bare ARNs. An ARN alone cannot
    say where the secret's name ends: Secrets Manager appends a six-character suffix
    and nothing marks the boundary. These are identifiers, not credential values --
    the value is fetched by the task's execution role before the container starts, so
    this file's written no-credentials contract holds unchanged.
  • assign_public_ip accepts only a real JSON boolean when present. Coercing it
    would read the string "false" as true, and this is the one field in the block
    that decides network exposure, so a present non-boolean voids the block rather
    than being guessed. An absent key still defaults to False.
  • The digest-only image rule is checked here rather than at launch, so a hand-edited
    cloud.json naming a movable tag reads as no Fargate configuration at all.

CloudConfig.fargate carries the raw block, and completeness is judged at the
point of use.
CloudConfig is loaded and re-saved to record last_tag after an
ordinary EC2 launch (cli_cloud.py, cloud/wizard.py), and save() writes
asdict(self). A field holding only a judged value would therefore erase a block an
operator is half-way through hand-editing. So load() stores the block exactly as
written, fargate_config() answers whether it is usable, and the file round-trips
untouched. Measured below.

The conditional lane inside DefaultRemoteProvisionerProvider (platform/defaults.py).

  • provisioners() always returns aws_ec2 and appends aws_fargate only when the
    block is complete. engine_for('aws_fargate') builds a FargateLaunchEngine from
    the block, and raises the same KeyError an unknown id raises when the block
    is absent -- a caller naming an unconfigured lane and one naming a nonexistent
    lane are in the same position, and a second failure mode would ask every caller to
    learn a distinction that changes nothing they can do.
  • The config is read per call, not at construction. Editing cloud.json takes
    effect on the next request and deleting the block removes the lane, with no
    gateway restart.
  • A read failure returns None rather than raising. This runs while the selector
    is being built, so raising would take the aws_ec2 lane down with it and turn one
    lane's misconfiguration into a Set-up tab that shows nothing.
  • The lane lives inside the default provider, with that class's docstring
    corrected in the same commit, rather than in a subclass.
    test_remote_provisioner_seam.py asserts the core's context composes exactly this
    provider; subclassing to slip past that isinstance check would satisfy the letter
    and dodge the intent. cloud/fargate/* and the RFC live in this repository, so the
    core plainly means to own this lane.
  • Every cloud import stays deferred, and not only for weight. A module-level
    import raises ImportError: cannot import name 'current_context' from partially initialized module 'kiro_crew.platform' -- kiro_crew.cloud reaches
    kiro_crew.sandbox, which imports platform.current_context, while platform is
    still initializing. That circular import is the real reason for the deferral, and
    a test now pins it. Weight, measured separately, agrees: kiro_crew.cloud.config
    is 105 ms and 122 modules against a 126 ms init.

cloud.json is sealed against agent writes at both layers, and this PR is what
makes that necessary.

The obvious framing of why that is needed is wrong, so say the real one plainly. It is
true that the block stores a secret's NAME and ARN rather than its value, and that the
execution role fetches the value before the container starts, so the file's
no-credentials contract is intact. That is beside the point. An identifier that
selects WHO RECEIVES the credential is as powerful as the credential
, and the
distinction between storing a secret and naming its recipient collapses the moment the
file is writable by the thing you are defending against. fargate.image is that
identifier: it names the container the launch runs, and KIRO_API_KEY is delivered
into whatever it names. _DIGEST_IMAGE_RE constrains the reference's FORM, not who
owns the registry, so a prompt-injected agent could point it at a digest-pinned image
of its own and leave the owner's cluster, subnets and secret refs untouched.

Per-crew role scoping does not cover this: the attacker's image runs AS that crew's
task, so a secret read scoped to kirocrew/crew/<crew>/* still lands in it. Scoping
bounds blast radius across crews, not this.

Before the fargate block, cloud.json held a profile name, a region and a tag --
nothing that chose a recipient. So the protection ships with the change that creates
the exposure, reusing the mechanisms already in the tree rather than adding a new one
beside them:

Layer Where What it stops
agent file-edit tool gate security.paths._WRITE_PROTECTED_HOME_PATHS an agent's edit tool writing the file
OS sandbox read-only seal sandbox._CREW_READONLY_LEAVES a sandboxed shell's open(..., "w"), which never passes the tool gate
absent-file precreate sandbox._CREW_PRECREATE_READONLY_FILE_LEAVES an agent CREATING the block where no file exists, since mount(2) cannot seal a missing path
strict no-alias requirement sandbox._CREW_NOFOLLOW_READONLY_FILE_LEAVES a symlink whose name stays replaceable, or a second hardlink whose alias sits outside the mount

cloud.json is the only name this change adds to those lists, and nothing sits beside it: the
advisory lock these lists used to carry is gone with the writer that took it. Under the
option-C ruling the file's write-protection is defence in depth rather than the property the
design rests on, so the answer to a gap in a name-shaped seal is not a further name.

The whole file is sealed rather than the block alone, and nothing in the product needs
exempting from that seal: the launch path's own fields live in cloud_launch_state.json, so
the only writer left is the operator themselves, outside both the agent's file-edit gate and
the sandbox. Sealing one sub-key would have needed
a bespoke second mechanism for a single field; sealing the file reuses the four the
tree already has. It stays READABLE at every layer, because the gateway reads it on
each request to build the provisioner list and a script cron resolves it in-sandbox --
masking it would take the Set-up tab down instead of protecting it.

Owning specs are updated in the same commit, as AGENTS.md requires.
docs/system-specs/modules/cloud.md gains a section documenting the block's schema,
the incomplete-means-absent rule and the seal, and its config.py and
fargate_engine.py rows no longer say the engine is unreachable or that the file
holds profile and region only. docs/system-specs/modules/platform-context.md no
longer describes the core as shipping a single lane.

platform/bootstrap.py is deliberately untouched for that same circular import.
It is not a weight judgement that could be revisited later; importing the config
module there does not work.

Measured before / after

Driven from a clean tree against a scratch config home, printing provisioners()
and engine_for('aws_fargate') for each state of cloud.json, then loading and
re-saving the way an EC2 launch recording last_tag does:

=========== main 2627b0407c ===========
-- registration --
no cloud.json            provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
incomplete block         provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
no credential secret     provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
public ip "false"        provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
complete block           provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
block deleted            provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
-- load/save round-trip of the operator's own text --
incomplete block         DESTROYED -> None
complete block           DESTROYED -> None

=========== this branch ===========
-- registration --
no cloud.json            provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
incomplete block         provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
no credential secret     provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
public ip "false"        provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
complete block           provisioners()=['aws_ec2', 'aws_fargate']  engine_for('aws_fargate') -> FargateLaunchEngine
block deleted            provisioners()=['aws_ec2']  engine_for('aws_fargate') -> KeyError 'aws_fargate'
-- load/save round-trip of the operator's own text --
incomplete block         PRESERVED
complete block           PRESERVED

engine_for('aws_fargate') returning an engine is the first time that has happened
in this repository. Three rows are worth reading closely:

  • block deleted returns to ['aws_ec2']. That is the per-call read being
    visible rather than asserted.
  • no credential secret and public ip "false" stay unregistered. Each has
    every placement field; each would otherwise be a lane that exists and refuses.
  • The round-trip rows are measured on main too, and main destroys both
    shapes. main has no fargate field at all, so asdict(self) writes a config
    without one and the operator's block vanishes on the first EC2 launch. This PR is
    what makes that text survive, for a complete block and a half-written one alike.

What this does not do

Registering the lane makes it reachable through the API. It does not put a row in
the Set-up picker: RemoteProvisioner.kind names a frontend form, the dashboard skips
a kind it cannot draw, and no registerRemoteProvisionerRenderer claims aws_fargate
anywhere today. Absent from the picker, not broken in it -- which is what that skip
exists for. No AWS resource is created by anything in this diff.

The escalated decision is resolved: option C

The open question on this PR was whether to keep defending cloud.json's bytes. The ruling
is no -- remove the file's power instead -- and this revision implements it.

Why the question existed. cloud.json is only dangerous because of what it decides:
fargate.image chooses the container a launch runs, and the task's execution role delivers
the model credential into it. Every defence of the file itself is a protection over a NAME,
and a name-shaped protection has to be argued complete for each platform and each way a name
can be aliased. Eight instances of that one class were found against this single new leaf over
this PR's review rounds, the last two inside the patch written to close the previous six. That
is a signal about the shape, not about the care taken on each patch.

What C does instead. The launch path resolves the credential recipient and refuses to hand
anything over unless the operator confirmed that recipient for this launch. A rewritten
cloud.json then changes what the launch resolves, which no longer matches what the operator
confirmed, so the launch is refused with both values named. A substitution becomes something
the operator SEES rather than something that happens quietly. The confirmation does not come
from the file, is not persisted, and depends on no filesystem property.

What was deleted

The sidecar that preserved displaced bytes is gone, not guarded: the helper, its two
constants, its entries in four seal lists, and its sixteen tests. Both blocking review findings
on the previous head were defects OF that mechanism -- a preserved copy the write gate did not
cover, and a directory leaf no alias check validated -- so removing the code removes what they
are about. Answering them by adding two more names to a seal list would have been instances
nine and ten.

The write into the operator's file is gone entirely, which is the next section. config.py
retains only a reader, so there is no longer a state in which a product write has to choose
between overwriting an operator's bytes and refusing.

What was added

piece where
the recipient, rendered once fargate/taskdef.py::credential_recipient
what the operator is shown FargateConfig.credential_recipient()
what they confirmed POST /api/cloud/launch -> confirm_recipient
carried through unresolved engine_for(..., confirmed_recipient=)
the refusal FargateLaunchEngine.provision, first check

The recipient is the digest-pinned image plus the ARN of the secret that carries the
credential. Both, because both decide who receives it, and which secret that is comes from the
engine's own secret_destinations_for rather than from a name match. It is the exact strings
and not a digest of them: a fingerprint an operator cannot read is one they cannot refuse.

One renderer, not two. The confirmation is a comparison between what an operator was shown
and what a launch resolves, so two spellings would make it a comparison of the renderings.
FargateConfig.credential_recipient() delegates to the engine's function.

The comparison is against the SPEC, not against a re-read of the file. Resolving it from
cloud.json again inside engine_for would be the file confirming itself. The seam therefore
carries the operator's value through unchecked and unnormalised, and provision compares it to
what it is about to launch.

Refused before RegisterTaskDefinition, not only before RunTask. A revision is durable
in the account and carries the secret ARNs, so a confirmation checked only at run time would
already have written the recipient down.

A resumed launch job is refused. It carries no confirmation, because persisting one would
put the operator's answer on disk beside the file it is meant to be independent of, and a
rewrite of both would be silent again. A launch resumed after a gateway restart has to be
re-requested. That is a deliberate consequence, not an oversight.

The same move again: the launch's own state leaves the operator's file

Two review findings on the previous head shared one root, and the fix is C's own shape rather
than two local patches.

What they were. A malformed cloud.json let the deploy succeed -- billed -- and then the
post-deploy write raised, so the command aborted before sign-in and dashboard setup. And
between the witness re-read and the replace, a concurrent operator save could still be
clobbered.

Both are properties of writing launch-owned state into a hand-edited file. So that write is
gone. profile, region and last_tag live in cloud_launch_state.json, which the launch
path owns and nothing hand-edits. There is no post-deploy write into the operator's file to
refuse on, nothing of theirs to clobber, and no cross-process lock to hold -- the advisory lock,
its bounded acquire, its unusable-lock discard and both of its sandbox seal entries are deleted
with it.

cloud resume still re-attaches. An install that launched before the record existed has its
pointer in cloud.json, so LaunchState.load() falls back to those fields when the record
holds none. That fallback is read-only: migrating by writing would reintroduce the write being
removed, and it would write on a READ, so every cloud subcommand would touch the operator's
file. Once a launch has written the record, the record wins, so a stale pointer cannot outrank
the launch that happened and a tag destroy cleared stays cleared.

The record's own write is also non-fatal. wizard._record_launch swallows OSError, warns and
prints how to reach the instance, because every caller runs after its remote work and sign-in
matters more to the operator than a pointer kirocrew cloud list can rediscover.

The operator reads the recipient before confirming it

A confirmation the operator can only obtain by attempting a launch and reading the refusal is a
copy-paste ritual, not a decision -- they never see the recipient in time to recognise a wrong
image. So the resolved recipient rides on the DESCRIPTOR, which is the row a launch card is
drawn from and which GET /api/cloud/provisioners publishes as confirm_before_launch.

POST /api/cloud/launch then requires confirm_recipient exactly when the resolved row
carries a value. The requirement is DERIVED from the lane rather than hard-coded to one id, so
a client cannot reach a launch without having read what it must confirm, and the refusal echoes
the value so a stale client can correct itself. The engine still resolves and compares against
what it is about to launch, which is the check no caller can skip; the handler's exists so the
refusal arrives before a job file is persisted. The built-in EC2 lane carries no value and is
untouched: nothing in a configuration file chooses what its credential reaches.

The remaining step is the frontend renderer for the aws_fargate kind. Until one claims that
kind the dashboard skips the row, as the seam documents, so the value is published and demanded
but not yet drawn on the panel. That renderer is its own change; every piece it needs is in
place and tested.

No launch path answers 500

Three review findings were escape paths rather than wrong decisions: the check was in the right
place, its exit was not. A 500 tells an operator to file a bug; each of these has a remedy
they can carry out, so each now answers a coded 400 that names it.

condition code what the operator does
the row demands a recipient and the request confirmed none, or a stale one recipient_not_confirmed confirm the value the row publishes
cloud.json reachable under a second name config_alias_refused replace the link with a regular file, or break the extra link
the lane publishes a recipient its provider cannot receive lane_cannot_confirm the deployment's provider needs the current engine_for signature

The alias refusal stays where it is. It is raised where a launch consumes the file, which is
the placement the exposure calls for, and only its escape changed. The message already named the
file and the remedy; now it reaches the client instead of becoming a stack trace. It is also
answered under its own code rather than folded into unknown_provisioner, because telling
someone whose configuration is symlinked that the lane does not exist sends them to the wrong
thing entirely.

The seam keeps the keyword. confirmed_recipient is keyword-only with a default, so a
provider written against the older signature is still conforming -- and calling it with the
keyword raised TypeError, which escaped an except KeyError and became a 500. The call now
dispatches on the provider's SIGNATURE: one that accepts the value receives it, one that cannot
is called as it was before the keyword existed. Deciding by signature rather than by catching
TypeError is deliberate: an exception-driven retry cannot tell a binding error from a
TypeError raised inside the provider's own body, and retrying the latter would run half of it
twice.

A lane that declares a recipient while its provider cannot receive the confirmation is refused
rather than launched. Publishing a credential recipient and then being unable to accept the
operator's answer to it is the silent-substitution shape the confirmation exists to remove, and
launching would leave them believing they had confirmed something.

The launch record's read is bounded before it allocates

_read_document reads at most _MAX_FILE_BYTES + 1 and decides from that. Reading the file
whole and checking the length afterwards is not a bound -- the allocation has already happened
by the time the check can look at it, and the file does not have to be written a byte at a time
to be enormous, since truncate -s makes a sparse one instantly.

The extra byte is load-bearing and its own test initially could not prove it. Reading exactly
the ceiling makes the length check mean "the read stopped here" rather than "the file is longer
than this", so an oversized file whose first _MAX_FILE_BYTES bytes are a COMPLETE valid record
passes the check and is adopted -- a truncated prefix read as the whole document. A file at
exactly the limit is accepted either way, so asserting on that case was non-discriminating and
the mutation survived. The test now builds exactly that crafted prefix, and the code comment
states the real reason.

The alias refusal was only half-removed, and no test could see it

Removing the strict check from wrap_argv left the same behaviour reachable one function over.
_materialize_sealable_ceilings, which namespace_argv calls on every Linux sandboxed
spawn
, still ran _require_real_file_nofollow on an existing cloud.json -- so on the
primary sandbox platform a stow / chezmoi / rsync --link-dest host still lost every chat turn,
cron job and subagent, while this same commit's spec, comment and mutation row all said it
could not.

Both pinning tests were blind to it for one reason: they read source text. One AST-inspected
wrap_argv's own body; the other called the warn helper directly. Neither executes the path that
refuses, so both pass while the host is unusable. The replacement runs
_materialize_sealable_ceilings itself, with cloud.json as a symlink and as a second hardlink,
and requires it to return. Restoring the refusal reddens it -- two failures, one per shape.

A third test closes the shape of the miss rather than the instance: the strict FILE check's
callers must be exactly the two CONSUME seams -- require_unaliased_cloud_config and
require_unaliased_launch_state -- asserted over the whole module rather than per function. A
per-function check is what let a second call site survive a rename, and a spawn-path caller
appearing under any name fails this.

playwright-cli keeps main's own strict DIRECTORY rule. That is main's behaviour, not a
regression here, and it is outside this change.

The launch record is sealed, and that completes C rather than counting doors

Moving the tag out of cloud.json moved a power with it: the tag is what cloud destroy
resolves when no --tag is given, so an agent able to write the record could choose which of
the owner's stacks a destroy --yes deletes. Sealing the record is what finishes that move, not
one more patched bypass -- which is why it is added despite this PR otherwise adding no seal
names.

layer list
agent file-edit gate security.paths._WRITE_PROTECTED_HOME_PATHS
OS read-only seal sandbox._CREW_READONLY_LEAVES
absent-file pre-creation sandbox._CREW_PRECREATE_READONLY_FILE_LEAVES

It is deliberately NOT in the strict no-alias list, which is not the same as unguarded: that
list is walked where a spawn is prepared, so a leaf in it refuses every sandboxed spawn on the
host. The record's own alias refusal sits at its consume seam instead -- the next section.

Pre-creation forced one real change to the reader. The seal needs a file to bind to, so the
launcher writes {} where none exists -- and read as a record, that stub answers "no previous
launch" for every install whose pointer still lives in cloud.json, breaking cloud resume the
first time an agent spawns. The fallback is therefore keyed on the three KEYS being present
rather than on the document parsing: a {} stub is not a record and falls through to the legacy
fields, while destroy's record carries last_tag: "" and does not, so a cleared pointer stays
cleared. Both directions are mutation-covered.

An aliased launch record is refused where its tag is consumed

Sealing the record on three layers left one name uncovered, because every one of those layers
names a PATH: a symlink at the name, or a second hardlink to the inode, is reachable by a name
none of them matches. A write through it puts any tag in the record, and a destroy --yes
deletes the stack that tag names, with the data on it. launch re-attaching to a forged tag is
the same substitution one step quieter.

So the record gets what cloud.json already had, in the same kind of place -- the seam that
CONSUMES the file, never the spawn path:

cloud.json the launch record
refused by require_unaliased_cloud_config require_unaliased_launch_state
called from the provisioner seam, where a saved block becomes an engine LaunchState.load, the read every tag-consuming verb goes through
on the spawn path warns warns

Four parts of it are decisions rather than mechanics.

Not added to the strict no-alias list. That list is walked where a spawn is prepared, so a
leaf in it refuses every sandboxed spawn on a stow / chezmoi / rsync --link-dest host: the whole
box for one command's exposure, and the regression Design already blocked on this PR. A test
executes _materialize_sealable_ceilings with the record aliased in both shapes and requires the
spawn to proceed, so re-arming it reddens.

The same guard covers the LEGACY fallback. When the record holds nothing, load reads
cloud.json's fields instead -- and that file is then the source of the tag, so
require_unaliased_cloud_config runs before it is read. Guarding only the record left the identical
hole open through the old file, and not as an exotic case: cloud.json's own guard sits on the
LAUNCH seam (defaults.engine_for), which a teardown never runs, and the empty {} record the
sandbox pre-creates is the DEFAULT state on any install that has ever spawned an agent. So an
aliased cloud.json plus that default handed cloud destroy --yes a forged tag with no alias check
anywhere between the file and the deletion. clear_tag still reads both files unguarded, because it
runs after the stack is already gone.

The sibling sweep that finding asked for, by enumeration rather than by reasoning: three consumers
read the tag (wizard line 365, cli_cloud._resolve, cli_cloud._resolve_tag) and all three reach
the guarded load. Two readers touch the credential-selecting config -- engine_for, guarded at
the seam, and provisioners, which renders the recipient for DISPLAY. The display one is
deliberately not guarded and cannot deliver a credential: a launch from a forged display is refused
at engine_for, and if the alias is removed in between, the confirmation is compared against the
spec the launch actually builds, so a substituted recipient is refused rather than delivered.

The refusal takes the path being read, not a derived one, so the file checked and the file
consumed cannot be two different files. A test reads an alias-backed file while the crew home
holds an ordinary record; a derived-path guard passes every other test and fails that one,
because under a test that sets KIROCREW_HOME the two paths coincide.

clear_tag uses an unguarded read, deliberately. It runs after the stack has already been
deleted, so a refusal there would abort a command whose irreversible work is finished -- the exact
shape this PR removed from the post-deploy write. The guard is not skipped: it ran at the consume
point that produced the tag being cleared.

It is a named refusal, not an escaping exception. handle_cloud catches
SandboxCeilingUnsealable for the whole dispatch table, so every verb -- and any verb added
later -- prints the file, the shape and the one command rather than a traceback. Each strict leaf
supplies its own harm and remedy to the shared check, with no default, because a message naming
the wrong consequence sends the operator at the wrong file.

And the command is the operator's own platform's. The first version rendered
rm <shlex.quote(path)> unconditionally, which on Windows produced rm 'C:\Users\...': a
command that shell does not have, quoted in a way cmd does not use, for a file that does exist.
It reddened Backend Tests (Windows) (4) with four failures. sandbox._delete_file_command now
renders it:

platform command why that spelling
Linux, macOS rm <posix-quoted path> unchanged
Windows del "<path>" a cmd builtin AND a PowerShell alias for Remove-Item, so one spelling works in both shells; rm exists only in PowerShell, and a Windows path cannot contain " so no escaping question arises

The platform is a parameter with the host as its default, not only a read of IS_WINDOWS.
That is the actual fix for the shape rather than for the instance: this is the fourth
platform-axis defect in this PR, and all four were a string written once, verified where it was
written, and asserted as general. A renderer that only reads the host leaves its other branch
measurable on that other host alone, which is how this reached CI. Three tests follow from that:
both renderings asserted from one host, the refusal MESSAGE asserted with the flag forced so the
exact string a Windows operator reads is exercised here, and the platform-dependent assertion in
the original test now written per platform instead of POSIX-only.

The sweep that finding asked for, over every operator-facing string this PR adds to src/: one
hit, the rm above. Grepping the added lines for rm/cp/mv/ln -s/chmod/sudo/$HOME/
~///tmp/ returns that line and one docstring mention of $HOME that names no command. The
other refusals added here are platform-neutral prose (cloud.json's remedy names no command) or
product commands that are the same everywhere (kirocrew cloud list).

Every pin here EXECUTES the path. Three times in this PR a test that read source text passed
while the behaviour it named was wrong, so none of these inspect source: they call the read, and
one drives the destroy verb end to end with ec2.describe and ec2.destroy replaced by a raising
stub, so a refusal arriving late enough to describe or delete anything fails the test. Mutations:
7 of 7 red, baseline green before and after, failure counts 8 / 7 / 3 / 2 / 4 / 2 / 1.

One lock, for one read-modify-write, on all three platforms

clear_tag reads, compares and writes, so a launch recording its tag in between was overwritten
and the pointer to a live instance lost. record and clear_tag now take one advisory lock.

It uses platform_compat.file_lock, not flock_compat.flock. That shim exists to keep the
import graph loadable on Windows and its flock is a NO-OP there -- correct for the gateway
machinery, which never runs on Windows, and wrong for this file, because kirocrew cloud is
exactly what a Windows client runs. So the one platform where the shim did nothing is a platform
where both writers are live, and a destroy completing alongside a launch could let the clear
overwrite the new tag. The compat lock serialises on all three: POSIX through fcntl.flock,
Windows through msvcrt.locking on the lock file's first byte, which is why the lock lives in a
dedicated .lock file rather than on the record.

serialises notes
Linux, macOS fcntl.flock, exclusive polled acquire with a ceiling
Windows msvcrt.locking, first byte no shared mode; an exclusive lock satisfies both

A lock that cannot be taken RAISES rather than running the critical section unlocked. An
earlier revision logged and continued, which put clear_tag's read, compare and write back into
three steps exactly when the lock was unavailable -- the failure the lock was added for. Strict is
affordable here because every writer's caller already answers that OSError, and the two answers
differ on purpose:

writer when on a lock failure
wizard._record_launch after a confirmed deploy warns; the instance is reachable, the pointer is missing
wizard._clear_prior_pointer before provisioning aborts; nothing created, nothing billing
cli_cloud._cloud_destroy's clear after the stack is gone warns; the stale pointer is visibly stale

So a filesystem with no lock support degrades to "no pointer, with a warning", never to a failed
command and never to a silently overwritten pointer. That is the opposite call from the spawn-path
refusal this PR downgraded, for a concrete reason rather than a preference: there, strictness cost
every sandboxed spawn on the host and no caller was in a position to absorb it. Here three are,
and a test drives both wizard callers with the lock unavailable to show it.

This is not the stack deleted earlier in this PR. That one guarded the OPERATOR's file against a
person in a text editor -- a writer that takes no lock, which is why it needed a witness on every
replace, a bounded acquire and a livelock bound. Here both writers are Crew's own, both take this
one, and there are exactly two.

Pinned by three tests rather than by a comment: the lock is taken through the compat helper with
exclusive=True (observed at runtime, because the platform where the difference shows is not the
platform CI's POSIX shards run); the lock is really HELD during the critical section, proved by a
non-blocking acquire from a second file description being refused; and an unusable lock still
completes the write.

A failed pointer write can only leave "no target", never "the wrong target"

Letting a failed write warn and continue is only safe while the PREVIOUS pointer is already
gone. It was not. With kc-old saved, a --new launch that came up healthy and then hit ENOSPC
on the record write left the record naming kc-old while kc-new was the stack that existed --
and a later cloud destroy with no --tag resolves kc-old and deletes it. Irreversible, with
its data, and nothing on screen says the pointer is stale.

So the pointer to the previous stack is cleared BEFORE provisioning, and a failure there aborts
the launch. The two halves are opposites deliberately, and the reason is WHEN each runs:

when on a write failure why
_clear_prior_pointer before provisioning ABORT nothing exists and nothing bills, so an abort is free
_record_launch after the deploy confirms warn, continue the work is done and cannot be retried; a lost pointer costs a cloud list
destroy's clear_tag after the stack is deleted warn, continue same, and the stale pointer it leaves is visibly stale

That ordering is what makes the failure lossy instead of destructive: the worst reachable
outcome is a record with no tag, which cloud list settles. It is also the same move as the
decision this PR rests on -- remove the power rather than defend the write.

A declined clear aborts as well, and that took two attempts to get right. clear_tag is
conditional on the pointer still naming the tag this launch observed, and its False was being
read as success -- so when another launch had recorded tag B in between, this one provisioned
anyway, and a failed record write then left B saved while the new stack was the one that existed.
A no-tag destroy would delete B, someone else's live stack.

The first fix aborted on the bool, and four existing tests reddened. They were right: False
covers two states and only one is a hazard.

the clear declines because provisioning is so
another launch recorded tag B unsafe -- a failed write leaves B saved ABORT, naming B
there is no pointer at all safe -- that is the state the clear exists to reach proceed

The bool cannot tell those apart, so the decision uses the tag the compare actually saw:
LaunchState.try_clear_tag returns (cleared, saved_tag) from inside the SAME hold of the
writer lock. Reading the record again after the decline would answer about a file that can have
moved on between the two reads, and in a stubbed test it answers from the stub rather than from
the file the compare used -- which is exactly how the first attempt produced four false failures.
clear_tag keeps its bool contract, so its other caller is untouched.

destroy's own ignored return was re-derived by the same question rather than left as an
omission: a decline there means the pointer names the concurrent launch's live stack, which is
the correct pointer for it, and nothing follows that line but the success message. The comment
now says that.

A sweep for the same shape across this PR: every bare-call statement the diff adds to src/ was
enumerated from the diff and its callee's return type checked. Two call sites discard a real
bool, both clear_tag -- the launch one, fixed here, and destroy's, correct and now justified in
place. Four others flagged by name (ui.fail, LaunchState.record, _audit) return None; the
flags were collisions with same-named functions in other modules.

One mutation survived the first sweep and earned a test: returning "" instead of the saved tag
from a declined compare passed everything, because the wizard test stubs that method. Four tests
now drive the real one, and the abort test asserts the deploy function was never invoked rather
than only the exit code.

Four tests drive the real launch() against a real record on disk, because the property is about
what is on disk at two different moments and a stubbed LaunchState cannot show it: the finding's
own scenario end to end (rc 0 AND the pointer empty rather than kc-old, so fixing this one does
not undo the previous one); a failed clear aborting with the deploy stub set to raise if reached
and the pointer unchanged; the ordering observed from INSIDE the deploy; and a resume not clearing
a pointer that is still correct.

destroy's own semantics are unchanged. Corroborating the saved tag against live stacks
before a teardown would add a further layer, but both reachable routes to a wrong pointer are now
closed -- an aliased record is refused where the tag is consumed, and the prior pointer is cleared
before a new stack exists -- so it is a separate decision rather than part of this fix. Recorded
in local backlog as f-20260919-02 with that reasoning, not as a public issue.

Nothing after the irreversible AWS work can fail the command

destroy cleared the saved pointer after ec2.destroy confirmed the stack gone, so a full or
read-only disk raised OSError and the CLI exited non-zero with a traceback -- while the stack
really was deleted. Automation reading that exit code concludes the teardown failed, and the AWS
work cannot be retried. The clear now warns and the command still reports the removal; what is
left behind is a stale pointer, which cloud list settles.

This is the same decision wizard._record_launch already makes on the launch side, one function
over, so the whole path was swept rather than waiting for the next round to name the next
instance. The result of that sweep:

post-AWS-work write state
LaunchState.clear_tag after a confirmed teardown fixed here
wizard._record_launch after a billed deploy already warns and continues
connect.register_instance after a deploy its whole body is already inside except Exception and logs
connect.unregister_instance after a teardown same, already non-fatal
source.delete_source after a teardown already wrapped at the call site, with the manual cleanup command printed

So one fix, and four writes measured as already safe rather than assumed to be.

Known limitation, scoped separately

cloud.json keeps its write-protection entry as defence in depth rather than as the property
this design rests on. The crew-home leaf-seal mechanism those entries use is per-leaf and
shared by every governance leaf, so strengthening it is a change to all of them and belongs in
its own review rather than in this lane's PR.

Two advisory findings, fixed as a deletion and a sentence

The launch record's module docstring opened by saying "no read of it feeds a security decision",
which is the opposite of the destroy-target check further down the same file. That is not a
cosmetic mismatch: a comment asserting the inverse of a security property is what hid the Linux
spawn refusal for a whole round of this review, and it is what a future maintainer would cite
when removing the guard. It now says a read selects the default destroy target, which is why
the file is sealed and an alias-backed copy refused.

_PROVISIONING_WRITES reserved ingest room for fields the launch path used to write back into
cloud.json. Nothing writes that file now, so the reservation described work no production code
performs. Deleted, with the one test that asserted on its contents. Checked before deleting
rather than after: it had no reader in src/, its only references were three lines in that test,
and both length constants it derived from keep other users (_TAG_MAX_LEN in _TAG_RE,
_MAX_STRING_LEN in three validators), so no orphan is left behind. Net for this round: 17 lines
added, 47 removed, across three files, and the mutation sweep still reports 25 of 25 red with a
green baseline -- no behaviour moved.

A sweep over the prose, not another two fixes

Thirteen pushes of design change left comments describing designs that no longer exist, and
fixing them one finding at a time produced a fresh pair every round. So this pass takes the
class: every comment and docstring the diff adds was enumerated from the diff itself, filtered
to sentences ASSERTING something (refused, sealed, safe, unsealed, locked, never written, no
security role), and each hit read against the code beside it. 369 candidate lines across 20
files; the ones that were actually wrong all described a mechanism this PR MOVED, which is where
prose goes stale:

claim where what the code does
"the ONE place an aliased strict leaf is refused is decided" wrap_argv it WARNS; the refusal is at the two consume seams. The block also contradicted itself -- its last paragraph already said "warns here"
"what makes cloud.json safe to leave unsealed" FargateLaunchSpec.confirmed_recipient the file IS sealed; the confirmation is what keeps that seal defence in depth rather than load-bearing
"no read of it feeds a security decision" launch record module docstring a read selects the default destroy target (corrected in the previous push)
"cli_cloud and the provisioner selector both call CloudConfig.load()" the seal-list entry cli_cloud reaches it through the launch record's legacy fallback now; the direct callers are the selector and that fallback
a reference to _require_real_file_nofollow on the spawn path same wrap_argv block that path calls _warn_if_alias_backed

Two claims that LOOK like the same defect were checked and left, because they are true:
_warn_unsealed_ceiling's docstring says the spawn is being refused, and both its callers raise
on the next line; _warn_aliased_strict_leaves says it reports without refusing, which is what
it does.

Every function-local import the PR adds now carries the # circular import annotation the
convention requires -- six imports in three places in platform/defaults.py. The reason is
MEASURED rather than asserted: importing any of cloud.fargate.identity,
cloud.fargate.runtask, cloud.fargate_engine, sandbox, cloud.config or
cloud.launch_engine already puts kiro_crew.platform.defaults in sys.modules, so a
module-scope import in that file closes the loop in every case. One annotation drops a module
count I had only measured loosely, since an unverifiable number in a comment is the same defect
class this sweep exists to remove.

Comments only: the mutation sweep still reports 25 of 25 red with a green baseline, so no
behaviour moved.

The reds on this branch, and who owns each

Five lanes are red and none of them is a defect in these files. Each is attributed by name,
measured against kirocrew/main rather than asserted:

lane owner
macOS Backend Tests (1) #11884 -- main's #11825 ships a login-dir guard test that refuses on the runner; the test and cloud/login.py are byte-identical to main and no login file is in this diff
macOS Backend Tests (3) #11918 -- test_theme_install.py case-variant ancestor test; byte-identical to main, no theme file in this diff
macOS Backend Tests (2) test_platform_log_append.py::test_concurrent_short_writers_serialize, FileNotFoundError: day.jsonl. It ran off the merge ref before the rebase -- the file was not in the branch at all -- and after it the file is byte-identical to main and no log module is in this diff. Re-measured on the rebased head; if it recurs it is main's and gets its own issue, since no issue names that test or day.jsonl
Coverage Combine, and Coverage Gate downstream of it #11925 -- coverage xml refuses a source path inside the AppImage mount that test_agent_home_isolation.py:448 creates and unmounts; the file is byte-identical to main and Combine is skipped on most runs, which is why it sat latent
Security Scope Review, and its candidate validation #11767 -- the reviewer's own candidate set carries ARN-shaped strings because this change's vocabulary IS task ARNs, secret ARNs and account ids, so the publish gate refuses it. No change to this branch clears it

Two shard failures that WERE this branch's are fixed rather than attributed:
test_cloud_login_target.py::TestWizardTargetCompletion::test_assume_yes_without_region_refuses_instead_of_builder_id
patched a name the writer deletion removed, which is one defect that showed up on three
platforms (3.12 shard 4, Windows shard 4, and macOS shard 1). Coverage Gate was failing closed
downstream of those shards rather than on its own coverage reading.

The two macOS failures were confirmed deterministic rather than intermittent by finding them
byte-identical on an unrelated branch: run 35408578148 on feat/schedule-once-autonudge, same
test ids, same assertions, same counts (1 failed / 38587 passed and 1 failed / 37442 passed).
A second identical failure on a foreign head is stronger evidence than a re-run on this one, so
no re-run was spent.

What remains mine, and what does not

item owner
every code finding raised so far mine, done, each with a red mutation
the two blocking findings on the previous head CLOSED by deletion: the mechanism they were defects of is gone
the credential recipient mine, done: resolved and confirmed at launch, mutation-covered
the shared leaf-seal mechanism scoped separately, one sentence above, not this PR
the four reds in the table above their named issues, not reachable from this branch

Backward compatibility

Adding the aws_fargate id is not a break

engine_for's contract is to raise KeyError for an id not in provisioners(), and both
sides are gated on the SAME predicate rather than on two conditions that agree today:

provisioners():  append the Fargate descriptor   iff _fargate_config() is not None
engine_for():    raise KeyError for that id      iff _fargate_config() is None

So an id is in the list exactly when an engine exists for it, in both directions. An install
with no fargate block gets the built-in descriptor alone and a KeyError for the new id,
which is byte-identical to today. No caller could previously pass the id successfully, so
nothing that worked stops working, and the built-in aws_ec2 path is untouched.

One honesty note on the strength of that claim: _fargate_config() is read PER CALL, so an
operator deleting the block between a provisioners() call and an engine_for() call sees
the id listed and then refused. That is the intended answer -- the lane really is gone, and
the handler reports unknown_provisioner -- and per-call reads are deliberate so an edit
takes effect on the next request rather than the next restart.

Two changes ARE backward incompatible, on purpose

cloud.json becomes sealed. It moves from agent-writable to write-denied inside the
sandbox, so anything that used to write it from a sandboxed process now fails. That is the
point of the change: the file selects the container image a Fargate launch runs, and the
task's execution role delivers the model credential into whatever image is named.

An alias-backed cloud.json or launch record refuses the command that consumes it. A host
that deployed its config as a symlink -- GNU stow, chezmoi, or an rsync --link-dest snapshot --
keeps spawning sessions normally, because the spawn path WARNS. What refuses is a Fargate launch
reading that config, and any cloud verb reading an alias-backed launch record.

Stated as an upgrade note, because the population that hits this is upgrading rather than reading
a diff. An earlier revision of this branch did refuse on the universal spawn path, which failed
every chat turn, cron job and subagent on such a host; that is the regression Design blocked, and
it is gone. Both refusals fire on a symlink and on a file with more than one hardlink, name the
file, and carry one command, rendered for the platform the operator is on. For the launch record
that command removes the file, because it holds a pointer the product rebuilds and cloud list
finds the instance again. For cloud.json the bytes are the operator's, so the alias is replaced
rather than removed -- reading through a symlink and giving a hardlink a new inode covers both
shapes at once:

POSIX:

cd <config dir> && cp -L cloud.json cloud.json.real && mv cloud.json.real cloud.json

Windows (cmd; copy follows a link and writes a new file):

cd <config dir>
copy cloud.json cloud.json.real
move /y cloud.json.real cloud.json

An install with no cloud.json at all is unaffected: the precreate rule makes a plain empty
file, which satisfies the requirement by construction. The four mechanisms this rides on, and
which agent action each one closes, are the table under "What changed" above.

That refusal is the wider blast radius of the two and it was taken deliberately, so the
reasoning belongs here rather than only the behaviour. Both candidate designs fail; they
differ in HOW. Refusing fails LOUDLY: the operator finds out immediately, the message names
the file and the remedy, and one command fixes it. Exempting the alias fails SILENTLY:
nobody finds out, and what happens instead is a model credential delivered into an
attacker-chosen image. A loud break the operator can fix beats a silent compromise they will
never notice, so the refusal reads no file contents at all -- contents are what an attacker
supplies, and any rule that reads them has the same hole.

A gentler shape exists and is NOT built here: seal a copied snapshot rather than failing the
spawn. It changes what an in-sandbox reader sees, which is a behaviour change deserving its
own review, so it is recorded as a follow-up instead of folded in beside a security fix.

One thing that looks like a third break and is not

ConcurrentEditRefused reaching callers that never handled it was not a deliberate
incompatibility. It is the defect this PR fixes, and the fix removed the write rather than
narrowing the refusal: no caller writes the operator's configuration at all now, so there is no
refusal for one to mishandle.

Tests

A green review lane is not a clean review

Worth stating for anyone reviewing this line, because it is the most reusable thing
this PR turned up. On the previous head, all five AI review lanes concluded
success while carrying four real findings in their comment bodies
-- Design and
First Principles as advisory CONCERNS, GPT under "no blocking findings" with two
FINDING lines inside a collapsed <details>. Every one of the four was verified
reachable against live code and every one is fixed here:

Finding Lane(s), all concluded success Real defect
A Design load() collapsed an incomplete block to None while save() re-emitted asdict, so an unrelated EC2 launch wrote "fargate": null and destroyed a half-written block
B Design, First Principles the config.py docstring claimed a taskdef drift pin that did not exist anywhere in the tree
C First Principles, GPT 5.6 is_complete() never demanded the model-credential secret, so "secrets": [] registered a lane the engine refuses on every launch
D GPT 5.6 bool(data.get("assign_public_ip")) read the string "false" as true

Reading only the check conclusions on that head would have reported a clean review
and shipped all four.

Automated coverage

test/test_cloud_config.py::TestFargateConfig -- the boundary. A complete block is
read; a non-dict block, a non-list secrets, a secret entry that is not a two-string
pair, an empty name or ARN, a movable-tag image, an unknown CPU architecture, a block
naming no model-credential secret, a block whose secrets exist but none named for the
credential, an assign_public_ip given as "false", "0", "true", 1 or null,
and each missing required field all read as None. A boolean flag is read as written,
an absent one defaults to False, and the credential gate is shown to read only the
secret's name.

test/test_cloud_config.py::TestRespelledConstants -- the drift pin, which is what
makes the docstring's claim true rather than aspirational. _CPU_ARCHITECTURES,
_DIGEST_IMAGE_RE.pattern and _MODEL_CREDENTIAL_ENV are held equal to
taskdef.CPU_ARCHITECTURES, taskdef._DIGEST_REF_RE.pattern and
taskdef.MODEL_CREDENTIAL_ENV, and a further test asserts cloud/config.py does not
import the engine -- the constraint that forces the respelling in the first place.

test/test_cloud_config.py::TestCloudConfigIsSealedAgainstAgentWrites -- the seal.
An agent may not write cloud.json under either crew-home prefix, it stays readable,
and the gateway can still save it. A positive control asserts an unprotected sibling
leaf under the same home comes back writable, so the class cannot pass vacuously
against a predicate that answered True for everything.

test/test_cloud_config.py round-trip cases -- an incomplete block, and each
malformed block shape, survive a load-mutate-save that changes only last_tag.

test/test_remote_provisioner_seam.py::TestFargateLane -- the lane. Unconfigured
offers only aws_ec2 and raises KeyError for aws_fargate; a complete block offers
both ids and builds a FargateLaunchEngine whose spec carries the block's placement,
image, secrets and architecture; an incomplete block offers only aws_ec2; a block
missing only the credential secret also offers only aws_ec2; deleting the file
after a complete read drops the lane again; the aws_ec2 lane still returns
RealLaunchEngine throughout; and importing kiro_crew.platform does not pull in
kiro_crew.cloud.config, so a future module-level import fails here rather than at
gateway start.

The existing seam test asserting the core composes exactly
DefaultRemoteProvisionerProvider is unchanged and still passes -- that is the point
of amending the provider in place.

Mutation matrix

Fourteen mutations for this revision, each reverting ONE behaviour it adds. The unmutated
baseline runs first and the sweep aborts if it is not green, restores come from a file copy
taken before the first mutation, and every row asserts its anchor applied exactly once so a
moved anchor reports NOT-APPLIED instead of a false kill. 14 of 14 red, and two later
rounds of review fixes add 9 of 9 and 10 of 10 on the same terms.

One row of the last batch reported NOT-APPLIED rather than red, and the reason is worth keeping:
its anchor was a 12-space-indented call line, which is a SUBSTRING of the 16-space-indented
identical call in the sibling loop, so it matched twice and measured nothing. Re-anchored on the
comment sentence only the intended branch carries, it reddens.

# mutation result
N1 the legacy pointer is not read, so an existing install loses resume RED
N2 the legacy fields outrank the record, so a cleared tag comes back RED
N3 the record is migrated by WRITING, so a read touches the operator's file RED
N4 a malformed tag is carried into the resume path RED
N5 destroy clears the pointer unconditionally RED
N6 the other fields are dropped when the tag is cleared RED
N7 a record that cannot be written aborts the billed launch RED
N8 a FAILED deploy records the tag anyway RED
N9 the descriptor stops carrying the recipient RED
N10 the published list drops the field RED
N11 the handler stops requiring what the row declares RED
N12 the handler requires it but does not say what to confirm RED
N13 the spawn path refuses again, failing every spawn on an aliased host RED
N14 the consumer stops refusing an aliased config RED

The twelve rows for the credential confirmation itself were measured on the previous head and
still hold; the engine's gate and its tests are unchanged by this revision.

The gate asks the engine instead of copying it

First Principles was right that the respelled-constants premise was void, and the
measurement backs it: importing kiro_crew.cloud.config executes cloud/__init__.py,
which imports cloud.aws and pulls kiro_crew.sandbox -- 401 modules and 245 ms
before this module exists. Adding fargate.identity and fargate.taskdef on top costs
5 modules and about 4 ms, and identity imports only the standard library, so there
is no cycle and no weight argument for a copy.

So all five copies are gone. _names_model_credential now calls
identity.secret_env_name, and the architecture set and digest rule read the engine's
own values through small helpers. TestRespelledConstants and the three per-constant
drift pins went with them: there is nothing left to drift.

That also retires a defect that recurred three times, because each round fixed the
spelling that had been reported while the check remained an approximation:

Round Accepted here, refused by the engine
1 "secrets": [] -- no credential secret at all
2 a bare KIRO_API_KEY, and a wrong-prefix junk/KIRO_API_KEY
3 seven crew spellings -- uppercase, leading or trailing hyphen, underscore, non-ASCII, over-length

Delegating makes agreement structural rather than tested: no spelling can pass here and
fail at launch, because it is the same function deciding. The 180-combination probe now
confirms a tautology, and one earlier test had to invert -- a conforming NAME with a
mismatched ARN used to register on the argument that the pairing was the engine's job.
It no longer does. The boundary moved rather than being duplicated: still one copy of
the rule, and it now runs at config time too.

An aliased cloud.json is refused where a launch CONSUMES it

An alias defeats both seal mechanisms -- a read-only bind seals a mount, a Seatbelt
deny file-write* matches a pathname, and in each case the alias reaches the same inode by a
name the rule does not cover. So the refusal stays, and it is unconditional on content: an
agent with a writable alias does not need to swap a block it can create.

What changed is WHERE it fires.

before now
universal spawn path (wrap_argv) refused warns
where the block becomes a launch (engine_for) nothing refuses

Refusing on the spawn path failed EVERY sandboxed spawn on the host -- a chat turn, a cron job,
a subagent -- when cloud.json carried a second name. That is the shape an install laid down by
stow, chezmoi or rsync --link-dest has, for reasons with nothing to do with Fargate, and it
made the whole box unusable over one lane's exposure. The alias harm is a refused launch either
way, so that is what it now costs. The warning stays on the spawn path, because a log claiming
a seal that is reachable under another name is worse than the hole.

This does not weaken the load path's own rule. The earlier decision that a loud break beats a
silent compromise was about what happens when the configuration is READ for a launch, and that
is exactly where the refusal now lives.

Every secret is validated, not just the first that matches

_names_model_credential returned on the first reference whose destination was the
credential, so a valid credential ref sitting beside a malformed or cross-crew one
registered the lane and the engine then refused the whole document at launch. It now runs
the engine's own secret_destinations over ALL references and sole_binding over their
ARNs, so a set naming two crews, or containing an unusable ref, leaves the lane
unregistered. A same-crew sibling still registers.

A partly-malformed placement list voids the block

_bounded_string_tuple filtered non-string members out, so a subnet list with one bad
entry launched the task in whichever subnets survived -- a placement the operator never
wrote. One bad member now voids the whole block, exactly as one bad secret entry does.

Pattern harvest: every finding on this PR was a class, and I kept patching instances

The most useful thing this PR learned, recorded because the next person editing
config.py needs it more than any individual fix. Three defect classes each came back
two or three times, in a different field or a different line, because each round fixed
the instance that was reported:

class first seen came back as
coercion makes a falsy JSON value truthy bool() on assign_public_ip read "false" as true str() on cluster turned false into "False"
load() and save() disagree about a bound save() could write what load() would refuse load() measured the compact form, save() emitted a larger pretty one
a comment claims a guarantee nothing enforces a docstring described a parity test that did not exist a docstring and cloud.md said only a secret's NAME is judged
the gate accepts what the engine refuses secretless block registered a lane bare name, then seven crew spellings, then a cross-crew reference
one rule restated per platform path Linux refused an aliased leaf, macOS did not both launchers refused it, the delegated spawn still did not
a refusal raised where it cannot be handled a size crash out of save() after the deploy a lock open(), then a stale-write refusal, in the same place

Rule candidate: a rule with two implementations has no implementation. Every finding
above is two pieces of code encoding the same rule and drifting, not a missing check or a
wrong constant. The fix is never to correct the copy; it is to delete it, so the check and
the thing it checks are the same code executing.

Its counterpart for tests, learned the hard way three times on this PR: a comment must
not be able to satisfy an assertion about behaviour.
A test that searched the source
text for a call name passed after the call was deleted, because the explanatory comment
beside it contained the name. Match real AST call nodes, not text. Two other tests here
passed for adjacent reasons -- one let load() drop the block it was meant to preserve,
and one measured a fixture that never reproduced the defect -- and in each case a mutation
staying green was the only thing that revealed it.

So each is now fixed once, where the class lives, not once per field:

  • No string-typed field is coerced, and the field list is DERIVED from the dataclass, so
    a string field added later is covered without a new branch. A test pins the derivation
    against fields(FargateConfig).
  • One function turns a record into text, and both load() and save() use it, so they
    cannot disagree about what fits.
  • The credential gate CALLS the engine's secret_destinations and sole_binding instead
    of approximating them.

The alias refusal is one decision, not one per platform

require_unaliased_cloud_config() is a single function both platforms reach, because the
refusal is a fact about the NAME and never depended on the sealing mechanism. A copy inside
each launcher would only give the two platforms something to drift on, which is how the macOS
branch came to skip the check while Linux applied it.

It reads no file contents at all -- lstat only -- so there is no encoding to bypass and
nothing to keep in step with the parser. An absent file costs nothing: the check returns on
FileNotFoundError.

A delegated spawn is covered by refusing the SPAWN, not by sealing the file

A delegated spawn is confined by kiro-cli's own sandbox and Crew wraps nothing, so no seal of
ours holds there and the layers cannot nest. Two designs were tried and discarded before the
right one, and both failures are worth keeping because they are the argument for the shape that
worked.

Declining delegation when a Fargate block is configured was the first, and it is bypassable for
a reason already established on this change: an agent does not need to swap a field it can
CREATE, so with no block it writes a complete one. Any rule reading current contents has that
hole whatever the contents are. Declining delegation unconditionally was the second, and it is
not this change's to make: on macOS it wraps a kiro-cli spawn in Crew's seatbelt while kiro's
own sandbox is enabled, which the codebase states fails to initialize nested; on Windows there
is no Crew backend, so it refuses every session rather than this feature's.

The mechanism that fits already existed. delegated_workspace_exposes_sealed_target refuses
a delegated spawn whose workspace IS, CONTAINS or sits INSIDE the sealed kiro agents tree,
because Crew's launcher rule cannot reach a delegated child and refusing the spawn is the only
enforcement point left. That is the same category of rule with the same bypass, so the config
leaf joins its target list: the guard gained one entry and a per-target reason, and nothing new
was invented.

Three properties make this the right shape rather than a fifth patch:

  • It reads no contents. The refusal is the same whether the file is absent, empty, or holds
    a complete block -- pinned by a parametrized test over exactly those three.
  • Its blast radius is almost nothing new. A workspace containing the data home is, on a
    delegated platform, usually a workspace containing the agents directory as well, and those are
    already refused today. What is newly refused is a workspace that contains ~/.kiro/crew but
    not ~/.kiro/agents.
  • It scales to the other ceilings without another decision. The list is the strict no-alias
    leaves, so the twelve sibling governance ceilings could join it by being added to that tuple.
    They are NOT added here: their exposure is main's, not this change's, and strengthening the
    shared mechanism is the separately-scoped change noted above.

The list-shaped derivation had a shape-shaped hole, and that is the part worth reading. The
guard built its targets from the strict no-alias FILE leaves alone. A leaf sealed as a DIRECTORY
is not reached by a derivation over the file leaves, so such a leaf is uncovered with nothing
saying so, and no number of entries in either list closes it. The targets now come from one
mapping keyed by BOTH lists, with a module-level assert that the mapping and the two lists cannot
drift in either direction, so the next sealed leaf of either shape is covered by construction
rather than by someone remembering. The per-target wording comes from that same mapping, because
a lookup keyed by one list rendered the other list's consequence for any member it did not know.

That covers one leaf that is not mine: playwright-cli, already a strict no-alias directory on
main. The incremental refusal is nil in practice -- a workspace over the crew home is refused by
cloud.json already, so the only newly refused case is a workspace that IS that directory or
sits inside it, which holds an executable the gateway runs and is why it is sealed. Leaving it
out would have meant re-creating the hole one member over.

path cloud.json writable by an agent?
Linux namespace no -- read-only bind
macOS seatbelt no -- pathname write denial
delegated spawn, workspace clear of the data home no -- nothing there to write through
delegated spawn, workspace over the data home the spawn is refused

A record too deeply nested to serialize is refused at ingest

json.loads accepts nesting json.dumps cannot emit, so a hand-edited fargate value can
parse cleanly and then raise RecursionError on the way back out. The depth that breaks is
not a property of the document: the limit is on total stack, so the same value serializes
from a shallow caller and raises from a deep one. There is therefore no depth to validate
against, and only attempting the serialization can answer.

Both sides of the boundary answer it, which took two rounds to get right: the WRITER side
first, and then the reader. json.loads fails on documents that never become objects at all,
and it does so through three different exception types -- a decode error, a JSONDecodeError,
the interpreter's integer-string limit raising plain ValueError on a 5,000-digit number that
is valid JSON syntax, and a RecursionError on depth it accepts less of than it can build.
Naming those one at a time is what lets one be missed, so the read answers the whole class:
anything that cannot become a document reads as defaults, which is the same answer every
caller can act on. JSONDecodeError is a ValueError, so that is a widening rather than a
replacement.

Answered where the ceiling is answered, in the one place a record becomes text, and
reported as "does not fit" rather than raised. That puts the refusal at ingest, before
anything is provisioned, instead of in a save() that runs after the deploy and is the call
that records the new instance.

Refused at the boundary, in other words, but the question "can this be written" is answered
by ASKING THE WRITER rather than by a depth limit of my own. A depth limit would be a second
shape rule free to drift from the serializer's real one, and it could not agree with it even
in principle: the serializer's limit is on total stack, so the same document is emittable
from one call site and not from another. The only thing that can answer for the writer is the
writer.

Nothing in the product writes cloud.json

The launch path's own profile, region and tag live in cloud_launch_state.json, a file it
owns. config.py has no writer left at all: no save(), no apply_update(), no
_writer_lock, no _merge_once, no precondition plumbing, no ingest reservation for what a
write-back would add. Roughly 550 lines of it are gone, and so are both cloud.json.lock
entries in the sandbox seal lists, because the lock existed only to serialise that write.

cloud.json cloud_launch_state.json
written by the operator the launch path only
read for the fargate block; the legacy pointer profile, region, last_tag
product writer none LaunchState.record / clear_tag
lock none needed none needed, one writer
sealed against agent writes yes, defence in depth no, deliberately

The property is asserted on the module rather than on one path: no function in config.py
calls a writing primitive, read off the call expressions so a runtime-built spelling cannot
pass. Two reviewer findings on the previous head were both about what that writer had to do
when the operator's file was not in a state it could use, and there is now no such moment.

The record is not sealed, deliberately. It carries no input to a security decision.
fargate.image is the field that chooses which container receives the model credential and it
stays in cloud.json; this file holds a pointer, and every command acting on that pointer
describes what it found first -- destroy prints the tag, describes the instance and asks
before deleting anything.

The pointer belongs to the stack it names

destroy clears last_tag only while it still names the stack being deleted, so
LaunchState.clear_tag(expect) compares before clearing and answers whether it did. Cleared
unconditionally, a launch that recorded its own tag between the delete and the clear would have
its pointer wiped by a command that never saw it, and the operator's new instance would look
unlaunched. Only the tag is cleared: the profile and region still name where their other stacks
live.

There is no lock around that compare, and that is the simplification this file buys. Both
writers are product-side commands a person runs one at a time, and the value at stake is a
pointer rather than a configuration -- kirocrew cloud list enumerates the real stacks, so a
pointer lost to that window is rediscoverable. Bytes an operator hand-wrote are not, which is
why the same reasoning did not apply while this lived in their file.

The same question asked at the seal's boundary

Two of the findings are one question: the seal names a file, and both of them reach that
file's effect without touching that name. So the answer is the SET of ways this document can
be written, replaced, or have its write BLOCKED, and what covers each:

route covered by
write to cloud.json read-only bind (Linux) / deny file-write* (macOS), plus the alias refusal above
rename another file onto it the same name rules: a rename onto a bind mount fails, and Seatbelt's rule is on the destination path
write it through an alias of that name the alias refusal, on every path including delegated
write it from a delegated spawn NOT covered by Crew; recorded above
break the lock so the write cannot happen the lock is not trusted: O_NOFOLLOW, replaced when it is not a lone regular file, and the write proceeds without it rather than failing

The lock is the interesting row. It cannot join the read-only seal, because taking a lock
needs a writable descriptor, so a leaf sealed read-only would break locking on the very
platform that seals hardest. The answer is therefore not another rule about its name but
removing the dependence on it being trustworthy at all.

One red on this branch is not this branch's, and is not fixed here

Backend Tests (Windows) (7) fails
test_snapshot_absent_vs_wrong_type.py::TestTheRollbackDirectoryBelongsToOneRestore::test_a_second_allocation_in_the_same_second_gets_its_own_directory.
It is a pre-existing clock race in the TEST, and it is left alone deliberately: an
unrelated test fix inside a feature change makes both harder to review.

The test allocates two rollback directories and asserts the second's name starts with the
first's. That only holds when both land in the same UTC second, which the test's name
claims and its body never arranges -- it calls the allocator twice and hopes. On a slow
runner the second boundary is crossed in between, and the second allocation gets a fresh
timestamp instead of a suffix.

Verified by driving the clock rather than by re-running until it flaked, which is why the
answer is definite:

| both allocations at ...043200Z | pre-restore-20260918T043200Z-2 | assertion holds |
| second at ...043201Z | pre-restore-20260918T043201Z | assertion fails |

The second row reproduces CI's observed name exactly, and the same two runs on pristine
origin/main (420efd1a17) produce the same failure with snapshot.py and the test file
byte-identical to this branch's. This change touches zero snapshot, restore or rollback
files. _allocate_rollback_dir is correct in both rows: a different second already yields
a distinct directory, which is all the production code has to guarantee. Only the
assertion depends on which row happened.

A fix belongs in its own change: freeze the clock across the two calls, or assert the
property that matters (the two directories differ) instead of the naming coincidence.

One finding deliberately not taken

First Principles also asked to delete the size bounds (_MAX_FILE_BYTES,
_MAX_LIST_ITEMS, _MAX_STRING_LEN and the save() refusal), arguing they defend
against an actor outside every boundary the codebase names. That is a fair premise-level
argument, and it is the direct opposite of what the GPT lane blocked on: those bounds
exist because that lane raised the unbounded read as a security-class finding. GPT is a
hard gate and First Principles is advisory, so the bounds stay and the disagreement is
recorded here rather than resolved by quietly following the advisory lane. If a
maintainer prefers the subtraction, it is one commit and this note is the argument for
it.

The credential gate had to match the engine's whole name grammar

Three rounds of review found the same defect in this one check, each time in a
different spelling, because each fix addressed the spelling that had been reported:

Round Accepted here, refused by the engine
1 a block with "secrets": [] -- no credential secret at all
2 a bare KIRO_API_KEY, and a wrong-prefix junk/KIRO_API_KEY
3 seven crew spellings -- uppercase, leading or trailing hyphen, underscore, non-ASCII, over-length

Every one registered the lane and then refused at launch, which is the exact state
this PR claims to prevent, reached from inside the check written to prevent it. So the
gate now respells the engine's whole name grammar -- prefix, crew pattern, variable --
each pinned to its original, and the property test runs a 180-combination product of
prefixes, crew spellings and keys through identity.secret_env_name itself rather
than restating the rule. Measured: zero names accepted here that the engine refuses.
A hand-picked list is what let this recur, so the test is a product.

The engine resolve moved off the event loop

_engine() was called directly in api_cloud_launch_create while its sibling store
calls in the same handler are await _in_executor(...), one of them commented "so a
slow disk can't stall the gateway's other requests and its heartbeat behind it". That
was harmless before this PR, because resolving the built-in id constructs an engine and
reads nothing. This PR made the resolve read cloud.json, so the blocking read is
this change's to fix, and it now goes through the executor like its siblings.
Two rows initially came back ANCHOR AMBIGUOUS rather than
green or red, because a text anchor matched several tuples; the harness refused to
mutate instead of scoring them, and they were redone with tuple-aware removal that
names the assignment. An anchor that silently stops matching is how a matrix prints
zero holes while verifying nothing.

cloud.json is also added to test_sandbox_governance_mask.py's KEYSTONES, which
asserts the OS-level seal per crew-home prefix and per sandbox mode: 12 cases covering
the Linux read-only bind (present in readonly, absent from hidden) and the macOS
seatbelt denials for file-write* and file-link, the latter being the hardlink shape.
That list names paths individually on purpose -- a test derived from the same tuple the
production code reads would keep passing after someone emptied it.
The fifth row is there because the first run of this matrix
found a genuine gap: _complete_block had been corrected and a comment described the
property, but no seam test asserted it, so dropping the requirement passed the seam
suite untouched. That is the same shape as finding B -- prose asserting what no code
enforces -- one layer up, and it was the matrix rather than review that caught it.

Suite runs

On the rebased tree: the two touched suites plus test_yaml_safe_loading.py -> 67
passed. The whole test/test_cloud_*.py surface including test_cloud_wizard.py and
test_cloud_cli.py, which exercise the load-then-save callers this change affects ->
668 passed. flake8, black --target-version py310, isort --check-only,
scripts/check_black_formatting.py, scripts/check_comment_history.py (gated with
COMMENT_HISTORY_BASE_REF=origin/main), scripts/check_brand_name.py and
scripts/check_subprocess_encoding.py all clean.

Manual verification

N/A -- no AWS call and no UI surface is reachable from this diff. The lane's whole
observable behavior is which ids provisioners() returns, which engine engine_for
builds, and what save() writes back, and all three are asserted directly in the
suites above; the before/after block is those same probes run by hand on both trees.

Related Issues

Part of #11328.

@chenmingwei23
chenmingwei23 requested review from a team and dwu96 September 17, 2026 16:22
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

The recipient confirmation is a string the API publishes then demands back verbatim, so any client that auto-echoes it nullifies the control while appearing enforced.

Watch

The server cannot distinguish an operator who read confirm_before_launch from a client that copies it into confirm_recipient programmatically — the natural way to write the renderer (body.confirm_recipient = row.confirm_before_launch) is exactly the copy-paste ritual the description says the design exists to avoid, and once written that way the option-C check passes forever without a human ever seeing the image digest. Today the lane is API-only, so the premise is unrealized rather than wrong, but the follow-up renderer is where it becomes true or false.
Clears when: the aws_fargate renderer (or its spec/issue) requires a displayed, explicitly acknowledged recipient — never a field auto-populated from the descriptor into the launch body.

Suggestions

  • After a post-upgrade launch, cloud.json's legacy pointer goes permanently stale while remaining authoritative to any downgraded binary's destroy --yes; one sentence in the upgrade note naming that would close the last wrong-target route this PR otherwise eliminates.

[DESIGN-REVIEWED] dc345aa

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] dc345aa

False positive or not applicable? A repository writer can comment:
/ai-review override gpt dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] dc345aa

Verdict parsed from the review's SHA-scoped output markers for commit dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5.

False positive or not applicable? A repository writer can comment:
/ai-review override fable dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The confirmation step's human half has no surface — nothing renders confirm_before_launch — and two new reader/clear forms generalize past their single counted consumer.

Not justified as shipped

  • Item 2 — one consumer, generalized: the descriptor field exists so "the operator READS it where they choose the lane" (interfaces.py), but no renderer claims the aws_fargate kind and confirm_recipient/confirm_before_launch has zero matches under website/ — today every caller is a program echoing GET /provisioners back, the copy-paste ritual the field's own comment disclaims.
    Subtraction: defer RemoteProvisioner.confirm_before_launch and the handler equality gate; keep the engine-side empty/mismatch refusal, which alone removes the rewrite-after-read harm.
    Clears when: a renderer or CLI prompt that shows the value to a human ships, or a counted human-facing consumer exists.
  • Item 9 — one consumer, generalized: _read_or_reason (grepped: 1 caller, config.py:382, which discards _reason) justifies its absent-vs-unreadable split by "opposite instructions to a writer" — the writer this same PR deletes (save() removed, "This module has no writer").
    Subtraction: collapse _read_or_reason into load() returning defaults, keeping the pre-parse size bound.
    Clears when: a consumer of the reason string exists, or the collapse is made.
  • Item 10 — zero consumers: clear_tag is try_clear_tag(...)[0], and its only caller (cli_cloud.py:444, grepped clear_tag\() deliberately ignores the bool.
    Subtraction: delete clear_tag; both sites call try_clear_tag.
    Clears when: the deletion is made or a caller consuming the bool is counted.

What this change ships

Inventory (10 items) — 7 justified

Intent: let an operator configure the Fargate lane in cloud.json and have aws_fargate registered exactly when that block is complete — an ADDITION, under RFC rfc-remote-instance-on-fargate (in-progress on the base list; new lane defaults off, so not product shape). The change has more than 10 observable differences; these are the 10 most noticeable. (The description file is workflow-truncated at 8000 bytes, so no undeclared tag is asserted from its absence there.)

  1. A complete fargate block registers the aws_fargate lane; incomplete reads as absent — justified
  2. Fargate launches require echoing the published credential recipient (confirm_recipient), refused at handler and engine — one consumer, generalized (no human surface renders it)
  3. cloud.json and the new launch record sealed against agent writes (tool gate + kernel + pre-create) — justified
  4. Launch bookkeeping moves to new cloud_launch_state.json; CloudConfig.save() deleted; legacy read-through keeps resume working — justified
  5. A launch now aborts before provisioning when the saved pointer changed or cannot be cleared — justified
  6. destroy clears the pointer only while it names the destroyed stack; write failures warn, never fail — justified
  7. Symlinked/hardlinked cloud.json/record refused where a launch or tag-consuming verb reads them; warned on spawn; delegated-workspace refusal extended — justified
  8. Dashboard launch refusals become 400s with codes instead of 500s; engine resolution moved off the event loop — justified
  9. Config reader hardening (1 MiB pre-parse bound, non-string fields void the block) via a _read_or_reason split — one consumer, generalized
  10. LaunchState.clear_tag shipped beside try_clear_tag — zero consumers

[FIRST-PRINCIPLES-REVIEWED] dc345aa

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 17, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/fargate-config-home-11328 branch 2 times, most recently from bbb0017 to a2faa8c Compare September 17, 2026 20:19
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 17, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/fargate-config-home-11328 branch from a2faa8c to 2894d49 Compare September 17, 2026 22:08
@chenmingwei23
chenmingwei23 force-pushed the feat/fargate-config-home-11328 branch 3 times, most recently from 27fe585 to c3170d6 Compare September 17, 2026 23:26
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

Which legitimate operations does dc345aafe255cfd26e3aabebc89e8e4f5cc7a6c5 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: the reviewer's own judgement; no confirmed regression.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 12 classified, 0 newly refused, 12 still allowed.
  • ubuntu-latest (platform posix): 12 classified, 0 newly refused, 12 still allowed.
  • windows-latest (platform windows): 8 classified, 0 newly refused, 8 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: CONCERNS

TIGHTENING: cloud.json and cloud_launch_state.json become sealed governance leaves — added to _WRITE_PROTECTED_HOME_PATHS (file-edit tool gate), to _CREW_READONLY_LEAVES and the pre-create list (kernel read-only bind on every Linux sandboxed spawn), given no-alias lstat refusals at their consume points (require_unaliased_cloud_config from the provisioner seam, require_unaliased_launch_state from LaunchState.load), and joined to the delegated-workspace overlap refusal (delegated_workspace_exposes_sealed_target) -- the ONE threat: a sandboxed write choosing what the owner's credential reaches, quoting the hunk: "a rewritten fargate.image turns the owner's next launch into credential delivery to an image the owner never chose", and for the launch record "a writable copy lets a sandboxed process choose which stack a destroy --yes deletes".

ADJUDICATED: 17 candidates, 0 confirmed newly-refused
No confirmed rows were handed back for this run. The candidates probe the boundary the diff moves: reads of both sealed leaves under both crew-home prefixes and the KIROCREW_HOME override, the directory listing and backup-copy shapes, the remedy command the new refusals themselves name (kirocrew cloud list), and workspace-local files sharing the cloud.json leaf name (read, redirect write, revert, validate) — the over-match a leaf-keyed rather than home-anchored rule would commit. Note the diff never touches _SENSITIVE_HOME_DIRS, is_sensitive_bash_command, the exfiltration auditor, or the deny catalog, and the shell gate explicitly does not text-match bash writes to the write-protected tier, so zero flips in the adjudicated composite is the expected result — which is also why the composite adjudicates only a sliver of this tightening (see UNADJUDICATED).

PLATFORM COVERAGE: posix — home-anchored reads under ~/.kiro/crew and the legacy ~/.kirocrew, the $KIROCREW_HOME override spelling, and the workspace-local same-leaf write; these cover the bind-mount/Seatbelt hosts, whose shells tokenize posix-style. windows — cmd (type, echo {} >, %USERPROFILE% with \ separators) and PowerShell (Get-Content, Get-ChildItem, $env: form) spellings of the same reads, listings and same-leaf write; the diff makes explicit Windows assumptions (the _delete_file_command del "…" remedy renderer, the every-first-party-Windows-spawn delegated branch), so both Windows shells are probed. any — kirocrew cloud list, git checkout -- cloud.json, python -m json.tool cloud.json. Not expressible as candidates: the delegated-workspace overlap and the consume-point alias checks take PATHS, not shell command lines, so no candidate can probe their platform behavior on either host — named below. Per-leg verdicts are the deterministic fold's to report, not mine.

UNADJUDICATED: The bulk of this tightening lives outside the shell-command composite, so no verdict exists for it:

  1. File-edit tool gate. Call path: hooks.on_tool_call (edit kind) → edit_target_candidates → is_sensitive_write_path, whose _WRITE_PROTECTED_HOME_PATHS gains <prefix>/cloud.json and <prefix>/cloud_launch_state.json under both crew-home prefixes. Candidate inputs I would have submitted: an edit targeting ~/.kiro/crew/cloud.json.bak (sibling name, must stay editable), an edit to a workspace-relative cloud.json, and an operator asking the agent to update their Fargate image pin in ~/.kiro/crew/cloud.json — the last is refused by design (it is the threat's exact shape), but it is a real owner workflow that now dead-ends into "edit it yourself out-of-band", and nothing in the refusal says so.

  2. Kernel read-only seal plus pre-create. Call path: namespace_argv → _materialize_sealable_ceilings → MS_RDONLY bind of both leaves on every Linux sandboxed spawn. Candidate inputs: an in-sandbox open(path, "w") (refused — the threat), and the staleness cost the diff itself documents: the operator's writers publish via rename, so an already-running sandboxed spawn stays pinned to the old inode and an in-sandbox cat of either file can read a stale (pre-created {}) document after the operator configures the lane. The diff argues criterion 2 makes this fail narrower-than-truth; that is an argued narrowing, not an adjudicated one.

  3. Consume-point no-alias refusals. Call path: provisioners.engine_for → require_unaliased_cloud_config, and LaunchState.load → require_unaliased_launch_state, both → _require_real_file_nofollow, unconditional on content, refusing a symlink or st_nlink > 1. Candidate legitimate inputs newly refused: a stow/chezmoi-managed home where ~/.kiro/crew/cloud.json is a symlink into a dotfiles repo (every Fargate launch refused until the operator de-links the file), and a cp -al-style hardlink snapshot of the home, which raises the source inode's link count on cloud_launch_state.json (every kirocrew cloud verb refused until the extra link is broken). The diff knows this class — it deliberately moved the refusal off the spawn path, warns there instead, and ships a per-shell remedy string — so this is a NARROWING finding stated in prose: real hosts with dotfile managers lose the cloud lane until manually remediated, and no candidate row can confirm or clear it because the guard consumes a path's inode state, not a command line.

  4. Delegated-workspace overlap. Call path: ACP spawn → delegated_workspace_exposes_sealed_target, whose target list grows from the kiro agents dir to also include config_dir()/cloud.json and config_dir()/playwright-cli. The new refusal delta is a workspace that IS or CONTAINS the crew config dir itself without containing the agents dir — e.g. workspace ~/.kiro/crew, or any ancestor of a relocated KIROCREW_HOME that sits under the user's project tree — on exactly the delegated platforms (macOS with kiro-cli's internal sandbox, every first-party Windows spawn). An operator who points KIROCREW_HOME inside the directory they also use as a workspace loses delegated spawns there with no candidate able to measure it.

[SCOPE-REVIEWED] dc345aa

@chenmingwei23
chenmingwei23 force-pushed the feat/fargate-config-home-11328 branch from c3170d6 to 2b63145 Compare September 17, 2026 23:48
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Inherited reds cleared by #11593

The two backend reds this PR carried earlier were not its own. Recording the chain so
a later reader does not re-investigate it.

main was red at 0640c1e0d on Backend Tests (Windows) (5), (Windows) (7),
(3.12, 5), (3.12, 6) and the Coverage Gate that cascades from them (#11585). CI
evaluates refs/pull/<n>/merge, so every open PR inherited it. This branch showed
Backend Tests (Windows) (7) -- one of those exact lanes -- plus Backend Tests (3.12, 4), which proves nothing by name on its own: pytest-split divides a
collected COUNT, so shard 4 here does not hold what shard 4 holds on main.

The cure is #11593 (fix(session-control): authorize a created child on the store it is bound to), now merged as 2627b0407c. This branch is rebased onto exactly that
commit and is zero commits behind it, so the merge ref no longer carries the failure.

One earlier red on this PR was a different inherited mechanism worth separating: a
Coverage Gate failure that was a cascade of two Backend Tests (3.12, ...) shards
being CANCELLED at the 50-minute job ceiling, not a coverage threshold. The gate's own
log shows it exits at backend-test=cancelled -- failing closed. on the upstream job
result, with BACKEND_MIN: 90 never evaluated. That ceiling is separately resolved by
94c59ed976 (8 shards), which this branch also carries.

The measured before/after in the description is re-run against 2627b0407c and
unchanged: a complete fargate block takes engine_for('aws_fargate') from
KeyError to FargateLaunchEngine, and removing the block returns it to KeyError.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 18, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/fargate-config-home-11328 branch 3 times, most recently from 82f1b4d to bd6061e Compare September 18, 2026 00:33
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants