Layered runtime protection
Which change a write belongs to
.comet/current-change.json uses comet.selection.v2 to record the workflow and change to which the current write belongs. It is only responsible for the current attribution and does not limit the number of active changes in the project.
Hook Router determines the write attribution in the following order:
- Locate the Comet project based on the working directory provided by the Hook request;
- Read the workflow enabled by the project and the current selection;
- Enumerate the active changes corresponding to the workflow;
- After determining the unique owner, only the Guard of that owner is called.
comet native select <change-name>. When the selected file is damaged, the target has been archived, the workflow has been disabled, or the change status cannot be read, the Router will also stop writing.
In the old version of the global Hook, if there is no trusted request working directory, it will remain neutral to avoid inferring the current change from the Hook installation directory or other items. When an anomaly is detected in the project or during the target range check, the Router will handle it as a failed shutdown.
Stage-aware change control
Native Guard divides the goals within the project into formal requirements, implementation files, and Runtime management files.
Formal requirements and implementation files must be written separately. When a single tool call modifies two types of files simultaneously, Guard will reject the operation to prevent the sharing of a state transition that cannot be accurately attributed between requirement changes and implementation changes.
During the Verify or Archive period, when it is observed that the implementation is written, RC1 will not continue to use the original candidate. The Runtime will increase the implementation rounds, clear invalid acceptance conclusions, and return to the Build. When the formal requirements change, the Runtime will return to Shape and invalidate the validation results and archiving authorizations in the old target cycle.
Pre-protection for observable writing
Hook Router can only handle events where the platform provides the write intent and the destination path. The following writes may not go through phase guarding:- The IDE or background process directly modifies the file;
- The platform does not expose any Shell or file operations to the Hook;
- The Hook request has no attributable target path.
- Clarify the goals that lie outside the current project.
Versioned state consistency
Incomet-state.yaml, starting from 1, each stable state transition can only increase once. Before writing a new state, the Runtime compares the disk version:
- The current version must be equal to the expected version of the operation.
- The new version must be exactly the current version plus one.
- Before submission, the disk state will be read again to prevent another process from modifying it first.
continuation and then perform the operations allowed by the current state.
Project-level concurrent mutual exclusion
The state modification, selection, migration and Archive of Native are all executed through project-level change locks. Only one controlled change operation can enter the critical section at the same time. After obtaining the lock, the Runtime will also check:- Is artifact root moving?
- Whether there are uncommitted, unrolled or unidentifiable transactions;
- Is the current operation exactly the recovery action that the transaction allows to continue?
Path and file identity verification
RC1 employs restricted reads and atomic writes for stable files. When reading the official product, the Runtime will check:- A reference is a standardized relative path within a project;
- The path has not entered a sensitive directory or the local Runtime.
- The file is an ordinary file, and the parent directory is not a symbolic link.
- The file size is within the corresponding upper limit, and the text is valid UTF-8.
- It remains the same file object before opening, during reading and after reading.
- The real path is always located in the managed root directory.
Recoverable transactional archiving
Archive will update the canonical Spec, final status and reports, and move the active change into archive. RC1 records these actions as transactions instead of a set of unrelated file commands. The transaction will record the expected content hash and the identity of the file object. Before replacing or deleting an existing target, the Runtime will place the original content in a controlled isolation area and verify that the isolated object is still consistent with the transaction record. After an interruption, the Runtime can continue the confirmed steps based on the log. When the content, path or object identity changes, the transaction will stop. The following situations need to be handled first before continuing with the Archive:- Both the active and archive directories exist simultaneously.
- The transaction log is damaged or inconsistent with the actual directory;
- canonical Spec changes during a transaction;
- Another active change declares the same capability in any registered Git worktree.
Breakpoint recovery based on stable states
The authoritative state for cross-session and cross-device recovery iscomet-state.yaml in the change directory. .comet/runtime/native/changes/<change-name>/state.json only records the local execution of this machine.
The recovery behavior for each scene — an interrupted check, a lost Verifier task, an archive-ready result that returns to Verify, a verification.md rebuild, and so on — is described together in Recovery playbook.
Zero-write environment-aware recovery
comet resume-probe finds the recovery target based on the default workflow specified by .comet/config.yaml. It does not modify change, nor does it switch branches or workspaces.
ambient_resume: false will disable the environment-aware recovery of ordinary requests. When explicitly entering Comet, it is still processed according to the entry command. When multiple active changes exist, the probe uses an explicit name or the current selection; When the unique owner is missing, return ask_user.
Unified diagnosis and recovery entry
For daily progress, only the latestcontinuation is executed. When troubleshooting is needed, read the status in the following order:
doctor --repair is only applicable to states that have been recognized by the Runtime and supported for recovery. When the config, YAML, transaction or directory ownership cannot be determined, it is safer to keep the on-site state than the manual splicing state.
Continue reading: Task advancement and interruption recovery, Product and State and Recovery and Fault Handling .
