Skip to main content

spec_driven_docs/gates/
ki_filing.rs

1//! Gate: a known-issue record carries one filing state.
2//!
3//! The filing state says where the case stands upstream, which the state
4//! axis never answers: a masked workaround says nothing about whether the
5//! evidence behind it is ticket-ready. With the field judged, a grep for
6//! `filing: ready` answers which cases someone can file today, and
7//! `filing: filed` is what binds a record to its report body.
8
9use crate::domain::rule_id::RuleId;
10use crate::gates::ki_record::{FILINGS, judge};
11use crate::gates::{GateCtx, GateResult};
12
13/// The rules this gate can cite.
14pub const CITES: &[RuleId] = &[RuleId::RecordCarriesOneFilingState];
15
16/// Judge every known-issue record under the resolved roots.
17///
18/// # Errors
19///
20/// [`crate::gates::GateError::Io`] when a record cannot be read.
21pub fn run(ctx: &GateCtx, args: &[String]) -> GateResult {
22    judge(
23        ctx,
24        args,
25        "filing",
26        &FILINGS,
27        RuleId::RecordCarriesOneFilingState,
28    )
29}
30
31#[cfg(test)]
32mod tests {
33    use super::*;
34    use crate::gates::tests_support::ki_fixture_filing;
35
36    fn run_on(filing: &str) -> Vec<String> {
37        let dir = ki_fixture_filing(
38            filing,
39            "https://example.invalid/issues/1234",
40            "# V\n## Report\nT\n",
41        );
42        let ctx = GateCtx::new(dir.path().to_str().unwrap());
43        run(&ctx, &[])
44            .unwrap()
45            .iter()
46            .map(ToString::to_string)
47            .collect()
48    }
49
50    #[test]
51    fn accepts_every_filing_state_the_method_defines() {
52        for filing in FILINGS {
53            assert!(run_on(filing).is_empty(), "{filing} was rejected");
54        }
55    }
56
57    #[test]
58    fn rejects_a_filing_state_the_method_does_not_define() {
59        let out = run_on("open");
60        assert_eq!(out.len(), 1);
61        assert!(out[0].starts_with("FAIL known-issues:a-record-carries-one-filing-state "));
62        assert!(out[0].ends_with(": filing: open is not one of gathering, ready, filed, deferred"));
63    }
64}