requirements.integration.symposium
Requirements index · View definition
Requirement
For a Cargo workspace that depends on
habeas, interactivecargo agents syncMUST let the user enable Habeas’s plugin. Once enabled, it MUST make the skills shipped with the selected Habeas version available to configured agents. After the selected version changes,cargo agents syncMUST provide the skills shipped with the new version.
Rationale
The tests cover each obligation in requirements.integration.symposium.
Obligations and their tests
- Interactive
cargo agents synclets the user enable Habeas’s plugin in a workspace that depends onhabeas.tests/symposium_hook_smoke.py#def[main]builds a consumer Cargo project with ahabeasdependency and a local stand-in crate.- It runs
interactive_sync, which forks thesynccommand under a pty. The helper waits for the “Enable it?” prompt and answers it. It raises an error if the prompt never appeared or the process exited non-zero. mainthen asserts that the saved Symposium config recordsauto-enableandhabeas. It also asserts that the hook registration file exists.
- Once enabled, the skills shipped with the selected version are made available to configured agents.
maincomputes the skill names fromassets/skills. It requires at least one skill. For each name it asserts that.agents/skills/<name>/SKILL.mdexists and matches the shipped file byte for byte.tests/repository.rs#fn[published_package_contains_the_bundled_skills_and_ci_example]supports this obligation.- It runs
cargo package --listand reads the plugin’s skill source path from the manifest’spackage.metadata.symposiumtable. - It asserts that every
SKILL.mdunder that path ships in the package. It also asserts that the CI reference ships. - A published crate therefore carries the skills that Symposium installs.
- It runs
- After the selected version changes,
cargo agents syncprovides the new version’s skills.mainwaits out Symposium’s debounce and caching. It builds ahabeas-nextcrate with the version bumped and one skill’s content changed. It repoints the consumer at it.- It asserts through
cargo metadatathat the next version is selected. It runssymposium syncand asserts that the installed skill now equals the changed skill, byte for byte. - This would catch an implementation that kept the old skill after a version change.
Other points
- The smoke test runs in CI.
tests/repository.rs#fn[ci_tests_pull_requests_and_main_then_deploys_the_book_from_main]asserts that thesymposium-hookjob runspython3 tests/symposium_hook_smoke.py. - The
{test}markers are in place, so there is no marking gap. - The test cannot run without
cargo-agentsinstalled, but CI covers that, so it is not an adequacy gap. - I found no unacknowledged gap.
Inputs
Tests
Input 2: outline tests/repository.rs fn[published_package_contains_the_bundled_skills_and_ci_example]
- File:
tests/repository.rs - Selector:
fn[published_package_contains_the_bundled_skills_and_ci_example] - Kind:
fn tests/repository.rs:426–465
// {test}`requirements.integration.symposium`
// {test}`requirements.test-coverage.check.guidance`
#[test]
fn published_package_contains_the_bundled_skills_and_ci_example() {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
let output = Command::new("cargo")
.args(["package", "--list", "--allow-dirty", "--offline"])
.current_dir(root)
.output()
.unwrap();
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
let packaged = String::from_utf8(output.stdout).unwrap();
let manifest = repository_toml("Cargo.toml");
let source = manifest["package"]["metadata"]["symposium"]["skills"][0]["source"]["path"]
.as_str()
.unwrap();
let mut skills = 0;
for entry in fs::read_dir(root.join(source)).unwrap() {
let entry = entry.unwrap();
if entry.path().join("SKILL.md").is_file() {
let path = format!("{source}/{}/SKILL.md", entry.file_name().to_str().unwrap());
assert!(
packaged.lines().any(|file| file == path),
"package omits {path}"
);
skills += 1;
}
}
assert!(skills > 0, "the plugin's source directory contains skills");
assert!(
packaged
.lines()
.any(|file| file == format!("{source}/habeas/references/ci.md")),
"the CI reference must ship with the skill that links to it"
);
}
Input 3: 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."
)
Other sources
Input 1: requirements selection requirements.integration.symposium
requirements.integration.symposium:md/requirements/integration.md:48–50
:::{req} symposium
For a Cargo workspace that depends on `habeas`, interactive `cargo agents sync` MUST let the user enable Habeas's plugin. Once enabled, it MUST make the skills shipped with the selected Habeas version available to configured agents. After the selected version changes, `cargo agents sync` MUST provide the skills shipped with the new version.
:::
Input 4: outline tests/symposium_hook_smoke.py def[interactive_sync]
- File:
tests/symposium_hook_smoke.py - Selector:
def[interactive_sync] - Kind:
def tests/symposium_hook_smoke.py:1–62
#!/usr/bin/env python3
"""Exercise Habeas's local CLI, skills, and hook through a Symposium consumer.
Run with `python3 tests/symposium_hook_smoke.py`. Set SYMPOSIUM_BIN to test a
specific cargo-agents binary. The test gives Symposium a local executable
that runs the current checkout with Cargo, without installing the CLI.
"""
import errno
import json
import os
from pathlib import Path
import pty
import select
import shlex
import shutil
import signal
import subprocess
import sys
import tempfile
import time
def interactive_sync(symposium, project, env):
child, terminal = pty.fork()
if child == 0:
os.chdir(project)
os.execvpe(symposium, [symposium, "sync"], {**env, "TERM": "xterm"})
output = bytearray()
answered = False
status = None
deadline = time.monotonic() + 120
try:
while status is None and time.monotonic() < deadline:
ready, _, _ = select.select([terminal], [], [], 1)
if ready:
try:
chunk = os.read(terminal, 4096)
except OSError as error:
if error.errno != errno.EIO:
raise
chunk = b""
output.extend(chunk)
if b"Enable it?" in output and not answered:
os.write(terminal, b"\x1b[B\r")
answered = True
completed, result = os.waitpid(child, os.WNOHANG)
if completed:
status = result
if status is None:
os.kill(child, signal.SIGKILL)
os.waitpid(child, 0)
raise RuntimeError("Interactive Symposium sync timed out")
finally:
os.close(terminal)
if not answered or os.waitstatus_to_exitcode(status):
raise RuntimeError(
"Interactive Symposium sync did not enable Habeas:\n"
+ output.decode(errors="replace")
)
Input 5: outline tests/repository.rs fn[ci_tests_pull_requests_and_main_then_deploys_the_book_from_main]
- File:
tests/repository.rs - Selector:
fn[ci_tests_pull_requests_and_main_then_deploys_the_book_from_main] - Kind:
fn tests/repository.rs:315–380
// {test}`requirements.integration.ci`
// {test}`requirements.test-coverage.check.guidance`
#[test]
fn ci_tests_pull_requests_and_main_then_deploys_the_book_from_main() {
let workflow = repository_file(".github/workflows/ci.yml");
assert!(
workflow.contains("\non:\n push:\n branches: [main]\n pull_request:\n\n"),
"{workflow}"
);
let test = workflow_job(&workflow, "test-and-build");
let steps = [
"run: node --test .github/scripts/autofix.test.mjs",
"cargo build --release --locked -p habeas",
"cargo habeas coverage -- --locked --workspace",
"run: cargo habeas coverage-check",
"run: cargo test --locked --doc --workspace",
"run: mdbook test",
"run: mdbook build",
"uses: actions/upload-pages-artifact@v4",
];
let positions: Vec<_> = steps
.iter()
.map(|step| test.find(step).unwrap_or_else(|| panic!("{step}:\n{test}")))
.collect();
assert!(positions.is_sorted(), "{test}");
assert!(test.contains("with:\n path: book\n"), "{test}");
let workflow_yaml: serde_json::Value = serde_saphyr::from_str(&workflow).unwrap();
let gate = workflow_yaml["jobs"]["test-and-build"]["steps"]
.as_array()
.unwrap()
.iter()
.find(|step| step["run"] == "cargo habeas coverage-check")
.unwrap();
assert!(
gate.get("if").is_none(),
"check only after successful collection"
);
assert!(
gate.get("continue-on-error").is_none(),
"enforce coverage failures"
);
let hook = workflow_job(&workflow, "symposium-hook");
assert!(
hook.contains("run: python3 tests/symposium_hook_smoke.py"),
"{hook}"
);
let deploy = workflow_job(&workflow, "deploy");
assert!(
deploy.contains("if: github.event_name == 'push' && github.ref == 'refs/heads/main'"),
"{deploy}"
);
assert!(
deploy.contains("needs: [test-and-build, symposium-hook]"),
"{deploy}"
);
assert!(deploy.contains("uses: actions/deploy-pages@v4"), "{deploy}");
let book = repository_toml("book.toml");
assert_eq!(
book["output"]["html"]["site-url"].as_str(),
Some("/habeas-codicem/")
);
}