requirements.integration.symposium_skill_hook.runtime_dependency_only
Requirements index · View definition
Example
A Cargo and mdBook project that lists
habeasonly under[dependencies]gets no session-start agent context, neither the skill sentence nor a setup advisory.
Rationale
The example is covered by tests/setup.rs#fn[session_start_gives_no_context_outside_habeas_projects], which carries a {test} reference to requirements.integration.symposium_skill_hook.runtime_dependency_only.
Setup. fixture() builds a Cargo project (Cargo.toml, src/main.rs) that is also an mdBook project (book.toml, md/SUMMARY.md). The test appends [dependencies]\nhabeas = "0.2" to the manifest. That matches the scenario: both project kinds, with habeas listed only under [dependencies]. The same loop also covers [build-dependencies].
Run. session_start() runs the real habeas hook session-start binary. It passes a SessionStart JSON on stdin with cwd set to the project, and it asserts the process succeeded.
Assertion. The test asserts the output equals {"SessionStart": {}}. That output contains no context at all, so it has neither the skill sentence nor a setup advisory. The example states both outcomes, and this single equality covers both.
The test also checks the neighbouring cases of the cited requirement: a directory outside any project, a project that doesn’t list habeas, and a dev-dependency without mdBook.
Inputs
Tests
Input 2: 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.runtime_dependency_only
requirements.integration.symposium_skill_hook.runtime_dependency_only:md/requirements/integration.md:80–82
:::{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 3: requirements selection requirements.integration.symposium_skill_hook.not_applicable
requirements.integration.symposium_skill_hook.not_applicable:md/requirements/integration.md:76–78
:::{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.
:::
Input 4: outline tests/setup.rs fn[fixture]
- File:
tests/setup.rs - Selector:
fn[fixture] - Kind:
fn tests/setup.rs:9–27
// {cite}`habeas:util`
fn fixture() -> TempDir {
let temp = TempDir::new().unwrap();
fs::create_dir_all(temp.path().join("src")).unwrap();
fs::create_dir_all(temp.path().join("md")).unwrap();
fs::write(
temp.path().join("Cargo.toml"),
"[package]\nname = \"sample-project\"\nversion = \"0.1.0\"\nedition = \"2024\"\n",
)
.unwrap();
fs::write(temp.path().join("src/main.rs"), "fn main() {}\n").unwrap();
fs::write(
temp.path().join("book.toml"),
"[book]\nsrc = \"md\"\n\n[output.html]\nadditional-css = [\"md/custom.css\"]\n",
)
.unwrap();
fs::write(temp.path().join("md/SUMMARY.md"), "# Summary\n").unwrap();
temp
}
Input 5: outline tests/setup.rs fn[session_start]
- File:
tests/setup.rs - Selector:
fn[session_start] - Kind:
fn tests/setup.rs:45–73
// {cite}`habeas:util`
fn session_start(project: &Path, cwd: &Path) -> Value {
let mut child = Command::new(env!("CARGO_BIN_EXE_habeas"))
.args(["hook", "session-start"])
.current_dir(project)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.unwrap();
let input = json!({
"SessionStart": {
"session_id": "test-session",
"cwd": cwd,
}
});
child
.stdin
.take()
.unwrap()
.write_all(&serde_json::to_vec(&input).unwrap())
.unwrap();
let output = child.wait_with_output().unwrap();
assert!(
output.status.success(),
"hook failed: {}",
String::from_utf8_lossy(&output.stderr)
);
serde_json::from_slice(&output.stdout).unwrap()
}