Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

requirements.integration.symposium_skill_hook.not_applicable

Requirements index · View definition

evidence Valid

Requirement

When a session starts outside every Cargo and mdBook project, or within one whose manifest does not list habeas under [dev-dependencies], the hook MUST provide no agent context.

Rationale

The code and test satisfy requirements.integration.symposium_skill_hook.not_applicable; I found no gaps.

Obligation: the hook provides no agent context in two cases.

  • The session starts outside every Cargo and mdBook project.
  • The session starts inside a project whose manifest does not list habeas under [dev-dependencies].

Code: src/hook.rs#fn[session_start] carries the {impl} reference and calls session_start_response. That function returns {"SessionStart": {}}, with no additionalContext, in these situations:

  • No project found: setup::find_project_root returns None. It looks through cwd.ancestors() for a directory with both Cargo.toml and book.toml. A directory outside any Cargo and mdBook project therefore gets no context.
  • No dev-dependency: setup::project_depends_on_habeas is false. It parses Cargo.toml and passes only if [dev-dependencies] contains habeas, via has_habeas_dev_dependency. A habeas entry under [dependencies] or [build-dependencies], or an unparseable manifest, therefore gets no context.
  • No SessionStart input: the function returns the same empty object. The requirement does not address this case, and the output is just the no-context response.

Both helpers are reachable from the {impl} item, so they need no reference of their own.

Test: tests/setup.rs#fn[session_start_gives_no_context_outside_habeas_projects] carries {test} references to this requirement and to the runtime_dependency_only example. It runs the real habeas hook session-start binary through the session_start helper. It asserts the empty SessionStart response in each of these cases:

  • a directory outside any project;
  • a project without habeas, started from a nested working directory;
  • habeas only under [dependencies];
  • habeas only under [build-dependencies];
  • a [dev-dependencies] entry but no book.toml, so not an mdBook project.

The runtime_dependency_only example adds no obligation beyond these. The same test covers its [dependencies]-only case.

Inputs

Implementation

Input 3: outline src/hook.rs fn[session_start]
// {impl}`requirements.integration.symposium_skill_hook`
// {impl}`requirements.integration.symposium_skill_hook.setup_state`
// {impl}`requirements.integration.symposium_skill_hook.not_applicable`
pub(crate) fn session_start() -> Result<(), Box<dyn Error>> {
    let input: Value = serde_json::from_reader(io::stdin()).unwrap_or(Value::Null);
    let response = session_start_response(&input, &std::env::current_dir()?);
    serde_json::to_writer(io::stdout().lock(), &response)?;
    Ok(())
}

Tests

Input 2: requirements selection requirements.integration.symposium_skill_hook.runtime_dependency_only
:::{example} symposium_skill_hook.runtime_dependency_only
A Cargo and mdBook project that lists `habeas` only under `[dependencies]` gets no session-start agent context, neither the skill sentence nor a setup advisory. {test}`requirements.integration.symposium_skill_hook.not_applicable`
:::
Input 4: outline tests/setup.rs fn[session_start_gives_no_context_outside_habeas_projects]
  • File: tests/setup.rs
  • Selector: fn[session_start_gives_no_context_outside_habeas_projects]
  • Kind: fn
  • tests/setup.rs:676–721
// {test}`requirements.integration.symposium_skill_hook.not_applicable`
// {test}`requirements.integration.symposium_skill_hook.runtime_dependency_only`
#[test]
fn session_start_gives_no_context_outside_habeas_projects() {
    let no_context = json!({"SessionStart": {}});

    let outside = TempDir::new().unwrap();
    assert_eq!(
        session_start(outside.path(), outside.path()),
        no_context,
        "a directory outside every Cargo and mdBook project"
    );

    let temp = fixture();
    let project = temp.path();
    let manifest = fs::read_to_string(project.join("Cargo.toml")).unwrap();
    let nested = project.join("src/nested");
    fs::create_dir_all(&nested).unwrap();
    assert_eq!(
        session_start(project, &nested),
        no_context,
        "a project that does not list Habeas"
    );

    for table in ["dependencies", "build-dependencies"] {
        fs::write(
            project.join("Cargo.toml"),
            format!("{manifest}\n[{table}]\nhabeas = \"0.2\"\n"),
        )
        .unwrap();
        assert_eq!(
            session_start(project, project),
            no_context,
            "a project listing Habeas only under [{table}]"
        );
    }

    // A Habeas dev dependency outside an mdBook project is not applicable either.
    fs::write(
        project.join("Cargo.toml"),
        format!("{manifest}\n[dev-dependencies]\nhabeas = \"0.2\"\n"),
    )
    .unwrap();
    fs::remove_file(project.join("book.toml")).unwrap();
    assert_eq!(session_start(project, project), no_context);
}

Other sources

Input 1: requirements selection requirements.integration.symposium_skill_hook.not_applicable
:::{req} symposium_skill_hook.not_applicable
When a session starts outside every Cargo and mdBook project, or within one whose manifest does not list `habeas` under `[dev-dependencies]`, the hook MUST provide no agent context.
:::