Skip to main content

require_acao_view

Function require_acao_view 

Source
pub fn require_acao_view<E>(caixa: &Caixa) -> Result<(&CiRun, CanteiroDag), E>
Expand description

Compound per-Acao entry gate: the canonical three-line require_kind(caixa, CaixaKind::Acao)? + require_ci(caixa)? + decompose_ci(caixa, ci)? prelude every per-Acao caixa-<target> consumer runs at its entry-point, collapsed onto one call the caller reads as intent (“gate the input on the V0 Acao shape and hand back the borrowed canteiro_types::CiRun + the decomposed canteiro_types::CanteiroDag”) rather than three hand-spelled steps.

The cascade names one contract with three axes: :kind is Acao (this is a per-Acao consumer’s input, not a Biblioteca / Binario / Servico / Supervisor / Aplicacao mis-hand-off), the :ci slot is present (require_ci returns the borrowed canteiro_types::CiRun), and the declared run decomposes cleanly through canteiro_types::decompose (a duplicate node name, a missing dep, a cycle — every canteiro_types::DecomposeError arm — surfaces via CiDecomposeFailure). All three axes must hold together — so lifting the three-arm cascade onto one helper names the compound contract at each call site the way the sibling per-Servico require_v0_servico_shape compound gate already names the two-axis compound V0 Servico-shape contract and the sibling per-Aplicacao require_aplicacao_view compound gate names the three-arm compound per-Aplicacao entry-gate contract.

Returns the borrowed canteiro_types::CiRun paired with the owned canteiro_types::CanteiroDag decompose_ci produced — both are the load-bearing artifacts every per-Acao consumer reads past the gate: the borrowed run for per-canteiro_types::CiNode axes (the substrate primitive ci_declared_edge_count for the declared edge count, the deferred sui-supercacheci::canteiro::emit_gha per-node YAML emit surface), the owned DAG for topological order (cd.topo_order(), which the substrate’s own decompose_ci pass-through-on-success contract at [decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag] pins as infallible on the accepted arm).

The current single production call site — caixa-actions::validate — previously carried the three-line prelude inline:

caixa_core::require_kind(caixa, CaixaKind::Acao)?;
let ci = caixa_core::require_ci(caixa)?;
let cd = caixa_core::decompose_ci(caixa, ci)?;

It now reads as a one-liner let (ci, cd) = caixa_core::require_acao_view::<Error>(caixa)?;. Every deferred per-Acao consumer named in the caixa-actions crate docs (the sui-supercacheci::canteiro::emit_gha workflow renderer, a future acao.pleme.io/v1alpha1/Acao CR materializer’s admission webhook, a future feira validate --acao per-caixa admission verb) gets the compound three-arm gate for free with one call, instead of re-inlining the three-line prelude — and a future change to the V0 Acao contract (an M4 canteiro_types::CiRun :workspace-scoped admission gate the CR materializer resolves at admission time, a per-:ci cross-node capability-audit prelude the Pony-inspired capability-typing roadmap acknowledges) is one edit here on the compound helper, not a coordinated rewrite across every per-Acao consumer’s inline three-line prelude.

The generic error type E accepts every per-Acao consumer’s local thiserror Error enum that carries all three of KindMismatch, MissingCiSlot, and CiDecomposeFailure via #[from] (caixa_actions::Error today, and every future per-Acao consumer that wires the same three #[from] arms as the diagnostic-naming-the-offending-caixa contract already requires). Type inference at the call site resolves E from the caller’s ? return type, though a caller that assigns the result directly to a Result<(&CiRun, CanteiroDag), Error> binding may need a turbofish (::<Error>) — matching the sibling require_aplicacao_view::<Error> turbofish convention the peer per-Aplicacao call site already reads.

Peer to require_v0_servico_shape on the sibling per-Servico entry-gate axis and require_aplicacao_view on the sibling per-Aplicacao entry-gate axis — every per-kind renderer’s entry-gate cascade now lives in exactly one substrate primitive.

§Errors

Returns the caller’s E wrapping a KindMismatch when caixa.kind != CaixaKind::Acao, a MissingCiSlot when the caixa’s :ci slot is absent past the kind gate, or a CiDecomposeFailure when canteiro_types::decompose refuses the borrowed run. Order matches the three-line prelude this replaces: the kind gate fires first (so a :kind Servico caixa carrying a well-formed :ci stanza — the manifest field’s documented “silently ignored” case on a non-Acao kind — surfaces the kind mismatch, the more actionable diagnostic), then the presence gate, then the decompose gate.