Checkpoints¶
akms.orchestrator.checkpoint
¶
checkpoint.py — File-Based Checkpoint Interface (§3 of system design).
Checkpoints are blocking pause points where the developer reviews and approves before the next stage begins. At each checkpoint, the orchestrator presents:
- Stage output — the primary artifact (plan, task JSONs, PCD, review report)
- AKMS status — new/modified nodes, confidence changes, pitfalls added
- Action menu — stage-specific options (approve, reject, edit, abort)
- Warnings — any graph health issues
The developer's response is one of:
- approve → proceed to next stage
- reject [reason] → re-run the stage with feedback
- edit → developer modifies artifacts directly, then approves
- abort → halt, preserve all state for resumption
File-based protocol:
- Orchestrator writes: knowledge/checkpoints/{stage}_{timestamp}.yaml
- Developer writes: knowledge/checkpoints/{stage}_{timestamp}_response.yaml
CheckpointData
¶
CheckpointData(
stage: Stage,
status: str = "awaiting_review",
stage_output: str = "",
akms_status: dict | None = None,
actions: list[str] | None = None,
warnings: list[str] | None = None,
phase: int | None = None,
timestamp: str | None = None,
)
Data structure for a checkpoint file.
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
to_dict
¶
Serialize to a dict for YAML output.
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
CheckpointResponse
¶
Response from the developer.
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
CheckpointHandler
¶
Bases: ABC
Abstract base class for checkpoint presentation strategies.
Implementations decide how to present a checkpoint to the developer (file-based polling, terminal prompt, auto-approve, etc.) and return a CheckpointAction indicating the developer's decision.
present
abstractmethod
¶
present(
state: "PipelineState",
stage_output: str,
akms_status: str,
warnings: list[str],
repo_root: Path,
) -> CheckpointAction
Present a checkpoint and return the developer's action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
'PipelineState'
|
Current pipeline state (stage, phase). |
required |
stage_output
|
str
|
Primary artifact text for review. |
required |
akms_status
|
str
|
AKMS status summary string. |
required |
warnings
|
list[str]
|
List of warning messages to display. |
required |
repo_root
|
Path
|
Repository root path. |
required |
Returns:
| Type | Description |
|---|---|
CheckpointAction
|
CheckpointAction indicating developer decision. |
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
FileCheckpointHandler
¶
Bases: CheckpointHandler
Checkpoint handler that writes a YAML file and polls for a response file.
Follows the write_checkpoint / read_checkpoint_response protocol. Returns ABORT on timeout, REJECT on unrecognised action string.
Timeout policy: pass an explicit timeout for asynchronous file-based
approval (a human answering from another terminal — the design use case
for this handler). When timeout is left at its default (None),
the wait adapts to the environment: an interactive run (stdin is a TTY)
waits :data:INTERACTIVE_TIMEOUT seconds, while a non-interactive run
(CI, cron, piped stdin) waits only :data:HEADLESS_TIMEOUT seconds —
an unattended process must fail visibly within a minute, not block for
an hour on a gate nothing will ever answer. Either way, the wait is
announced on stderr with the exact response path and accepted actions.
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
TerminalCheckpointHandler
¶
Bases: CheckpointHandler
Checkpoint handler that uses print() / input() for interactive review.
Suitable for local developer workflows where the orchestrator runs in a terminal session (per addendum §3.3.1, deviation D3).
write_checkpoint
¶
Write a checkpoint YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_root
|
Path
|
Repository root path. |
required |
data
|
CheckpointData
|
Checkpoint data to write. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written checkpoint file. |
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
read_checkpoint_response
¶
read_checkpoint_response(
checkpoint_path: Path,
timeout: float | None = None,
poll_interval: float = 1.0,
) -> CheckpointResponse | None
Read a checkpoint response file.
The response file name is derived from the checkpoint path by appending
_response. Optionally polls for the file if timeout is set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path
|
Path
|
Path to the checkpoint YAML. |
required |
timeout
|
float | None
|
Seconds to wait for response (None = no wait, just check). |
None
|
poll_interval
|
float
|
Seconds between polls. |
1.0
|
Returns:
| Type | Description |
|---|---|
CheckpointResponse | None
|
CheckpointResponse if found, None if timeout/not found. |
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
write_checkpoint_response
¶
write_checkpoint_response(
checkpoint_path: Path,
action: str,
reason: str = "",
edits: dict | None = None,
) -> Path
Write a checkpoint response file (for testing / CLI).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path
|
Path
|
Path to the original checkpoint YAML. |
required |
action
|
str
|
One of: approve, reject, edit, abort. |
required |
reason
|
str
|
Required for reject. |
''
|
edits
|
dict | None
|
Optional edits dict. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the written response file. |
Source code in packages/akms/src/akms/orchestrator/checkpoint.py
list_checkpoints
¶
List all checkpoint files in the repository.
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of dicts with keys: path, stage, status, timestamp, has_response. |