Skip to main content

Gates

Struct Gates 

Source
pub struct Gates;
Expand description

The gate-file protocol, scoped to a project’s .devflow/gates/ directory.

Implementations§

Source§

impl Gates

Source

pub fn dir(project_root: &Path) -> PathBuf

The .devflow/gates/ directory for a project.

Source

pub fn gate_path(project_root: &Path, phase: PhaseId, stage: Stage) -> PathBuf

Path to the gate request file for a phase + stage.

Source

pub fn response_path( project_root: &Path, phase: PhaseId, stage: Stage, ) -> PathBuf

Path to the response file for a phase + stage.

Source

pub fn ack_path(project_root: &Path, phase: PhaseId, stage: Stage) -> PathBuf

Path to the ack file for a phase + stage.

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn ack( project_root: &Path, phase: PhaseId, stage: Stage, ) -> Result<PathBuf, GateError>

Write an ack file signalling the response was read.

Source

pub fn cleanup( project_root: &Path, phase: PhaseId, stage: Stage, ) -> Result<(), GateError>

Remove the gate, response, and ack files for a stage. Idempotent.

Auto Trait Implementations§

§

impl Freeze for Gates

§

impl RefUnwindSafe for Gates

§

impl Send for Gates

§

impl Sync for Gates

§

impl Unpin for Gates

§

impl UnsafeUnpin for Gates

§

impl UnwindSafe for Gates

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more