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.configuration.workspace_structure

Requirements index · View definition

evidence Valid

Requirement

impl requirements.configuration.feature_sections habeas.toml MUST serialize WorkspaceConfig as UTF-8 TOML with version = 1. Its supported feature tables are [authoring], [coverage], and [evidence]; each MAY be absent. [coverage] has one optional key, reauthorings, under cite requirements.references.coverage.history; it has no user-file counterpart or invocation option, and no operation requires it. Unknown keys, unsupported versions, and invalid field types MUST produce a diagnostic identifying the file and setting. Invalid TOML, including content that is not UTF-8, MUST produce a diagnostic identifying the file, with the line and column of a syntax error. Features MUST define their own data structures and loading rules under cite requirements.configuration.feature_sections. A file containing only version = 1 MUST be valid. Habeas settings MUST NOT require a [habeas] table inside book.toml.

Rationale

The reviewed tests cover each obligation in requirements.configuration.workspace_structure. I did not request any implementation source.

  • Serialization as UTF-8 TOML with version = 1:
    • tests/configuration.rs#fn[workspace_discovery_uses_nearest_file_without_merging_or_rewriting_it] calls to_toml() and re-parses the output with WorkspaceConfig::parse. The result equals the original config, and the serialized text omits the empty configs.
    • It also asserts that loading leaves the file byte-for-byte unchanged.
    • Parsing only accepts version = 1, so the round trip shows the serialized form carries that version.
  • Optional tables: tests/configuration.rs#fn[feature_sections_are_scoped_and_absent_sections_use_defaults] parses version = 1 alone. It asserts that authoring, evidence and coverage are all None. It also covers an absent or empty [evidence] table, and an absent authoring section in UserConfig.
  • [coverage] has the single reauthorings key and no user-file counterpart:
    • fn[feature_sections_are_scoped_and_absent_sections_use_defaults] parses reauthorings = 5 and rejects reauthorings = 0.
    • It rejects allow inside [coverage] and a top-level reauthorings.
    • It asserts that UserConfig::parse rejects [coverage].
    • tests/coverage.rs#fn[an_invalid_coverage_table_is_a_validation_finding_but_authoring_proceeds] shows that an invalid [coverage] table, including an unknown window key, is reported as a validation finding naming habeas.toml and the setting. Authoring still succeeds, which supports “no operation requires it”.
  • Unknown keys, unsupported versions and invalid types name the file and setting:
    • tests/configuration.rs#fn[workspace_diagnostics_identify_the_file_and_setting] loops over version = '1' and version = 2. It also covers unknown top-level, authoring, evidence and coverage keys, and wrongly typed authoring.default, authoring.configs.cloud, evidence.disallow and evidence.allow[0].
    • It asserts that every message starts with <file>: <setting>, through load_workspace_config, WorkspaceConfig::parse, load_coverage_reauthorings and load_workspace_evidence.
    • tests/evidence_boundaries.rs#fn[validation_checks_workspace_common_config_without_loading_unused_authoring_settings] and tests/commands.rs#fn[status_loads_nearest_workspace_file_without_validating_authoring] check the same at the validation and CLI level.
  • Invalid TOML names the file and the line and column: fn[workspace_diagnostics_identify_the_file_and_setting] writes non-UTF-8 bytes and asserts that the error contains the file path. It writes a syntax error and asserts the text invalid TOML syntax at line 2, column after the file name. The status and validation tests also cover malformed TOML.
  • A file with only version = 1 is valid: this is covered by fn[feature_sections_are_scoped_and_absent_sections_use_defaults] and by tests/configuration.rs#fn[evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials]. The authoring CLI test works with a minimal workspace file.
  • No [habeas] table is required in book.toml: tests/configuration.rs#fn[absent_and_minimal_configuration_are_distinct_and_read_only] shows that ProjectConfig::from_book_toml on a book without [habeas] returns None, which is not an error. The CLI tests run status and validation with no such table.
  • Feature-owned structures and loading rules: the citation of requirements.configuration.feature_sections delegates these obligations. The scoping tests also show that fields stay within their own sections and that evidence loading does not reinterpret authoring settings.

I found no plausible violation of the requirement text that these assertions would accept.

Inputs

Tests

Input 4: outline tests/authoring_cli.rs fn[authoring_uses_nearest_workspace_configuration_without_a_user_file]
// {test}`requirements.configuration.workspace_location`
// {test}`requirements.authoring.configuration`
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.authoring.configuration_precedence`
// {test}`requirements.authoring.credentials`
// {test}`requirements.authoring.provider`
// {test}`requirements.authoring.rig_configuration_mapping`
// {test}`requirements.authoring.invocation`
// {test}`requirements.authoring.usage_storage`
// {test}`requirements.configuration.serialization`
#[test]
// {test}`requirements.configuration.documentation`
fn authoring_uses_nearest_workspace_configuration_without_a_user_file() {
    let server = Server::start(vec![reply(vec![call(
        "submit",
        "submit_judgment",
        json!({"determination":true,"rationale":"The supplied sources support the subject."}),
    )])]);
    let fixture = Fixture::new(&server.endpoint);
    fs::remove_file(fixture.config.join("habeas/config.toml")).unwrap();
    fs::write(
        fixture.project.join("habeas.toml"),
        "version = 1\n[authoring]\ndefault = 'missing-parent-choice'\n",
    )
    .unwrap();
    let nested = fixture.project.join("src/nested");
    fs::create_dir(&nested).unwrap();
    let workspace = nested.join("habeas.toml");
    fs::write(
        &workspace,
        format!(
            "version = 1\n[authoring]\ndefault = 'workspace'\n[authoring.configs.workspace]\npolicy = 'once'\nbackend = 'ollama'\nmodel = 'workspace-model'\nendpoint = '{}'\napi_key = 'WORKSPACE_LITERAL_KEY'\n",
            server.endpoint
        ),
    )
    .unwrap();
    let configurations = [fixture.project.join("habeas.toml"), workspace.clone()];
    let before = configurations
        .iter()
        .map(|path| fs::read(path).unwrap())
        .collect::<Vec<_>>();
    let output = fixture
        .command()
        .current_dir(&nested)
        .args(["author", SUBJECT])
        .output()
        .unwrap();
    assert!(output.status.success(), "{output:?}");
    // Running the configured feature rewrites neither configuration file,
    // and creates no user configuration.
    for (path, before) in configurations.iter().zip(&before) {
        assert_eq!(&fs::read(path).unwrap(), before, "{}", path.display());
    }
    assert!(!fixture.config.join("habeas/config.toml").exists());
    let requests = server.finish();
    assert_eq!(requests.len(), 1);
    assert_eq!(requests[0].body["model"], "workspace-model");
    assert!(requests[0].headers.contains("WORKSPACE_LITERAL_KEY"));
    assert!(
        !requests[0]
            .body
            .to_string()
            .contains("WORKSPACE_LITERAL_KEY")
    );
    let usage = fixture.usage();
    assert_eq!(usage["model"], "workspace-model");
    for text in [
        usage.to_string(),
        String::from_utf8_lossy(&output.stdout).into_owned(),
        String::from_utf8_lossy(&output.stderr).into_owned(),
    ] {
        assert!(!text.contains("WORKSPACE_LITERAL_KEY"), "{text}");
    }
}
Input 5: outline tests/commands.rs fn[status_loads_nearest_workspace_file_without_validating_authoring]
  • File: tests/commands.rs
  • Selector: fn[status_loads_nearest_workspace_file_without_validating_authoring]
  • Kind: fn
  • tests/commands.rs:223–269
// {test}`requirements.configuration.workspace_location`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.authoring.deterministic_validation`
// {test}`requirements.cli.status`
// {test}`requirements.ci.errors`
#[test]
fn status_loads_nearest_workspace_file_without_validating_authoring() {
    let temp = fixture();
    let nested = temp.path().join("src/nested");
    fs::write(temp.path().join("habeas.toml"), "version = 99\n").unwrap();
    fs::write(
        nested.join("habeas.toml"),
        "version = 1\n[authoring]\nconfigs = 'invalid but unused'\n",
    )
    .unwrap();
    let output = habeas(&nested, &["status"]);
    assert!(output.status.success(), "{output:?}");

    // An invalid workspace file is one validation finding: `status` and
    // `info` still run and report the checks that do not depend on it.
    for args in [["status"].as_slice(), ["info", "requirements.*"].as_slice()] {
        let output = habeas(temp.path(), args);
        assert!(output.status.success(), "{args:?}: {output:?}");
        let text = String::from_utf8(output.stdout).unwrap();
        assert!(
            text.contains("habeas.toml: version: expected version = 1"),
            "{args:?}: {text}"
        );
        assert!(
            text.contains("evidence/requirements.malformed.json: invalid JSON"),
            "{args:?}: {text}"
        );
    }

    fs::write(temp.path().join("habeas.toml"), "version = 1\n").unwrap();
    fs::write(nested.join("habeas.toml"), "version = [\n").unwrap();
    let output = habeas(&nested, &["status"]);
    assert!(output.status.success(), "{output:?}");
    let text = String::from_utf8(output.stdout).unwrap();
    assert!(
        text.contains(&nested.join("habeas.toml").display().to_string())
            && text.contains("evidence/requirements.malformed.json: invalid JSON"),
        "{text}"
    );
}
Input 6: outline tests/configuration.rs fn[absent_and_minimal_configuration_are_distinct_and_read_only]
// {test}`requirements.configuration.structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.configuration.serialization`
// {test}`requirements.configuration.workspace_structure`
#[test]
// {test}`requirements.configuration.documentation`
fn absent_and_minimal_configuration_are_distinct_and_read_only() {
    let dir = tempfile::tempdir().unwrap();
    let path = dir.path().join("user.toml");
    assert!(load_user_config(&path).unwrap().is_none());
    assert!(!path.exists());
    let original = "# keep this comment\nversion = 1\n";
    fs::write(&path, original).unwrap();
    let config = load_user_config(&path).unwrap().unwrap();
    assert!(config.authoring.is_none());
    assert_eq!(fs::read_to_string(&path).unwrap(), original);
    assert_eq!(
        UserConfig::parse(&config.to_toml().unwrap(), &path).unwrap(),
        config
    );
    let book = "[book]\nsrc = 'docs'\n";
    assert!(
        ProjectConfig::from_book_toml(book, &path)
            .unwrap()
            .is_none()
    );
    assert_eq!(
        ProjectConfig::from_book_toml(&format!("{book}\n[habeas]\n"), &path).unwrap(),
        Some(ProjectConfig {})
    );
    assert!(ProjectConfig::from_book_toml("[habeas]\nversion = 1\n", &path).is_err());
    let malformed = "version = [\n";
    fs::write(&path, malformed).unwrap();
    let error = load_user_config(&path).unwrap_err().to_string();
    assert!(error.contains("invalid TOML syntax"), "{error}");
    assert!(error.contains(path.to_str().unwrap()), "{error}");
    assert_eq!(fs::read_to_string(&path).unwrap(), malformed);
}
Input 7: outline tests/configuration.rs fn[workspace_discovery_uses_nearest_file_without_merging_or_rewriting_it]
// {test}`requirements.configuration.workspace_location`
// {test}`requirements.authoring.configuration_serialization`
// {test}`requirements.authoring.configuration_structure`
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.configuration.serialization`
#[test]
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.documentation`
fn workspace_discovery_uses_nearest_file_without_merging_or_rewriting_it() {
    let temp = tempfile::tempdir().unwrap();
    let project = temp.path().join("project");
    let nested = project.join("nested/deep");
    fs::create_dir_all(&nested).unwrap();
    let outer = temp.path().join("habeas.toml");
    fs::write(&outer, "version = 1\n[evidence]\nallow = ['outer']\n").unwrap();
    let inherited = load_workspace_config(&project).unwrap().unwrap();
    assert_eq!(inherited.path, outer);
    assert_eq!(inherited.root, temp.path().canonicalize().unwrap());
    let path = project.join("nested/habeas.toml");
    let text = "# preserved\nversion = 1\n[authoring]\ndefault = 'cloud'\n[evidence]\ndisallow = ['private']\n";
    fs::write(&path, text).unwrap();
    let closest = load_workspace_config(&nested).unwrap().unwrap();
    assert_eq!(closest.path, path);
    assert_eq!(closest.root, path.parent().unwrap());
    assert!(
        closest
            .config
            .authoring
            .as_ref()
            .unwrap()
            .configs
            .is_empty()
    );
    assert!(closest.config.evidence.as_ref().unwrap().allow.is_empty());
    assert_eq!(
        closest.config.evidence.as_ref().unwrap().disallow,
        vec![Path::new("private")]
    );
    assert_eq!(fs::read_to_string(&path).unwrap(), text);
    let serialized = closest.config.to_toml().unwrap();
    assert!(!serialized.contains("configs"));
    assert_eq!(
        WorkspaceConfig::parse(&serialized, &path).unwrap(),
        closest.config
    );

    fs::write(&path, "version = 1\n[evidence\n").unwrap();
    let error = load_workspace_config(&nested).unwrap_err().to_string();
    assert!(error.contains(path.to_str().unwrap()), "{error}");
    assert!(error.contains("invalid TOML"), "{error}");
    assert_eq!(
        fs::read_to_string(&path).unwrap(),
        "version = 1\n[evidence\n"
    );
    fs::remove_file(path).unwrap();
    fs::remove_file(outer).unwrap();
    assert!(load_workspace_config(&nested).unwrap().is_none());
}
Input 8: outline tests/configuration.rs fn[evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials]
  • File: tests/configuration.rs
  • Selector: fn[evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials]
  • Kind: fn
  • tests/configuration.rs:476–517
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.loading`
// {test}`requirements.authoring.credentials`
#[test]
fn evidence_configuration_ignores_unused_authoring_settings_and_detects_credentials() {
    let temp = tempfile::tempdir().unwrap();
    let path = temp.path().join("habeas.toml");
    fs::write(&path, "version = 1\n[evidence]\nallow = ['generated', '../shared']\ndisallow = ['generated/private']\n[authoring.configs.cloud]\nbackend = 'unknown'\ncredentials = 'DO_NOT_PRINT_THIS_CREDENTIAL'\n").unwrap();
    let policy = load_workspace_evidence(temp.path()).unwrap().unwrap();
    assert_eq!(policy.path, path);
    assert_eq!(policy.root, temp.path().canonicalize().unwrap());
    assert_eq!(
        policy.evidence.allow,
        vec![Path::new("generated"), Path::new("../shared")]
    );
    assert!(policy.contains_credentials);
    let error = load_workspace_config(temp.path()).unwrap_err().to_string();
    assert!(!error.contains("DO_NOT_PRINT_THIS_CREDENTIAL"), "{error}");

    fs::write(&path, "version = 1\n[authoring]\ndefault = 123\n").unwrap();
    assert!(
        !load_workspace_evidence(temp.path())
            .unwrap()
            .unwrap()
            .contains_credentials
    );
    assert!(load_workspace_config(temp.path()).is_err());
    for source in [
        "version = 2",
        "version = 1\nunknown = true",
        "version = 1\n[evidence]\nallow = ['']",
        "version = 1\n[evidence]\ndisallow = [42]",
        "version = 1\n[evidence]\nunknown = []",
    ] {
        fs::write(&path, source).unwrap();
        let error = load_workspace_evidence(temp.path())
            .unwrap_err()
            .to_string();
        assert!(error.contains(path.to_str().unwrap()), "{error}");
    }
}
Input 9: outline tests/configuration.rs fn[workspace_defaults_and_configs_combine_with_existing_user_selections]
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.authoring.configuration`
// {test}`requirements.authoring.configuration_precedence`
// {test}`requirements.authoring.configuration_storage`
// {test}`requirements.configuration.serialization`
#[test]
fn workspace_defaults_and_configs_combine_with_existing_user_selections() {
    let temp = tempfile::tempdir().unwrap();
    let root = temp.path().canonicalize().unwrap();
    let user_path = root.join("user.toml");
    let mut user = UserConfig::parse("version = 1\n[authoring]\ndefault = 'user'\n[authoring.configs.user]\nbackend = 'bedrock'\nmodel = 'user-model'\naws_profile = 'user-profile'\n[authoring.configs.shared]\nbackend = 'bedrock'\nmodel = 'old-model'\nregion = 'us-west-2'\nconcurrency = 7\noptions = { temperature = 0.25, top_p = 0.5 }\n", &user_path).unwrap();
    let path = root.join("habeas.toml");
    fs::write(&path, "version = 1\n[authoring]\ndefault = 'workspace'\n[authoring.configs.workspace]\nbackend = 'ollama'\nmodel = 'workspace-model'\n[authoring.configs.shared]\nbackend = 'ollama'\nmodel = 'replacement'\noptions = { temperature = 0.8 }\n").unwrap();
    let mut workspace = load_workspace_config(&root).unwrap().unwrap();
    let selected = resolve_authoring_with_workspace_from(
        &user_path,
        Some(&user),
        Some(&workspace),
        &root,
        None,
    )
    .unwrap();
    assert_eq!(selected.name, "workspace");
    assert_eq!(selected.config_path, path);
    let replaced = resolve_authoring_with_workspace_from(
        &user_path,
        Some(&user),
        Some(&workspace),
        &root,
        Some("shared"),
    )
    .unwrap();
    assert_eq!(replaced.config_path, path);
    assert_eq!(replaced.concurrency, None);
    assert_eq!(
        replaced.backend.options_json().unwrap(),
        serde_json::json!({"temperature":0.8})
    );
    assert!(
        matches!(&replaced.backend, BackendConfig::Ollama(config) if config.model == "replacement" && config.endpoint.is_none())
    );

    user.authoring.as_mut().unwrap().projects.insert(
        root.clone(),
        habeas::config::ProjectSelection {
            config: "user".into(),
        },
    );
    let project = resolve_authoring_with_workspace_from(
        &user_path,
        Some(&user),
        Some(&workspace),
        &root,
        None,
    )
    .unwrap();
    assert_eq!(project.name, "user");
    assert_eq!(project.config_path, user_path);
    let explicit = resolve_authoring_with_workspace_from(
        &user_path,
        Some(&user),
        Some(&workspace),
        &root,
        Some("workspace"),
    )
    .unwrap();
    assert_eq!(explicit.name, "workspace");
    user.authoring.as_mut().unwrap().projects.clear();
    workspace.config.authoring.as_mut().unwrap().default = Some("user".into());
    let user_reference = resolve_authoring_with_workspace_from(
        &user_path,
        Some(&user),
        Some(&workspace),
        &root,
        None,
    )
    .unwrap();
    assert_eq!(user_reference.name, "user");
    assert_eq!(user_reference.config_path, user_path);
    workspace.config.authoring.as_mut().unwrap().default = None;
    assert_eq!(
        resolve_authoring_with_workspace_from(
            &user_path,
            Some(&user),
            Some(&workspace),
            &root,
            None
        )
        .unwrap()
        .name,
        "user"
    );
    workspace.config.authoring.as_mut().unwrap().default = Some("workspace".into());
    let workspace_only =
        resolve_authoring_with_workspace_from(&user_path, None, Some(&workspace), &root, None)
            .unwrap();
    assert_eq!(workspace_only.name, "workspace");
    let error = resolve_authoring_with_workspace_from(
        &user_path,
        Some(&user),
        Some(&workspace),
        &root,
        Some("missing"),
    )
    .unwrap_err()
    .to_string();
    assert!(
        error.contains(path.to_str().unwrap()) && error.contains("missing"),
        "{error}"
    );
}
Input 10: outline tests/configuration.rs fn[workspace_diagnostics_identify_the_file_and_setting]
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
#[test]
fn workspace_diagnostics_identify_the_file_and_setting() {
    let temp = tempfile::tempdir().unwrap();
    let path = temp.path().join("habeas.toml");
    let file = path.to_str().unwrap();
    for (source, setting) in [
        ("version = '1'", "version"),
        ("version = 2", "version"),
        ("version = 1\nunknown = true", "unknown"),
        (
            "version = 1\n[authoring]\ndefault = 123",
            "authoring.default",
        ),
        ("version = 1\n[authoring]\nbogus = 1", "authoring.bogus"),
        (
            "version = 1\n[authoring.configs.cloud]\nbackend = 'bedrock'\nmodel = 3",
            "authoring.configs.cloud",
        ),
        (
            "version = 1\n[evidence]\ndisallow = [42]",
            "evidence.disallow",
        ),
        ("version = 1\n[evidence]\nunknown = []", "evidence.unknown"),
        ("version = 1\n[evidence]\nallow = ['']", "evidence.allow[0]"),
    ] {
        fs::write(&path, source).unwrap();
        let errors = [
            load_workspace_config(temp.path()).map(|_| ()),
            WorkspaceConfig::parse(source, &path).map(|_| ()),
        ];
        for error in errors {
            let error = error.unwrap_err().to_string();
            assert!(error.starts_with(&format!("{file}: {setting}")), "{error}");
        }
    }
    // Only the coverage report decodes `[coverage]`; authoring ignores it.
    for (source, setting) in [
        (
            "version = 1\n[coverage]\nreauthorings = 'many'",
            "coverage.reauthorings",
        ),
        ("version = 1\n[coverage]\nbogus = 1", "coverage.bogus"),
    ] {
        fs::write(&path, source).unwrap();
        let errors = [
            load_coverage_reauthorings(temp.path()).map(|_| ()),
            WorkspaceConfig::parse(source, &path).map(|_| ()),
        ];
        for error in errors {
            let error = error.unwrap_err().to_string();
            assert!(error.starts_with(&format!("{file}: {setting}")), "{error}");
        }
        load_workspace_config(temp.path()).unwrap().unwrap();
    }
    // The evidence loader decodes only the `[evidence]` table it uses.
    for (source, setting) in [
        (
            "version = 1\n[evidence]\ndisallow = [42]",
            "evidence.disallow",
        ),
        ("version = 1\n[evidence]\nunknown = []", "evidence.unknown"),
    ] {
        fs::write(&path, source).unwrap();
        let error = load_workspace_evidence(temp.path())
            .unwrap_err()
            .to_string();
        assert!(error.starts_with(&format!("{file}: {setting}")), "{error}");
    }
    fs::write(&path, b"version = 1\n# \xff\n").unwrap();
    let error = load_workspace_config(temp.path()).unwrap_err().to_string();
    assert!(error.contains(file), "{error}");
    fs::write(&path, "version = 1\n[evidence\n").unwrap();
    let error = load_workspace_config(temp.path()).unwrap_err().to_string();
    assert!(error.starts_with(file), "{error}");
    assert!(
        error.contains("invalid TOML syntax at line 2, column"),
        "{error}"
    );
    let error = UserConfig::parse("version = 1\n[authoring]\ndefault = 123", &path)
        .unwrap_err()
        .to_string();
    assert!(
        error.starts_with(&format!("{file}: authoring.default")),
        "{error}"
    );
}
Input 11: outline tests/configuration.rs fn[feature_sections_are_scoped_and_absent_sections_use_defaults]
// {test}`requirements.configuration.feature_sections`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.structure`
// {test}`requirements.configuration.workspace_structure`
#[test]
fn feature_sections_are_scoped_and_absent_sections_use_defaults() {
    let temp = tempfile::tempdir().unwrap();
    let path = temp.path().join("habeas.toml");
    // An absent `[evidence]` table, or omitted arrays, mean empty lists.
    for source in ["version = 1\n", "version = 1\n[evidence]\n"] {
        fs::write(&path, source).unwrap();
        let policy = load_workspace_evidence(temp.path()).unwrap().unwrap();
        assert!(policy.evidence.allow.is_empty() && policy.evidence.disallow.is_empty());
    }
    let config = WorkspaceConfig::parse("version = 1\n", &path).unwrap();
    assert!(config.authoring.is_none() && config.evidence.is_none() && config.coverage.is_none());
    let config =
        WorkspaceConfig::parse("version = 1\n[coverage]\nreauthorings = 5\n", &path).unwrap();
    assert_eq!(config.coverage.unwrap().reauthorings, Some(5));
    // The one positivity rule applies to the whole-file parse too.
    let error = WorkspaceConfig::parse("version = 1\n[coverage]\nreauthorings = 0\n", &path)
        .unwrap_err()
        .to_string();
    assert!(error.contains("coverage.reauthorings"), "{error}");
    // Feature settings must stay within their sections.
    for source in [
        "version = 1\nallow = ['generated']\n",
        "version = 1\ndefault = 'cloud'\n",
        "version = 1\n[authoring]\nallow = ['generated']\n",
        "version = 1\n[evidence]\ndefault = 'cloud'\n",
        "version = 1\nreauthorings = 3\n",
        "version = 1\n[coverage]\nallow = ['generated']\n",
    ] {
        assert!(WorkspaceConfig::parse(source, &path).is_err(), "{source}");
    }
    assert!(UserConfig::parse("version = 1\n[evidence]\nallow = []\n", &path).is_err());
    // `[coverage]` has no user-file counterpart.
    assert!(UserConfig::parse("version = 1\n[coverage]\nreauthorings = 3\n", &path).is_err());
    // The evidence feature does not reinterpret or validate authoring settings.
    fs::write(
        &path,
        "version = 1\n[authoring]\ndefault = 'missing'\nunknown = 1\n[evidence]\nallow = ['generated']\n",
    )
    .unwrap();
    let policy = load_workspace_evidence(temp.path()).unwrap().unwrap();
    assert_eq!(policy.evidence.allow, vec![Path::new("generated")]);
    // Authoring settings stay in `[authoring]`; its provider-owned options
    // cannot replace harness settings.
    for source in [
        "version = 1\n[authoring.configs.c]\nbackend = 'ollama'\nmodel = 'm'\nallow = []\n",
        "version = 1\n[authoring.configs.c]\nbackend = 'ollama'\nmodel = 'm'\n[authoring.configs.c.options]\nmodel = 'x'\n",
    ] {
        assert!(UserConfig::parse(source, &path).is_err(), "{source}");
        assert!(WorkspaceConfig::parse(source, &path).is_err(), "{source}");
    }
    // An absent authoring section configures nothing.
    let user = UserConfig::parse("version = 1\n", &path).unwrap();
    assert!(user.authoring.is_none());
    for feature in [
        "[authoring]\nconfigs = {}",
        "[evidence]\nallow = []",
        "[coverage]\nreauthorings = 3",
    ] {
        let error = WorkspaceConfig::parse(&format!("version = 2\n{feature}\n"), &path)
            .unwrap_err()
            .to_string();
        assert!(error.contains("version"), "{error}");
    }
}
Input 12: outline tests/coverage.rs fn[an_invalid_coverage_table_is_a_validation_finding_but_authoring_proceeds]
  • File: tests/coverage.rs
  • Selector: fn[an_invalid_coverage_table_is_a_validation_finding_but_authoring_proceeds]
  • Kind: fn
  • tests/coverage.rs:598–633
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.references.coverage.history`
#[test]
fn an_invalid_coverage_table_is_a_validation_finding_but_authoring_proceeds() {
    let temp = project();
    let root = temp.path();
    fs::write(root.join("md/rules.md"), "# Rules\n").unwrap();
    commit(root, "first");
    for (table, setting) in [
        ("[coverage]\nreauthorings = 0\n", "coverage.reauthorings"),
        ("[coverage]\nreauthorings = 'x'\n", "coverage.reauthorings"),
        ("[coverage]\nwindow = 2\n", "coverage.window"),
    ] {
        fs::write(root.join("habeas.toml"), format!("version = 1\n\n{table}")).unwrap();
        let errors = habeas::validate_repository(root).unwrap().errors;
        assert!(
            errors
                .iter()
                .any(|error| error.contains("habeas.toml") && error.contains(setting)),
            "{table}: {errors:#?}"
        );
        // Authoring does not use `[coverage]`.
        let output = Command::new(env!("CARGO_BIN_EXE_habeas"))
            .args(["author", "--all"])
            .current_dir(root)
            .output()
            .unwrap();
        assert!(output.status.success(), "{table}: {output:?}");
        let stderr = String::from_utf8_lossy(&output.stderr);
        assert!(
            stderr.contains("cannot compute coverage warnings"),
            "{stderr}"
        );
    }
}
Input 13: outline tests/evidence_boundaries.rs fn[validation_checks_workspace_common_config_without_loading_unused_authoring_settings]
// {test}`requirements.configuration.workspace_location`
// {test}`requirements.configuration.evidence_paths`
// {test}`requirements.configuration.workspace_structure`
// {test}`requirements.configuration.loading`
// {test}`requirements.authoring.deterministic_validation`
#[test]
fn validation_checks_workspace_common_config_without_loading_unused_authoring_settings() {
    let temp = fixture();
    let root = temp.path().join("project");
    for text in [
        "version = 2\n",
        "version = 1\nunknown = true\n",
        "version = [\n",
    ] {
        fs::write(root.join("habeas.toml"), text).unwrap();
        let errors = validate_repository(&root).unwrap().errors.join("\n");
        assert!(errors.contains("habeas.toml"), "{text:?}: {errors}");
    }
    fs::write(
        root.join("habeas.toml"),
        "version = 1\n[authoring]\nconfigs = 'invalid unused authoring settings'\n",
    )
    .unwrap();
    let report = validate_repository(&root).unwrap();
    assert!(report.errors.is_empty(), "{:?}", report.errors);
}

Referenced definitions

Input 2: requirements selection requirements.references.coverage.history
:::{req} coverage.history
{impl}`requirements.configuration.feature_sections`
An item has recent coverage when it has a reference that covers it under
{cite}`requirements.references.rust_item_coverage`, or when its outline node, or
an outline node containing it, is named by file and selector in the inputs of
any version of an existing evidence record, citation review, or site review in
its coverage window. A file's coverage window MUST be its current contents on
disk, committed or not, together with its contents in each of the last N
commits in its Git history that changed it, read through a Git library rather
than by running `git`. A recorded hash MUST NOT matter here: an earlier version
names the node, whatever its code was then. N MUST be the workspace
`[coverage]` setting `reauthorings`, a positive integer, and 3 when it is not
set. When the history is unavailable, such as outside Git or in a shallow clone
missing those commits, the window MUST be the commits that are available, and
`habeas status --coverage` MUST say that coverage history is incomplete.
:::
Input 3: requirements selection requirements.configuration.feature_sections
:::{req} feature_sections
Each configurable feature MUST define the name and typed data structure of its
user section and any supported project section, citing these common configuration
requirements. The feature MUST specify its supported keys, value types, defaults,
validation rules, and the precedence or combination rules for user settings,
project settings, and invocation options. It MUST specify the behavior of an
absent section and which operations require that section.

Feature-specific fields MUST stay within the feature's section. A feature MUST
NOT reinterpret another feature's settings or change the shared file locations
or schema version. A feature MAY define a provider-owned options map, but MUST
document that boundary and how those options are validated.
:::

Other sources

Input 1: requirements selection requirements.configuration.workspace_structure
:::{req} workspace_structure
{impl}`requirements.configuration.feature_sections`
`habeas.toml` MUST serialize WorkspaceConfig as UTF-8 TOML with `version = 1`.
Its supported feature tables are `[authoring]`, `[coverage]`, and
`[evidence]`; each MAY be absent. `[coverage]` has one optional key,
`reauthorings`, under {cite}`requirements.references.coverage.history`; it has
no user-file counterpart or invocation option, and no operation requires it. Unknown keys, unsupported versions, and invalid field types MUST produce
a diagnostic identifying the file and setting. Invalid TOML, including content
that is not UTF-8, MUST produce a diagnostic identifying the file, with the line
and column of a syntax error.
Features MUST define their own data structures and loading rules under
{cite}`requirements.configuration.feature_sections`. A file containing only
`version = 1` MUST be valid. Habeas settings MUST NOT require a `[habeas]` table
inside `book.toml`.
:::