meta.language.calls.forbidden

An observed operation must not violate a prohibition of any active ancestor, even when its immediate caller permits the call. A violation is an error and retains the prohibition and complete call path.

Read in specification context · design/meta/language.md

Implementation

Implemented crates/sage-meta/src/contracts.rs:295–300

sage_meta::contracts · lib:sage_meta

Restrictions apply to execution reached through incremental validation as well as source requests, regardless of direct-call permissions.

#![allow(unused)]
fn main() {
    // {anchor}`meta.language.calls.forbidden`
    fn check_prohibitions(&mut self, invocation: &Invocation) {
        // Restrictions apply to execution reached through incremental validation
        // as well as source requests, regardless of direct-call permissions.
        let prohibitions: Vec<_> = self
            .active

}

See more source ↗

Implemented crates/sage-meta/src/validate.rs:30–35

sage_meta::validate · lib:sage_meta

#![allow(unused)]
fn main() {
// {anchor}`meta.language.calls.forbidden`
// {anchor}`meta.language.envelopes.permissions`
pub(crate) fn resolve_contracts(
    documents: &[Document],
) -> Result<BTreeMap<String, crate::contracts::OperationContract>, Vec<Diagnostic>> {
    use crate::contracts::{CallPermission, ContractRule, OperationContract, UncheckedEffect};

}

See more source ↗

Tests and review

Indexed tests and the implementation-completeness and test-adequacy review; no test run is implied.

Implemented sage_meta::real_salsa_contract_fixture

crates/sage-meta/tests/contracts.rs · test:contracts

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.language.calls.declared)]
#[sage::test(meta.language.calls.forbidden)]
#[sage::test(meta.contracts.validated_session)]
#[sage::test(meta.contracts.cache_invocations)]
#[sage::test(meta.contracts.observation_coverage)]
fn real_salsa_contract_fixture() {
    let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
    let fixture = root.join("tests/fixtures/contracts");
    let output = std::process::Command::new(env!("CARGO"))
        .args(["test", "--locked", "--manifest-path"])
        .arg(fixture.join("Cargo.toml"))
        .args(["--", "--nocapture", "--test-threads=1"])
        .env(
            "CARGO_TARGET_DIR",
            root.join("../../target/sage-contract-fixture"),
        )
        .output()
        .expect("run the isolated contracts fixture");
    assert!(
        output.status.success(),
        "contract fixture failed:\n{}\n{}",
        String::from_utf8_lossy(&output.stdout),
        String::from_utf8_lossy(&output.stderr)
    );
    let stdout = String::from_utf8(output.stdout).unwrap();
    let evidence: Vec<serde_json::Value> = stdout
        .lines()
        .filter_map(|line| line.split_once("SAGE_CONTRACT_EVIDENCE:"))
        .map(|(_, json)| serde_json::from_str(json).unwrap())
        .collect();
    assert_eq!(evidence.len(), 2, "expected cold and prewarmed reports");
    let root = "sage_contract_fixture::nodes::Root::run";
    let helper = "sage_contract_fixture::nodes::Helper::work";
    let leaf = "sage_contract_fixture::nodes::Leaf::read";
    for prewarmed in [false, true] {
        let sample = evidence
            .iter()
            .find(|sample| sample["prewarmed"] == prewarmed)
            .expect("each cache scenario must report evidence");
        let operations = &sample["model"]["operations"];
        assert!(operations[helper]["invokes"].as_array().unwrap().is_empty());
        assert_eq!(
            operations[root]["prohibits"][0]["targets"],
            serde_json::json!([leaf])
        );
        let report = &sample["contracts"];
        assert_eq!(report["calls_conform"], false);
        assert_eq!(report["coverage"]["checked_requests"], 3);
        assert!(report["coverage"]["gaps"].as_array().unwrap().is_empty());
        let violations = report["violations"].as_array().unwrap();
        assert_eq!(violations.len(), 2);
        assert_eq!(violations[0]["kind"], "UndeclaredCall");
        assert_eq!(violations[1]["kind"], "ForbiddenTransitive");
        assert_eq!(violations[1]["rule"]["operation"], root);
        assert_eq!(
            violations[1]["path"]
                .as_array()
                .unwrap()
                .iter()
                .map(|frame| frame["operation"].as_str().unwrap())
                .collect::<Vec<_>>(),
            [root, helper, leaf],
        );
        if prewarmed {
            let events = sample["query_events"].as_array().unwrap();
            assert!(events.iter().any(|event| {
                let event = event.as_str().unwrap();
                event.starts_with("return Leaf::read") && event.contains("[Reused]")
            }));
            assert!(
                !events
                    .iter()
                    .any(|event| event.as_str().unwrap().starts_with("execute Leaf::read"))
            );
        }
    }
}
}

See more source ↗

Implemented sage_meta::immediate_permission_does_not_override_an_active_ancestor_prohibition

crates/sage-meta/tests/runtime_contracts.rs · test:runtime_contracts

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.language.calls.forbidden)]
fn immediate_permission_does_not_override_an_active_ancestor_prohibition() {
    let model = model(
        r#"
        class Root { """Suspended query."""
            fn run() -> u32 { """Forbids the leaf.""" envelope {
                forbid transitive crate::Leaf::read;
            } }
        }
        class Helper { """Internal reexecution."""
            fn work() -> u32 { """May request the leaf.""" envelope {
                invokes crate::Leaf::read();
            } }
        }
        class Leaf { """Value."""
            fn read() -> u32 { """Read.""" envelope {} }
        }
    "#,
    );
    let mut checked = session(model, &["Root::run"]);
    let root = checked.enter("demo::Root::run", None);
    // Internal reexecution installs Helper beneath the suspended Root without
    // inventing a Root -> Helper source call. Helper's own request is permitted.
    let helper = checked.enter_validation("demo::Helper::work", None);
    let leaf = checked.enter("demo::Leaf::read", None);
    checked.exit(leaf);
    checked.exit(helper);
    checked.exit(root);
    let report = checked.finish();
    assert!(!report.calls_conform);
    assert_eq!(report.violations.len(), 1);
    assert_eq!(
        report.violations[0].kind,
        ViolationKind::ForbiddenTransitive
    );
    assert_eq!(
        report.violations[0].rule.as_ref().unwrap().operation,
        "demo::Root::run"
    );
    assert_eq!(
        report.violations[0]
            .path
            .iter()
            .map(|frame| frame.operation.as_str())
            .collect::<Vec<_>>(),
        ["demo::Root::run", "demo::Helper::work", "demo::Leaf::read"]
    );
}
}

See more source ↗

Implemented sage_meta::internal_reexecution_cannot_bypass_an_active_ancestor_prohibition

crates/sage-meta/tests/runtime_contracts.rs · test:runtime_contracts

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.language.calls.forbidden)]
fn internal_reexecution_cannot_bypass_an_active_ancestor_prohibition() {
    let mut session = session(model(FORBIDDEN), &["Root::run"]);
    let root = session.enter("demo::Root::run", None);
    // This execution may come from a memo created in an earlier unchecked
    // session. There is no source call to invent, but the restriction applies.
    let validation = session.enter_validation("demo::Leaf::read", None);
    session.exit(validation);
    session.exit(root);
    let report = session.finish();
    assert!(!report.calls_conform);
    assert!(report.coverage.gaps.is_empty());
    assert_eq!(report.coverage.checked_requests, 1);
    assert_eq!(report.coverage.validation_contexts, 1);
    assert_eq!(report.violations.len(), 1);
    assert_eq!(
        report.violations[0].kind,
        ViolationKind::ForbiddenTransitive
    );
    assert_eq!(
        report.violations[0].rule.as_ref().unwrap().operation,
        "demo::Root::run"
    );
    assert_eq!(report.violations[0].path[1].kind, EntryKind::Validation);
    assert!(report.violations[0].message.contains("execution"));
}
}

See more source ↗

Implemented sage_meta::reports_direct_and_ancestor_violation_with_complete_path_and_rule

crates/sage-meta/tests/runtime_contracts.rs · test:runtime_contracts

#![allow(unused)]
fn main() {
#[test]
#[sage::test(meta.language.calls.declared)]
#[sage::test(meta.language.calls.forbidden)]
fn reports_direct_and_ancestor_violation_with_complete_path_and_rule() {
    let mut session = session(model(FORBIDDEN), &["Root::run"]);
    let root = session.enter("demo::Root::run", Some("root:1"));
    let helper = session.enter("demo::Helper::work", Some("helper:2"));
    let leaf = session.enter("demo::Leaf::read", Some("leaf:3"));
    session.exit(leaf);
    session.exit(helper);
    session.exit(root);
    let report = session.finish();
    assert!(!report.calls_conform);
    assert_eq!(report.coverage.checked_requests, 3);
    assert_eq!(report.violations.len(), 2);
    assert_eq!(report.violations[0].kind, ViolationKind::UndeclaredCall);
    let forbidden = &report.violations[1];
    assert_eq!(forbidden.kind, ViolationKind::ForbiddenTransitive);
    assert_eq!(
        forbidden.rule.as_ref().unwrap().operation,
        "demo::Root::run"
    );
    assert_eq!(
        forbidden
            .path
            .iter()
            .map(|frame| frame.operation.as_str())
            .collect::<Vec<_>>(),
        ["demo::Root::run", "demo::Helper::work", "demo::Leaf::read"]
    );
    assert_eq!(forbidden.path[2].receiver.as_deref(), Some("leaf:3"));
    assert_eq!(report.trace.len(), 6);
}
}

See more source ↗

Review: Accepted · Codex /root/anchor_188.

Independently reassessed the complete prohibition claim and all two ordinary implementation entries and four ordinary tests. Exact byte comparisons against historical implementation_sources and test_sources confirmed unchanged contracts.rs, validate.rs, contracts test file and runtime_contracts test file; the historical rationale remains sufficient after current source inspection, rather than serving as an automatic approval. No TODO/N/A entries or deferred prerequisites exist.
resolve_contracts resolves prohibition targets (including inherited rules) separately from permissions and preserves the declaring operation, file and span. ContractSession checks every active ancestor's matching prohibitions on both requests and validation executions, after the independent immediate-caller check; an immediate permission cannot suppress a prohibition. Receiver restrictions are respected, with missing identity recorded as a nonconforming coverage gap. violation retains the full active path plus offending invocation and the original rule; finish marks violations nonconforming and assert_calls_conform exposes an error outside callbacks.
reports_direct_and_ancestor_violation_with_complete_path_and_rule asserts nonconformance, both undeclared and forbidden errors, the root rule, complete Root/Helper/Leaf path and leaf receiver. immediate_permission_does_not_override_an_active_ancestor_prohibition explicitly permits the helper's leaf request yet asserts exactly one forbidden error, ancestor rule and complete path. internal_reexecution_cannot_bypass_an_active_ancestor_prohibition checks validation execution beneath Root, a single forbidden error, rule owner, validation frame and execution message. real_salsa_contract_fixture directly asserts generated reports for cold and cached leaf requests, the forbidden target, nonconformance, rule owner and complete path; it also proves the warm leaf was reused without execution. Captured setup helpers, fixture queries/model, fixture evidence producer, expected forbidden trace and Salsa adapter confirm these are actual observed reports, not fabricated evidence. These assertions would detect skipping ancestors, letting direct permission override a prohibition, losing path/rule provenance, or omitting validation/cache observations.
Execution distinction: I ran review start/read, exact-source comparison commands and review record; I did not execute behavioral tests or a workspace build. Coordinator-reported 321 passing functional sage-meta tests and successful root cargo build are separate baseline execution evidence, not my own runs. No requested edits.

Browse meta anchors

116 anchors

Specification anchors and declared coverage
AnchorImplementationTests
meta (116)102 Implemented24 TODO103 Implemented36 TODO
meta.anchors (22)22 Implemented21 Implemented12 TODO
anchor_pagesImplementedImplementedTODO
book_explorerImplementedImplementedTODO
canonical_sourcesImplementedImplementedTODO
meta.anchors.content (7)7 Implemented7 Implemented
blocksImplementedImplemented
explicit_endImplementedImplemented
headingImplementedImplemented
literal_syntaxImplementedImplemented
next_anchorImplementedImplemented
source_endImplementedImplemented
unmatched_endImplementedImplemented
context_navigationImplementedImplementedTODO
evidence_statusImplementedImplementedTODO
explorer_navigationImplementedTODO
implementation_coverageImplementedImplementedTODO
implementation_referencesImplementedImplementedTODO
placeholder_statusImplementedImplementedTODO
point_excerptsImplementedImplementedTODO
region_balanceImplementedImplemented
region_excerptsImplementedImplementedTODO
test_coverageImplementedImplemented
test_referencesImplementedImplemented
unique_namesImplementedImplementedTODO
meta.book (21)10 Implemented18 TODO12 Implemented18 TODO
anchor_movesImplementedTODOImplementedTODO
authorityImplementedTODOImplementedTODO
browser_deliveryTODOImplementedTODO
browser_dependenciesTODOTODO
browser_rust_sourceTODOTODO
browser_searchTODOTODO
browser_serveTODOTODO
browser_structureTODOTODO
chapter_namesImplementedTODOImplementedTODO
crate_ownershipImplementedImplemented
crates_landingImplementedImplemented
entity_linksTODOTODO
index_groupsImplementedTODOImplementedTODO
index_namespace_pagesImplementedImplemented
index_rowsImplementedTODOImplementedTODO
index_statusImplementedTODOImplementedTODO
rfd_changesTODOTODO
sage_chaptersTODOImplementedTODO
self_descriptionTODOTODO
shared_modelImplementedTODOImplementedTODO
source_rolesTODOTODO
meta.contracts (4)4 Implemented3 TODO4 Implemented3 TODO
cache_invocationsImplementedTODOImplementedTODO
correspondenceImplementedImplemented
observation_coverageImplementedTODOImplementedTODO
validated_sessionImplementedTODOImplementedTODO
meta.language (39)39 Implemented39 Implemented
meta.language.calls (2)2 Implemented2 Implemented
declaredImplementedImplemented
forbiddenImplementedImplemented
meta.language.classes (3)3 Implemented3 Implemented
abstract_completeImplementedImplemented
override_signatureImplementedImplemented
single_inheritanceImplementedImplemented
meta.language.contexts (1)1 Implemented1 Implemented
inheritanceImplementedImplemented
meta.language.envelopes (7)7 Implemented7 Implemented
class_callsImplementedImplemented
createsImplementedImplemented
direct_callsImplementedImplemented
leafImplementedImplemented
permissionsImplementedImplemented
readsImplementedImplemented
receiver_callsImplementedImplemented
meta.language.fields (2)2 Implemented2 Implemented
context_stateImplementedImplemented
kindsImplementedImplemented
meta.language.methods (2)2 Implemented2 Implemented
kindsImplementedImplemented
proseImplementedImplemented
meta.language.model (3)3 Implemented3 Implemented
forbidden_pathsImplementedImplemented
inherited_prohibitionsImplementedImplemented
virtual_dispatchImplementedImplemented
meta.language.types (19)19 Implemented19 Implemented
argument_arityImplementedImplemented
declaration_proseImplementedImplemented
enum_variantsImplementedImplemented
field_proseImplementedImplemented
generic_parametersImplementedImplemented
member_commasImplementedImplemented
name_resolutionImplementedImplemented
opaque_representationImplementedImplemented
preludeImplementedImplemented
qualified_namesImplementedImplemented
recursive_valuesImplementedImplemented
struct_fieldsImplementedImplemented
tuplesImplementedImplemented
type_expressionsImplementedImplemented
unique_fieldsImplementedImplemented
unique_parametersImplementedImplemented
unique_variantsImplementedImplemented
unknown_namesImplementedImplemented
variant_proseImplementedImplemented
meta.reviews (27)27 Implemented27 Implemented
claim_textImplementedImplemented
complete_test_setImplementedImplemented
decisionsImplementedImplemented
fragment_associationsImplementedImplemented
fragment_formatImplementedImplemented
fragment_freshnessImplementedImplemented
gateImplementedImplemented
input_formatImplementedImplemented
input_fragmentsImplementedImplemented
output_formatImplementedImplemented
preparationImplementedImplemented
record_requiredImplementedImplemented
recorded_readsImplementedImplemented
recordingImplementedImplemented
review_delegationImplementedImplemented
review_diagnosticsImplementedImplemented
review_instructionsImplementedImplemented
review_scopeImplementedImplemented
selector_claimImplementedImplemented
selector_line_rangeImplementedImplemented
selector_testImplementedImplemented
selector_whole_fileImplementedImplemented
source_representationImplementedImplemented
stalenessImplementedImplemented
summary_formatImplementedImplemented
test_sourceImplementedImplemented
validation_layoutImplementedImplemented
meta.validation (3)3 TODO3 TODO
claim_specific_evidenceTODOTODO
independent_inspectionTODOTODO
review_packetsTODOTODO