pub struct Gates;Expand description
The gate-file protocol, scoped to a project’s .devflow/gates/ directory.
Implementations§
Source§impl Gates
impl Gates
Sourcepub fn gate_path(project_root: &Path, phase: PhaseId, stage: Stage) -> PathBuf
pub fn gate_path(project_root: &Path, phase: PhaseId, stage: Stage) -> PathBuf
Path to the gate request file for a phase + stage.
Sourcepub fn response_path(
project_root: &Path,
phase: PhaseId,
stage: Stage,
) -> PathBuf
pub fn response_path( project_root: &Path, phase: PhaseId, stage: Stage, ) -> PathBuf
Path to the response file for a phase + stage.
Sourcepub fn ack_path(project_root: &Path, phase: PhaseId, stage: Stage) -> PathBuf
pub fn ack_path(project_root: &Path, phase: PhaseId, stage: Stage) -> PathBuf
Path to the ack file for a phase + stage.
Sourcepub fn list_open(project_root: &Path) -> Vec<OpenGate>
pub fn list_open(project_root: &Path) -> Vec<OpenGate>
Every open gate (request written, no response yet), sorted by phase
then stage. Request files are NN-{stage}.json; .response.json and
.ack.json siblings are protocol artifacts, not requests, and any
unparsable file is skipped — listing must degrade, not die.
Sourcepub fn respond(
project_root: &Path,
phase: PhaseId,
stage: Stage,
response: &GateResponse,
) -> Result<PathBuf, GateError>
pub fn respond( project_root: &Path, phase: PhaseId, stage: Stage, response: &GateResponse, ) -> Result<PathBuf, GateError>
Answer an open gate by writing its response file atomically — the programmatic form of what a human previously hand-edited. Refuses when no gate request is open for the phase+stage, and when a response is already on disk awaiting the workflow’s poller (silently replacing an unconsumed answer would race the poll).
Sourcepub fn reap(
project_root: &Path,
phase: PhaseId,
stage: Stage,
note: &str,
responded_by: &str,
) -> Result<PathBuf, GateError>
pub fn reap( project_root: &Path, phase: PhaseId, stage: Stage, note: &str, responded_by: &str, ) -> Result<PathBuf, GateError>
Answer an abandoned gate with a rejection — the reaping half of 23b’s
aged-gate sweep. Mitigation for T-23-41 (Elevation of Privilege): this
function takes no boolean parameter and hard-codes approved: false at the literal below, so no caller — buggy or refactored — can
ever make it write an approval. It is the sweep’s ONLY write path.
The caller-supplied note’s lowercase form MUST contain the abort
keyword GateAction::from_response matches on ("abort"), so the
reap resolves to GateAction::Abort rather than
GateAction::LoopBack(Stage::Code) — a loop-back would relaunch an
agent on an abandoned run, the opposite of what a reap should do.
Sourcepub fn write_gate(
project_root: &Path,
phase: PhaseId,
stage: Stage,
context: &str,
) -> Result<PathBuf, GateError>
pub fn write_gate( project_root: &Path, phase: PhaseId, stage: Stage, context: &str, ) -> Result<PathBuf, GateError>
Write a gate request, creating the gates directory if needed.
Sourcepub fn poll_response(
project_root: &Path,
phase: PhaseId,
stage: Stage,
timeout_secs: u64,
) -> Option<GateResponse>
pub fn poll_response( project_root: &Path, phase: PhaseId, stage: Stage, timeout_secs: u64, ) -> Option<GateResponse>
Poll for a response with exponential backoff (1s → 2s → 4s … capped at
60s), giving up after timeout_secs. Returns the parsed response when it
appears, or None on timeout.