Repository navigation
Closed
Labels
task:readySpec checked. An agent may implement it once its Depends on allow.
Description
Part of #213.
Scope
After this PR an operator removes a component Simlock installed: simlock component remove ios 26.4 or simlock component remove android 35, with --dry-run to see what would go. Simlock removes only what it has a record of installing and what no device uses. The same operation is on the admin client and over HTTP.
On iOS the runtime is unregistered with simctl runtime delete. If its download stays behind in the macOS asset store (#79), the result says so.
Technical spec
File and line references are to main at 88c4eeb.
Modules touched
src/core/driver.ts:Driver.removeComponent(receipt, { signal })returns{ sizeBytes?, residue? }. The driver:- finds the installed component whose receipt equals the one given, and throws
ComponentNotOwnedErrorwhen there is none; - throws
ComponentInUseErrorwhenforeignDevicesfor it is above zero; - removes it, bounded by a five-minute timeout;
- reads the installed components again and fails when it is still there.
residueis a sentence for the operator when something stays on disk.
- finds the installed component whose receipt equals the one given, and throws
src/drivers/ios/index.ts:simctl runtime delete <image>, without--keep-asset. Afterwards look for the build in the asset store (#downloadedRuntimeAssets, :1318); when it is still there,residuesays the download remains and names Xcode's Settings, Platforms as the way to reclaim it.simlock simctl runtime deletestays refused (:1439); its message points atsimlock component remove.src/drivers/android/index.ts:sdkmanager --uninstall <package>.src/core/component-installer.ts:remove({ platform, version, dryRun, requesterId }).- Find the registry's component record for the platform and version. None:
ComponentNotOwnedError. - Find it in
list(). Not marked as Simlock's:ComponentNotOwnedError. devicesorforeignDevicesabove zero:ComponentInUseErrorwith both counts.- An install running or waiting on that platform:
ComponentBusyError. dryRun: answer{ outcome: "would-remove", sizeBytes? }and stop. Every check a removal makes has run by now.- Take the platform's turn, so an install that arrives waits behind the removal.
- Inside the serialized decision gate (
decisions.run): count the devices again and mark the platform and version as being removed. From then until the removal settles, no device record is created for that platform and version, on any path: lease, warm pool, or startup convergence. A request that resolved to it is rejected withRUNTIME_MISSING. - Call
removeComponent. On success delete the record, clear the mark, emitcomponent.removed, answer{ outcome: "removed", sizeBytes?, residue? }. On failure clear the mark, keep the record, and rethrow.
- Find the registry's component record for the platform and version. None:
src/core/registry.ts:deleteComponent(platform, version).src/contract/operations.ts:component.remove,role: "admin". Input{ platform, version, dryRun? }. Output{ platform, version, outcome: "removed" | "would-remove", sizeBytes?, residue? }.src/contract/errors.ts,src/daemon/error-code.ts:COMPONENT_NOT_OWNED(CLI exit 12, HTTP 409),COMPONENT_IN_USEwith details{ devices, foreignDevices }(exit 12, HTTP 409),COMPONENT_BUSY(exit 11, HTTP 409).src/bus/index.ts:component.removed.src/daemon/dispatcher.ts: the handler, withrequesterId: session.principal.src/gateway/dispatcher.ts:UNSUPPORTED_IN_GATEWAY_MODE.src/simlock-client/client.ts,types.ts:SimlockAdminClient.removeComponent(input).src/cli/index.ts:component remove <platform> <version> [--dry-run] [--yes]. Without--dry-runit confirms or requires--yes, exactly asrelease --alldoes (:1220). One JSON line on stdout.src/http/app.ts:DELETE /v1/components/{platform}/{version},?dryRun=truefor the dry run. A JSON answer, no stream.src/core/fake-driver.ts,e2e/fake-driver/fake-driver.ts:removeComponent, scriptable to fail and to leave residue.docs/internal/agent-rules/safety.mdrule 1: a component is removed only through its record, and never while any device uses it, Simlock's or not; a driver may read, never write, the platform's default device locations to count them.- Docs:
docs/CLI.md(the command, the three codes, theruntime deletebullet),docs/HTTP-API.md,docs/CLIENT.md,docs/EVENTS.mdanddocs/internal/EVENTS.md,docs/internal/KNOWN-PITFALLS.md(iOS on-demand runtime downloads never actually free disk space (mobileassetd cache outlives simctl runtime delete) #79: whatcomponent removereports; new entry: a second Simlock instance on the same machine is not counted as a user of a component, and a foreign device created after the driver's last count is not seen),docs/internal/ARCHITECTURE.md.
Contract and event changes
- New operation
component.remove. Three new error codes. No protocol change. - New event
component.removed:platform,componentId,version,sizeByteswhen known,residuewhen there is one,requesterId. Emitted by the installer after the record is deleted. BothEVENTS.mdfiles gain the row.
Rules in play
- ADR 0010 §5 and §8.
safety.mdrule 1 (rewritten here), rule 2 (a leased device counts as a user, so its component is never removed), rule 5 (confirm or--yes; the dry run), rule 6 (the event names who asked), rule 8 (the record and the receipt, never a name).architecture.mdrule 5 (the removal is a direct call chain), rule 7 (the destructive step is a driver verb the core invokes), rule 10 (the "in use" answer comes fromlist(), the same place the listing gets it), rule 12 (the removing mark is cleared on every exit, including a throw).events.mdrules 1, 3, 6 and 8.testing.mdrules 1 to 4.
Tests
- A component with a record and no users is removed, its record is deleted, and
component.listno longer shows it. - A component with no record fails with
COMPONENT_NOT_OWNEDandremoveComponentis never called. - A record whose receipt no longer matches what is installed fails with
COMPONENT_NOT_OWNEDandremoveComponentis never called. - A component a registry device uses fails with
COMPONENT_IN_USEnaming the count, whatever the device's state, leased included. - A component a foreign device uses fails with
COMPONENT_IN_USEnaming the count. - A dry run answers
would-removewith the size, calls no driver verb that changes anything, and leaves the record. - A dry run while an install is running on that platform fails with
COMPONENT_BUSY, as the removal would. - A removal while an install is running on that platform fails with
COMPONENT_BUSY. - An install that arrives during a removal starts only after the removal has ended.
- A lease request that resolves to the version being removed is rejected with
RUNTIME_MISSING, and no device record is created. - Warm-pool provisioning creates no device for a version being removed.
- A removal the driver fails keeps the record, clears the mark, and emits no
component.removed. component.removedcarries the admin principal asrequesterId.- The iOS driver runs
simctl runtime deletewith the image identifier from the receipt and no--keep-asset. - The iOS driver reports
residuewhen the build is still in the asset store afterwards, and none when it is gone. - The iOS driver refuses when a device in the default device set uses the runtime, and deletes nothing.
- The Android driver runs
sdkmanager --uninstallwith the package from the receipt. - The Android driver refuses when an AVD in the user's AVD home names the image.
- An agent session gets
FORBIDDEN. - The CLI refuses without
--yeswhen it cannot confirm, and does not ask under--dry-run. - On a gateway the operation answers
UNSUPPORTED_IN_GATEWAY_MODE.
Done when
- On real hardware: an Android image installed with
simlock component installis removed, and its directory is gone. Ask the maintainer before running this. - On real hardware: an iOS runtime installed with
simlock component installis removed and no longer insimlock catalog. Record in the PR whether its download left the asset store and whether the result carriedresidue. Ask the maintainer before running this. - e2e with the fake driver covers remove, dry run, not owned, in use, and the agent refusal.
pnpm checkis green.
Out of scope
- Removing on its own: no cleanup rule, idle tier or disk-pressure reaction removes a component.
- Deleting a file in the macOS asset store. Simlock asks
simctlto delete the runtime and reports whatsimctlleft behind. - Removing through a gateway.
- A force flag.
Depends on
simlock component listshows every installed component, its size, and who installed it #220- Lease-triggered downloads go through one installer in the core #216
Approval
- Approved for delivery
Written by an agent.
Metadata
Metadata
Assignees
Labels
task:readySpec checked. An agent may implement it once its Depends on allow.
Activity
V3RON commentedon Oct 2, 2026
Spec updated: Technical spec makes the dry run do every check, and records two accepted gaps in KNOWN-PITFALLS.
Written by an agent.
docs(adr): 0010 — components are installed, recorded and removed thro…
github-actions commentedon Oct 2, 2026
Now
task:ready: approved, technical spec present, #220, #216 closed.feat(core,ios,android,contract,daemon,cli,client,http,gateway): simlo…
feat(core,ios,android,contract,daemon,cli,client,http,gateway): simlo…