requirements.integration.symposium_setup_hook
Requirements index · View definition
Requirement
For an enabled Habeas plugin, a supported agent session started within a Cargo and mdBook project whose manifest lists
habeasunder[dev-dependencies], asadds it, MUST receive a Symposium
SessionStarthook. The hook MUST check whether the configuration and files required byrequirements.cli.setup,, and
are present and compatible. If not, it MUST provide nonblocking agent context saying that Habeas Codicem is not fully configured and suggesting
habeas setup. If setup is complete or no applicable project is found, it MUST provide no setup advisory. The hook MUST NOT modify project files or run setup itself.
Rationale
The reviewed tests cover each obligation in requirements.integration.symposium_setup_hook.
Hook delivery in a real Symposium session. tests/symposium_hook_smoke.py#def[main]/def[session_start] is marked {test}. It does the following:
- It builds a consumer project with
habeasunder[dev-dependencies]. - It runs an interactive
symposium syncto enable the plugin. - It checks that a
session-starthook is registered in.codex/hooks.json. - It runs the hook for a Codex
SessionStartand readsadditionalContext. - Before setup, it asserts the context contains “Habeas Codicem is not fully configured”.
- After
habeas setup, it asserts that text is gone.
Applicability and the no-advisory cases. tests/setup.rs#fn[session_start_advises_only_when_setup_is_incomplete] checks these cases:
- A project without Habeas gets an empty
SessionStart. - A project with
habeasonly under[dependencies]also gets an emptySessionStart. - A complete setup, run from a nested cwd, gets only the skill sentence and no setup advisory.
- A project whose
book.tomlhas been removed gets an emptySessionStart. coverage_setup_preserves_custom_index_and_preflights_conflictsshows no advisory when no separate coverage chapter exists.
Checking that configuration and files are present and compatible. The same test covers each item requirements.cli.setup, requirements.test-coverage.setup and requirements.test-coverage.setup.configuration require, one at a time:
- Stylesheet. A missing
md/habeas.cssand one with differing content both produce the advisory. Abook.tomlwithout theadditional-cssentry also produces it. - Preprocessor.
habeas mdbookreplaced bywrong-preprocessorproduces the advisory. - Fold setting. A missing
output.html.fold.enableproduces the advisory. An existingfalsevalue counts as complete, which matches “unless the book already sets it”. - Test file. A missing
tests/habeas.rsand one with differing content both produce the advisory. - Nextest configuration.
- In
coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter, a conflicting.config/nextest.toml(theall()filter changed totest(one)) produces the advisory. - In the same test, a deleted
.config/nextest.tomlalso produces it. - A repeat setup leaves the file unchanged, with no duplicate configuration.
- In
- Book source directory.
setup_uses_src_when_book_table_or_source_setting_is_absentchecks that the defaultsrcis honored and that a badbook.srcgives an advisory. - Coverage chapter. It is not required: with no
md/test-coverage.md, and withSUMMARY.mdreduced to# Summary, no advisory results.
Advisory content. The session_start_advises_only_when_setup_is_incomplete test asserts the context contains both “Habeas Codicem is not fully configured” and habeas setup. The session_start helper asserts the hook process exits successfully. The advisory is delivered as additionalContext, so it does not block the session.
MUST NOT modify files or run setup. After advisory runs, the tests assert the following:
- The stylesheet and
.config/nextest.tomlare not recreated. book.tomlis byte-identical.- The user-modified css and
tests/habeas.rskeep their content. - The conflicting nextest file is unchanged.
Residual points. There is no explicit assertion that the hook output lacks a blocking decision. The nonblocking obligation is checked only through the successful exit and the additionalContext form, with no block flag in the output. I don’t consider this a gap, because the output shape has no blocking field for the tests to check.
I found no unaddressed obligation or marking gap.
Inputs
Tests
Input 5: outline tests/setup.rs fn[coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter]
- File:
tests/setup.rs - Selector:
fn[coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter] - Kind:
fn tests/setup.rs:77–133
// {test}`requirements.test-coverage.setup`
// {test}`requirements.test-coverage.setup.configuration`
// {test}`requirements.test-coverage.check.guidance`
// {test}`requirements.test-coverage.check.exceptions.setup`
// {test}`requirements.integration.symposium_setup_hook`
#[test]
fn coverage_setup_is_idempotent_and_hook_needs_no_coverage_chapter() {
let temp = fixture();
let root = temp.path();
let local_crate = env!("CARGO_MANIFEST_DIR");
let summary = fs::read_to_string(root.join("md/SUMMARY.md")).unwrap();
run(root, &["setup", "--path", local_crate]);
let config = fs::read_to_string(root.join(".config/nextest.toml")).unwrap();
assert!(!root.join("md/test-coverage.md").exists());
assert_eq!(
fs::read_to_string(root.join("md/SUMMARY.md")).unwrap(),
summary
);
assert!(config.contains("coverage-process"));
run(root, &["setup", "--path", local_crate]);
assert_eq!(
fs::read_to_string(root.join("md/SUMMARY.md")).unwrap(),
summary
);
assert_eq!(
fs::read_to_string(root.join(".config/nextest.toml")).unwrap(),
config
);
assert!(!advises_setup(&session_start(root, root)));
let conflicting = config.replace("all()", "test(one)");
fs::write(root.join(".config/nextest.toml"), &conflicting).unwrap();
assert!(advises_setup(&session_start(root, root)));
assert_eq!(
fs::read_to_string(root.join(".config/nextest.toml")).unwrap(),
conflicting
);
fs::write(root.join(".config/nextest.toml"), config).unwrap();
fs::write(root.join("md/SUMMARY.md"), "# Summary\n").unwrap();
assert!(!advises_setup(&session_start(root, root)));
assert_eq!(
fs::read_to_string(root.join("md/SUMMARY.md")).unwrap(),
"# Summary\n"
);
fs::write(root.join("md/test-coverage.md"), "User's coverage notes.\n").unwrap();
run(root, &["setup", "--path", local_crate]);
assert_eq!(
fs::read_to_string(root.join("md/test-coverage.md")).unwrap(),
"User's coverage notes.\n"
);
assert!(!advises_setup(&session_start(root, root)));
fs::remove_file(root.join(".config/nextest.toml")).unwrap();
assert!(advises_setup(&session_start(root, root)));
assert!(
!root.join(".config/nextest.toml").exists(),
"hook must not repair configuration"
);
}
Input 6: outline tests/setup.rs fn[coverage_setup_preserves_custom_index_and_preflights_conflicts]
- File:
tests/setup.rs - Selector:
fn[coverage_setup_preserves_custom_index_and_preflights_conflicts] - Kind:
fn tests/setup.rs:135–193
// {test}`requirements.test-coverage.setup`
// {test}`requirements.test-coverage.setup.configuration`
// {test}`requirements.integration.symposium_setup_hook`
#[test]
fn coverage_setup_preserves_custom_index_and_preflights_conflicts() {
let temp = fixture();
let root = temp.path();
fs::write(
root.join("md/custom.md"),
"A custom report.\n\n:::{coverage-index}\n:::\n",
)
.unwrap();
fs::write(
root.join("md/SUMMARY.md"),
"# Summary\n\n- [Custom](custom.md)\n",
)
.unwrap();
run(root, &["setup", "--path", env!("CARGO_MANIFEST_DIR")]);
assert!(!root.join("md/test-coverage.md").exists());
assert!(
!advises_setup(&session_start(root, root)),
"setup requires no separate coverage chapter"
);
assert!(
fs::read_to_string(root.join("md/custom.md"))
.unwrap()
.starts_with("A custom report.")
);
let temp = fixture();
let root = temp.path();
fs::write(root.join("md/test-coverage.md"), "User content\n").unwrap();
let original_summary = fs::read_to_string(root.join("md/SUMMARY.md")).unwrap();
run(root, &["setup", "--path", env!("CARGO_MANIFEST_DIR")]);
assert!(root.join(".config/nextest.toml").exists());
assert_eq!(
fs::read_to_string(root.join("md/test-coverage.md")).unwrap(),
"User content\n"
);
assert_eq!(
fs::read_to_string(root.join("md/SUMMARY.md")).unwrap(),
original_summary
);
let temp = fixture();
let root = temp.path();
fs::write(root.join("md/unlinked.md"), ":::{coverage-index}\n:::\n").unwrap();
fs::write(
root.join("md/rules.md"),
"```text\n:::{coverage-index}\n:::\n```\n",
)
.unwrap();
run(root, &["setup", "--path", env!("CARGO_MANIFEST_DIR")]);
assert!(!root.join("md/test-coverage.md").exists());
assert!(
!fs::read_to_string(root.join("md/SUMMARY.md"))
.unwrap()
.contains("test-coverage.md")
);
}
Input 7: outline tests/setup.rs fn[setup_uses_src_when_book_table_or_source_setting_is_absent]
- File:
tests/setup.rs - Selector:
fn[setup_uses_src_when_book_table_or_source_setting_is_absent] - Kind:
fn tests/setup.rs:425–446
// {test}`requirements.cli.setup_project`
// {test}`requirements.integration.symposium_setup_hook`
// {test}`requirements.cli.setup`
#[test]
fn setup_uses_src_when_book_table_or_source_setting_is_absent() {
for configuration in ["", "[book]\ntitle = 'Example'\n"] {
let temp = fixture();
let project = temp.path();
fs::write(project.join("book.toml"), configuration).unwrap();
fs::write(project.join("src/SUMMARY.md"), "# Summary\n").unwrap();
run(project, &["setup", "--path", env!("CARGO_MANIFEST_DIR")]);
assert!(project.join("src/habeas.css").is_file());
assert_eq!(session_start(project, project), skill_sentence_only());
let mut book: toml_edit::DocumentMut = fs::read_to_string(project.join("book.toml"))
.unwrap()
.parse()
.unwrap();
book["book"]["src"] = toml_edit::value(7);
fs::write(project.join("book.toml"), book.to_string()).unwrap();
assert!(advises_setup(&session_start(project, project)));
}
}
Input 8: outline tests/setup.rs fn[session_start_advises_only_when_setup_is_incomplete]
- File:
tests/setup.rs - Selector:
fn[session_start_advises_only_when_setup_is_incomplete] - Kind:
fn tests/setup.rs:507–618
// {test}`requirements.integration.symposium_setup_hook`
#[test]
fn session_start_advises_only_when_setup_is_incomplete() {
let temp = fixture();
let project = temp.path();
assert_eq!(
session_start(project, project),
json!({"SessionStart": {}}),
"a project without Habeas must not receive an advisory"
);
let manifest = fs::read_to_string(project.join("Cargo.toml")).unwrap();
fs::write(
project.join("Cargo.toml"),
format!("{manifest}\n[dependencies]\nhabeas = \"0.2\"\n"),
)
.unwrap();
assert_eq!(
session_start(project, project),
json!({"SessionStart": {}}),
"only a Habeas dev dependency makes the hook applicable"
);
fs::write(project.join("Cargo.toml"), manifest).unwrap();
run(project, &["setup", "--path", env!("CARGO_MANIFEST_DIR")]);
let nested = project.join("src/nested");
fs::create_dir_all(&nested).unwrap();
assert_eq!(session_start(project, &nested), skill_sentence_only());
let css = project.join("md/habeas.css");
fs::remove_file(&css).unwrap();
let book = fs::read_to_string(project.join("book.toml")).unwrap();
let response = session_start(project, &nested);
let context = response["SessionStart"]["additionalContext"]
.as_str()
.unwrap();
assert!(context.contains("Habeas Codicem is not fully configured"));
assert!(context.contains("habeas setup"));
assert!(!css.exists(), "the hook must not recreate the stylesheet");
assert_eq!(fs::read_to_string(project.join("book.toml")).unwrap(), book);
fs::write(&css, include_str!("../md/habeas.css")).unwrap();
fs::write(
project.join("book.toml"),
book.replace("habeas mdbook", "wrong-preprocessor"),
)
.unwrap();
let response = session_start(project, &nested);
assert!(advises_setup(&response));
fs::write(project.join("book.toml"), &book).unwrap();
assert_eq!(session_start(project, &nested), skill_sentence_only());
let mut without_fold: toml_edit::DocumentMut = book.parse().unwrap();
without_fold["output"]["html"]["fold"]
.as_table_like_mut()
.unwrap()
.remove("enable");
fs::write(project.join("book.toml"), without_fold.to_string()).unwrap();
let response = session_start(project, &nested);
assert!(
advises_setup(&response),
"a book without `output.html.fold.enable` is not fully configured"
);
let mut disabled_fold = without_fold;
disabled_fold["output"]["html"]["fold"]["enable"] = toml_edit::value(false);
fs::write(project.join("book.toml"), disabled_fold.to_string()).unwrap();
assert_eq!(
session_start(project, &nested),
skill_sentence_only(),
"setup keeps an existing fold setting, so any value is complete"
);
// Each required file and the stylesheet entry is checked on its own.
fs::write(project.join("book.toml"), &book).unwrap();
let mut without_css: toml_edit::DocumentMut = book.parse().unwrap();
without_css["output"]["html"]["additional-css"] = toml_edit::value(toml_edit::Array::new());
fs::write(project.join("book.toml"), without_css.to_string()).unwrap();
assert!(
advises_setup(&session_start(project, &nested)),
"a book without the stylesheet entry is not fully configured"
);
fs::write(project.join("book.toml"), &book).unwrap();
let test = project.join("tests/habeas.rs");
let test_source = fs::read_to_string(&test).unwrap();
for (path, original) in [
(&css, include_str!("../md/habeas.css").to_owned()),
(&test, test_source),
] {
fs::write(path, "user content\n").unwrap();
assert!(
advises_setup(&session_start(project, &nested)),
"{} with different content is not compatible",
path.display()
);
assert_eq!(fs::read_to_string(path).unwrap(), "user content\n");
fs::remove_file(path).unwrap();
assert!(
advises_setup(&session_start(project, &nested)),
"a missing {} is not fully configured",
path.display()
);
assert!(
!path.exists(),
"the hook must not recreate {}",
path.display()
);
fs::write(path, original).unwrap();
assert_eq!(session_start(project, &nested), skill_sentence_only());
}
fs::remove_file(project.join("book.toml")).unwrap();
assert_eq!(session_start(project, &nested), json!({"SessionStart": {}}));
}
Input 9: outline tests/symposium_hook_smoke.py def[main]/def[session_start]
- File:
tests/symposium_hook_smoke.py - Selector:
def[main]/def[session_start] - Kind:
def tests/symposium_hook_smoke.py:95–187
# The stub crates below live outside the repository, so the vendored
# fork's relative path must point back into it.
fork_path = 'path = "vendor/habeas-rig"'
if manifest.count(fork_path) != 1:
raise AssertionError("Habeas's habeas-rig dependency changed")
manifest = manifest.replace(
fork_path, f"path = {json.dumps(str(repo / 'vendor' / 'habeas-rig'))}", 1
)
cargo_installation = (
'source = "cargo"\ncrate = "habeas"\n'
'executable = "habeas"\nglobal = true'
)
if manifest.count(cargo_installation) != 1:
raise AssertionError("Habeas's Cargo installation declaration changed")
(local_crate / "Cargo.toml").write_text(
manifest.replace(
cargo_installation,
f"executable = {json.dumps(str(runner))}",
1,
)
)
(local_crate / "src" / "lib.rs").write_text("")
shutil.copytree(source_skills, local_crate / "assets" / "skills")
(project / "Cargo.toml").write_text(
'[package]\nname = "habeas-hook-consumer"\nversion = "0.1.0"\n'
'edition = "2024"\n\n[dev-dependencies]\n'
f"habeas = {{ path = {json.dumps(str(local_crate))} }}\n"
)
(project / "Cargo.lock").write_bytes((repo / "Cargo.lock").read_bytes())
(project / "book.toml").write_text('[book]\nsrc = "md"\n')
(project / "md" / "SUMMARY.md").write_text("# Summary\n")
(project / "src" / "lib.rs").write_text("")
(symposium_home / "config.toml").write_text(
'auto-sync = false\nauto-update = "off"\nhook-scope = "project"\n'
'agents-syncing = false\n\n[[agent]]\nname = "codex"\n\n'
"[defaults]\nsymposium-recommendations = false\nuser-plugins = false\n"
)
env = os.environ.copy()
env["SYMPOSIUM_HOME"] = str(symposium_home)
metadata = subprocess.run(
[cargo, "metadata", "--format-version", "1", "--all-features"],
cwd=project,
env=env,
text=True,
capture_output=True,
)
if metadata.returncode:
raise RuntimeError(f"Consumer Cargo metadata failed:\n{metadata.stderr}")
current_version = next(
package["version"]
for package in json.loads(metadata.stdout)["packages"]
if package["name"] == "habeas"
)
major, minor, patch = map(int, current_version.split("."))
next_version = f"{major}.{minor}.{patch + 1}"
# {test}`requirements.integration.symposium_setup_hook`
interactive_sync(symposium, project, env)
saved_config = (symposium_home / "config.toml").read_text()
if "auto-enable" not in saved_config or "habeas" not in saved_config:
raise AssertionError("Symposium did not record the decision to enable Habeas")
hook_registration = project / ".codex" / "hooks.json"
if not hook_registration.is_file() or "session-start" not in hook_registration.read_text():
raise AssertionError("Symposium did not register its session-start hook")
last_stderr = ""
def session_start():
nonlocal last_stderr
payload = {
"hook_event_name": "SessionStart",
"session_id": "habeas-smoke-test",
"cwd": str(project),
}
result = subprocess.run(
[symposium, "-v", "hook", "codex", "session-start"],
cwd=project,
env=env,
input=json.dumps(payload),
text=True,
capture_output=True,
)
last_stderr = result.stderr
if result.returncode:
raise RuntimeError(
f"Symposium hook exited {result.returncode}:\n{result.stderr}"
)
try:
output = json.loads(result.stdout)
except json.JSONDecodeError as error:
raise RuntimeError(f"Invalid Symposium output: {result.stdout}") from error
return output.get("hookSpecificOutput", {}).get("additionalContext", "")
Input 13: outline tests/symposium_hook_smoke.py def[main]
- File:
tests/symposium_hook_smoke.py - Selector:
def[main] - Kind:
def tests/symposium_hook_smoke.py:65–291
def main():
repo = Path(__file__).resolve().parents[1]
cargo = shutil.which("cargo")
symposium = os.environ.get("SYMPOSIUM_BIN") or shutil.which("cargo-agents")
if cargo is None or symposium is None:
raise RuntimeError("cargo and cargo-agents must be installed")
with tempfile.TemporaryDirectory(prefix="habeas-symposium-hook-") as temporary:
root = Path(temporary)
project = root / "consumer"
symposium_home = root / "symposium-home"
local_crate = root / "habeas-current"
source_skills = repo / "assets" / "skills"
for directory in (
project / "md",
project / "src",
symposium_home,
local_crate / "src",
):
directory.mkdir(parents=True)
runner = root / "habeas-local"
runner.write_text(
"#!/bin/sh\n"
f"exec {shlex.quote(cargo)} run --locked --quiet "
f"--manifest-path {shlex.quote(str(repo / 'Cargo.toml'))} "
'--bin habeas -- "$@"\n'
)
runner.chmod(0o755)
manifest = (repo / "Cargo.toml").read_text()
# The stub crates below live outside the repository, so the vendored
# fork's relative path must point back into it.
fork_path = 'path = "vendor/habeas-rig"'
if manifest.count(fork_path) != 1:
raise AssertionError("Habeas's habeas-rig dependency changed")
manifest = manifest.replace(
fork_path, f"path = {json.dumps(str(repo / 'vendor' / 'habeas-rig'))}", 1
)
cargo_installation = (
'source = "cargo"\ncrate = "habeas"\n'
'executable = "habeas"\nglobal = true'
)
if manifest.count(cargo_installation) != 1:
raise AssertionError("Habeas's Cargo installation declaration changed")
(local_crate / "Cargo.toml").write_text(
manifest.replace(
cargo_installation,
f"executable = {json.dumps(str(runner))}",
1,
)
)
(local_crate / "src" / "lib.rs").write_text("")
shutil.copytree(source_skills, local_crate / "assets" / "skills")
(project / "Cargo.toml").write_text(
'[package]\nname = "habeas-hook-consumer"\nversion = "0.1.0"\n'
'edition = "2024"\n\n[dev-dependencies]\n'
f"habeas = {{ path = {json.dumps(str(local_crate))} }}\n"
)
(project / "Cargo.lock").write_bytes((repo / "Cargo.lock").read_bytes())
(project / "book.toml").write_text('[book]\nsrc = "md"\n')
(project / "md" / "SUMMARY.md").write_text("# Summary\n")
(project / "src" / "lib.rs").write_text("")
(symposium_home / "config.toml").write_text(
'auto-sync = false\nauto-update = "off"\nhook-scope = "project"\n'
'agents-syncing = false\n\n[[agent]]\nname = "codex"\n\n'
"[defaults]\nsymposium-recommendations = false\nuser-plugins = false\n"
)
env = os.environ.copy()
env["SYMPOSIUM_HOME"] = str(symposium_home)
metadata = subprocess.run(
[cargo, "metadata", "--format-version", "1", "--all-features"],
cwd=project,
env=env,
text=True,
capture_output=True,
)
if metadata.returncode:
raise RuntimeError(f"Consumer Cargo metadata failed:\n{metadata.stderr}")
current_version = next(
package["version"]
for package in json.loads(metadata.stdout)["packages"]
if package["name"] == "habeas"
)
major, minor, patch = map(int, current_version.split("."))
next_version = f"{major}.{minor}.{patch + 1}"
# {test}`requirements.integration.symposium_setup_hook`
interactive_sync(symposium, project, env)
saved_config = (symposium_home / "config.toml").read_text()
if "auto-enable" not in saved_config or "habeas" not in saved_config:
raise AssertionError("Symposium did not record the decision to enable Habeas")
hook_registration = project / ".codex" / "hooks.json"
if not hook_registration.is_file() or "session-start" not in hook_registration.read_text():
raise AssertionError("Symposium did not register its session-start hook")
last_stderr = ""
def session_start():
nonlocal last_stderr
payload = {
"hook_event_name": "SessionStart",
"session_id": "habeas-smoke-test",
"cwd": str(project),
}
result = subprocess.run(
[symposium, "-v", "hook", "codex", "session-start"],
cwd=project,
env=env,
input=json.dumps(payload),
text=True,
capture_output=True,
)
last_stderr = result.stderr
if result.returncode:
raise RuntimeError(
f"Symposium hook exited {result.returncode}:\n{result.stderr}"
)
try:
output = json.loads(result.stdout)
except json.JSONDecodeError as error:
raise RuntimeError(f"Invalid Symposium output: {result.stdout}") from error
return output.get("hookSpecificOutput", {}).get("additionalContext", "")
skill_sentence = (
"This project tracks requirements with Habeas; "
"load the `habeas` skill before starting any work."
)
# {test}`requirements.integration.symposium_skill_hook`
# {test}`requirements.integration.symposium_skill_hook.setup_state`
incomplete_context = session_start()
if (
not incomplete_context.startswith(skill_sentence)
or "Habeas Codicem is not fully configured" not in incomplete_context
):
status = subprocess.run(
[symposium, "status"],
cwd=project,
env=env,
text=True,
capture_output=True,
)
raise AssertionError(
"Symposium did not deliver Habeas's skill sentence and setup advisory. "
f"Agent output: {incomplete_context!r}\n"
f"Hook diagnostics: {last_stderr}\n"
f"Plugin status: {status.stdout}\n{status.stderr}"
)
subprocess.run(
[runner, "setup", "--path", str(repo)], cwd=project, check=True
)
configured_context = session_start()
if "Habeas Codicem is not fully configured" in configured_context:
raise AssertionError("Symposium kept advising setup after it was complete")
if configured_context.strip() != skill_sentence:
raise AssertionError(
"Symposium did not deliver only the skill sentence once setup was complete: "
f"{configured_context!r}"
)
# {test}`requirements.integration.symposium`
skills_dir = project / ".agents" / "skills"
skill_names = sorted(
path.name for path in source_skills.iterdir() if (path / "SKILL.md").is_file()
)
if not skill_names:
raise AssertionError("Habeas did not ship any skills")
for name in skill_names:
installed = skills_dir / name / "SKILL.md"
if not installed.is_file() or installed.read_bytes() != (
source_skills / name / "SKILL.md"
).read_bytes():
raise AssertionError(f"Symposium did not install the current {name} skill")
# Symposium 0.5.1 debounces skill comparisons for five seconds and
# caches workspace dependencies by whole-second Cargo.lock mtime.
time.sleep(6)
next_crate = root / "habeas-next"
(next_crate / "src").mkdir(parents=True)
(next_crate / "src" / "lib.rs").write_text("")
shutil.copytree(source_skills, next_crate / "assets" / "skills")
current_version_line = f'version = "{current_version}"'
if current_version_line not in manifest:
raise AssertionError("Cargo did not report the current Habeas version")
(next_crate / "Cargo.toml").write_text(
manifest.replace(current_version_line, f'version = "{next_version}"', 1)
)
changed_skill = next_crate / "assets" / "skills" / skill_names[0] / "SKILL.md"
changed_skill.write_text(changed_skill.read_text() + "\nUpdated in the next release.\n")
(project / "Cargo.toml").write_text(
'[package]\nname = "habeas-hook-consumer"\nversion = "0.1.0"\n'
'edition = "2024"\n\n[dev-dependencies]\n'
f"habeas = {{ path = {json.dumps(str(next_crate))} }}\n"
)
updated_metadata = subprocess.run(
[cargo, "metadata", "--format-version", "1", "--all-features"],
cwd=project,
env=env,
text=True,
capture_output=True,
)
if updated_metadata.returncode:
raise RuntimeError(f"Updated Cargo metadata failed:\n{updated_metadata.stderr}")
packages = json.loads(updated_metadata.stdout)["packages"]
if not any(
package["name"] == "habeas" and package["version"] == next_version
for package in packages
):
raise AssertionError("Cargo did not select the next Habeas version")
updated_sync = subprocess.run(
[symposium, "sync"],
cwd=project,
env=env,
text=True,
capture_output=True,
)
if updated_sync.returncode:
raise RuntimeError(f"Updated Symposium sync failed:\n{updated_sync.stderr}")
if (skills_dir / skill_names[0] / "SKILL.md").read_bytes() != changed_skill.read_bytes():
raise AssertionError("Symposium kept the old skill after the selected version changed")
print(
"Symposium dispatched the local CLI, installed current skills, refreshed changed skills, "
"pointed the agent to the habeas skill, and delivered setup advice only when needed."
)
Referenced definitions
Input 2: requirements selection requirements.cli.setup
requirements.cli.setup:md/requirements/cli.md:11–13
:::{req} setup
Running `habeas setup` in an existing Cargo and mdBook project MUST add Habeas as a dev dependency, configure `habeas mdbook` as its preprocessor, add the badge stylesheet, enable sidebar folding with `output.html.fold.enable` unless the book already sets it, and create `tests/habeas.rs` that calls `habeas::validate()`. Repeating setup MUST avoid duplicate configuration and MUST NOT overwrite a differing test or stylesheet. Setup MUST NOT install or modify agent skills.
:::
Input 3: requirements selection requirements.test-coverage.setup
requirements.test-coverage.setup:md/requirements/test-coverage.md:499–505
:::{req} setup
In addition to {cite}`requirements.cli.setup`, `habeas setup` MUST enable the
automatic coverage subchapter of {cite}`requirements.test-coverage.index`
without creating a separate coverage source chapter, adding a coverage
entry to `SUMMARY.md`, or requiring a coverage source directive.
Setup MUST preserve existing authored chapter contents and `SUMMARY.md`.
:::
Input 4: requirements selection requirements.test-coverage.setup.configuration
requirements.test-coverage.setup.configuration:md/requirements/test-coverage.md:514–522
:::{req} setup.configuration
`habeas setup` MUST configure native nextest settings in
`.config/nextest.toml` at the Cargo workspace root so the coverage workflow of
{cite}`requirements.test-coverage.run` routes each executed test attempt through
the per-process collector of {cite}`requirements.test-coverage.processes`.
Those settings MUST use nextest's own configuration format.
Repeating setup MUST avoid duplicate configuration, preserve unrelated nextest
settings, and report conflicting settings for review rather than overwrite them.
:::
Other sources
Input 1: requirements selection requirements.integration.symposium_setup_hook
requirements.integration.symposium_setup_hook:md/requirements/integration.md:56–58
:::{req} symposium_setup_hook
For an enabled Habeas plugin, a supported agent session started within a Cargo and mdBook project whose manifest lists `habeas` under `[dev-dependencies]`, as {cite}`requirements.cli.setup` adds it, MUST receive a Symposium `SessionStart` hook. The hook MUST check whether the configuration and files required by `requirements.cli.setup`, {cite}`requirements.test-coverage.setup`, and {cite}`requirements.test-coverage.setup.configuration` are present and compatible. If not, it MUST provide nonblocking agent context saying that Habeas Codicem is not fully configured and suggesting `habeas setup`. If setup is complete or no applicable project is found, it MUST provide no setup advisory. The hook MUST NOT modify project files or run setup itself.
:::
Input 10: 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()
}
Input 11: outline tests/setup.rs fn[skill_sentence_only]
- File:
tests/setup.rs - Selector:
fn[skill_sentence_only] - Kind:
fn tests/setup.rs:226–230
// {cite}`habeas:util`
/// The response for an applicable project whose setup is complete.
fn skill_sentence_only() -> Value {
json!({"SessionStart": {"additionalContext": SKILL_SENTENCE}})
}
Input 12: outline tests/setup.rs fn[advises_setup]
- File:
tests/setup.rs - Selector:
fn[advises_setup] - Kind:
fn tests/setup.rs:232–238
// {cite}`habeas:util`
/// Whether a session-start response carries the setup advisory.
fn advises_setup(response: &Value) -> bool {
response["SessionStart"]["additionalContext"]
.as_str()
.is_some_and(|context| context.contains("Habeas Codicem is not fully configured"))
}