Skip to content

feat(plugins): move Plugin interface to version 0.3.0 - #430

Merged
avidianity merged 42 commits into
mainfrom
feat/222-plugin-interface-0-3-0
Nov 24, 2026
Merged

avidianity merged 42 commits into
mainfrom
feat/222-plugin-interface-0-3-0

Conversation

@avidianity

@avidianity avidianity commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Moves the public Plugin interface (wit/language.wit and wit/metric.wit), Plugin host, five built-in Language plugins, built-in Metrics, conformance tests, sandbox probes, result cache, and documentation to version 0.3.0.
Adds optional per-function coverage facts and per-language coverage statements, Hazard lines and has-hazard-rules / hazard-rules declarations with host-side bounds and rule validation, has-imports so languages without imports omit import-based Metrics cleanly instead of showing 0, multi-file resolved imports (resolution.resolved(list of strings)), and file-model.program-start entry-point marks.
Rejects Plugins built for version 0.2.0 with exit code 2 naming the Plugin, both versions, and a rebuild remedy, while keeping all reports for the five built-in languages unchanged.

Closes #222
Closes #245
Closes #246
Closes #247
Closes #248
Closes #249
Closes #250
Closes #251
Closes #252
Closes #253
Closes #254
Closes #255
Closes #256
Closes #257
Closes #258
Closes #259
Closes #260
Closes #261
Closes #262
Closes #263
Closes #264
Closes #265

Tier

Tier 3 from the tier check (cargo run --locked -p xtask -- risk-tier --base origin/main): touches crates/plugin-host/** (tier map rule "crates/plugin-host/**") and updates existing assertions for the 0.3.0 interface (0.2.0 -> 0.3.0, Resolution::Resolved(Vec of String), and resolve_imports returning Result).

Task

Spec #222 (Spec: Plugin interface version 0.3.0 for coverage facts, Hazard lines, and new import rules) and sub-issues #245 through #265:

Fail-first test

  • Test: crates/cli/tests/plugins.rs (v0_2_0_language_plugin_stops_check_with_exit_2_and_rebuild_remedy, hazard_line_beyond_end_of_file_stops_check_with_exit_2_naming_plugin_file_and_line, unlisted_hazard_line_rule_stops_check_with_exit_2_naming_plugin_file_and_rule, empty_resolved_import_list_stops_check_with_exit_2_naming_plugin, marked_production_file_is_an_entry_point_for_orphan_files_alongside_globs_while_marked_tests_stay_out, no_imports_only_repo_omits_import_cycles_and_dependencies_across_check_diff_and_trend), crates/plugin-host/tests/conformance.rs (no_imports_external_wasm_plugin_passes_seam_2_conformance), crates/model/src/runtime_imports/tests.rs (resolve_runtime_imports_deduplicates_targets_preserving_first_seen_order, resolve_runtime_imports_propagates_plugin_memory_limit_errors), crates/metrics/src/boundaries/tests.rs (duplicate_targets_in_a_single_resolved_import_are_counted_once), and crates/cli/src/check/tests.rs (lowering_clears_language_plugin_coverage_and_unmeasured_plugins_emit_no_language_facts).
  • Before the change: failed on 0.2.0 contract and Round 1/2 revisions (v0_2_0 plugin loaded instead of exiting 2; diff and trend emitted import_cycles: 0.0 and leaked unmeasured built-ins; trace --package emitted from_entry_point: "program-start mark" for packages/app/scripts/tool.fld; duplicate multi-file targets counted twice; resolve_imports turned memory cap errors into WrongCount).
  • After the change: passed.

Checks

Check Result
cargo fmt --all --check passed
cargo clippy --workspace --all-targets --locked -- -D warnings passed
cargo test --locked -p codeint-model -p codeint-metrics -p codeint-report -p codeint-plugin-host -p codeint-lang-ts -p codeint-lang-rust -p codeint-lang-php -p codeint-lang-dart -p codeint-lang-python passed
cargo test --locked -p codeint-cli --lib passed (30/30)
cargo test --locked -p codeint-cli --test plugins --test reference --test check passed
cargo test --locked -p codeint-cli --test integration (report::, diff::, trend::, doctor::, trace::, boundaries::, orphan_files::, mcp::) passed
Hook checks (lefthook pre-commit: links, secrets, format, duplicates, markdown, repository; commit-msg) passed
cargo run --locked -p xtask -- merged-result, no-comments --base origin/main, commit-message --range origin/main passed
cargo run --locked -p codeint-cli -- diff origin/main --format toon passed (exit 0, 0 regressions)

Safety proof

  • Safety fact: (1) Reports, diff, trend, trace, doctor, SavedReport re-rendering, and ResultCache upgrades for the five built-in languages remain backward-compatible with unchanged semantics; (2) external 0.3.0 Language and Metric plugins uphold every contract boundary (version rejection, coverage stripping, hazard-line bounds/rules, no-imports omission across check/diff/trend/mcp/--package, multi-file deduplication and limit propagation, and program-start tooling exclusion).
  • Proof: Round 2 Blast Radius verification on isolated worktree (2176e7b) built target/debug/codeint and ran empirical probes across the Rust self-check, a 5-language repo, 16 codeint report re-render combinations (v0.2.0 and v0.3.0 payloads across JSON/TOON/Markdown/SARIF), poisoned v5 ResultCache miss verification, no-imports-only repos with stray package.json and budgets.unused_dependencies: 0.0, --package scopes, mixed-language and split-source-set repos, codeint mcp JSON-RPC calls (check, diff, trend, trace), multi-file folder imports, and codeint doctor; both Safety Facts PROVEN.
  • interrogate:
    • Round 1 (361b5d9, FAIL, 6 verified findings): (1) unmeasured built-ins leaked into code-model.languages and caused diff to trigger unused_dependencies budget on no-imports-only repos; (2) diff, trend, and mcp emitted import_cycles: 0.0 instead of absent; (3) trace marked program_start files in non-runtime tooling paths (scripts/main.prog) and no-imports models as entry points; (4) Boundaries::measure double-counted duplicate targets [a, a] in one resolved list; (5) WasmLanguagePlugin::resolve_imports swallowed limit errors via .unwrap_or_default() into WrongCount; (6) function.coverage from Language plugins was forwarded to Metric plugins. All 6 fixed in 2176e7b with regression tests.
    • Round 2 (2176e7b, FAIL, 1 verified finding + 1 defensive observation): all 6 Round 1 findings verified fixed; discovered codeint trace --package member (and MCP trace with package) cleared model.workspace during filtering so member/scripts/... was falsely marked "program-start mark", plus defensive clearing of file.program_start when !has_imports. Fixed in 3f6a877 with regression tests.
    • Round 3 clean rerun (3f6a877, Independent Verifier on isolated worktree): empirically verified CLI and MCP trace (with and without --package), no-imports program_start stripping, side-effect audit, and targeted test suites -> Verdict: PASS (0 open verified findings).

Runtime evidence

Build revision: 3f6a877 on feat/222-plugin-interface-0-3-0.
Verified against built target/debug/codeint binary across check, diff, trend, trace, impact, doctor, report, and mcp (JSON, TOON, Markdown, SARIF) for all five built-in languages and all compiled WASM 0.3.0 and legacy 0.2.0 sandbox probes; verdict: PASS.

Gaps

  • Deferred coverage: none.
  • Pre-existing failures: none.
  • Environmental failures: none.

Move the Language plugin and Metric plugin WIT contracts, Plugin host, CLI remedies, test fixtures, and documentation to codeint:plugin@0.3.0 without adding new records, functions, or variants.

Export PLUGIN_INTERFACE_VERSION from codeint-plugin-host as the single source of truth for the active Plugin interface version.

Closes #245
@github-actions github-actions Bot added the tier-3 Tier 3 from the tier check label Nov 24, 2026
Include PLUGIN_INTERFACE_VERSION in MeasurementSettings and bump MEASUREMENT_CACHE_VERSION from 5 to 6 so results cached under version 0.2.0 are never reused after stepping to 0.3.0 while keeping the StoredEntry and report shapes unchanged.

Closes #247
Add optional function-coverage (listed-lines, executed-lines) to wit/language.wit, re-export FunctionCoverage from codeint-model, pass coverage across the Wasm Plugin boundary, assert Language plugins leave coverage absent in Seam 2 conformance, add a coverage-reader Metric plugin test fixture, and document the rules in docs/plugins.md and crates/model/HOW-TO.md.

Closes #248
Validate external WebAssembly plugin component contracts in codeint doctor without executing guest code, and add process-boundary and host tests with legacy 0.2.0 language and metric fixtures.

Closes #246
Add program-start: bool to file-model in wit/language.wit so a Language plugin can mark a file as a program start from its source text and a Metric plugin can read the mark. Forward program_start across both WebAssembly host boundaries, leave it false in all five built-in Language plugins, document the field and its rules, and verify both ends through Wasm test plugins.

Closes #264
…etric interface

Add LanguageFacts with per-language has_coverage to CodeModel and wit/metric.wit, preserve it across CodeModel::merge and into_source_sets, populate it as false per language in check measurement, pass it across the Wasm Metric plugin boundary, and document the rules in docs/plugins.md.

Closes #249
…gin-interface-0-3-0

# Conflicts:
#	crates/plugin-host/tests/load.rs
#	docs/plugins.md
Include every Production file marked with program_start in Orphan files entry points alongside manifest entry points and configured entry_points globs, keep marked non-Production files out of entry points, and report the program-start mark as the entry-point reason in codeint trace. Extend the program-start Wasm test plugin with relative imports and add process-boundary check and trace tests plus reference and guide updates.

Closes #265
…n-interface-0-3-0

# Conflicts:
#	crates/cli/src/check.rs
#	crates/cli/tests/plugins.rs
…plugins

Add has-hazard-rules and hazard-rules to wit/language.wit and has-hazard-rules to language-facts in wit/metric.wit so a Language plugin can declare whether it defines Hazard line rules and list their stable names, and a Metric plugin can read the per-language statement. Cache and forward both exports across the WebAssembly Language plugin host, pass has-hazard-rules across the Metric plugin host and check snapshot finalization, leave all five built-in Language plugins reporting false and an empty list, add Wasm fixture tests, and document the rules in docs/plugins.md and crates/model/HOW-TO.md.

Closes #250
…rface-0-3-0

# Conflicts:
#	crates/cli/tests/plugins.rs
Change variant resolution.resolved in codeint:plugin@0.3.0 from a single path string to a non-empty list of repository file paths across the WIT contract, Code model, Plugin host, five built-in Language plugins, Metrics, Reports, conformance suite, and docs. Reject an empty target list with exit code 2 naming the Plugin.

Closes #259
…gin-interface-0-3-0

# Conflicts:
#	crates/cli/tests/plugins.rs
#	crates/plugin-host/tests/fixtures/sandbox-probes/Cargo.toml
#	crates/plugin-host/tests/load.rs
#	docs/plugins.md
…gin interface

Add record hazard-line (line and rule, never source text) and file-model.hazard-lines to wit/language.wit, re-export HazardLine from codeint-model, account for hazard-lines in Wasm lifted-size budgeting and pass them across both Language and Metric Wasm plugin boundaries, keep all five built-in Language plugins reporting empty hazard-lines, extend Seam 2 conformance checks and Wasm fixture tests, and document hazard-lines in docs/plugins.md and crates/model/HOW-TO.md.

Closes #251
…terface-0-3-0

# Conflicts:
#	crates/plugin-host/tests/load.rs
Add unit and process-boundary CLI integration tests proving Orphan files marks every file of an imported folder and its transitive folder imports as reachable, reports unreferenced files, and classifies test-only folder imports as test-only.

Closes #261
Add unit tests in codeint-metrics and process-boundary integration tests in codeint-cli using folder_import_language_plugin.wasm to verify that multi-file imports emit boundary findings only for targets on the forbidden side, match configured zone rules, and assign distinct stable IDs per forbidden target across JSON, SARIF, and Markdown outputs.

Closes #262
Sort and deduplicate resolved import adjacency lists in ImportCycles::measure, add unit tests for multi-file resolved import cycles and duplicate targets, and add process-boundary integration tests using the folder-import Language plugin proving cycle findings include only participating files and acyclic folder imports report no cycles.

Closes #260
Record every multi-file import traversed along returned codeint trace paths in TraceResult and TraceReport, render each import and its targets in text, TOON, and JSON formats, leave single-file built-in language trace output unchanged, document the output in docs/reference.md, and add unit and process-boundary integration tests with the folder-import Language plugin fixture.

Closes #263
Validate every Hazard line returned by a Language plugin against the 1-based line count of its source file during lowering, stopping the run with exit code 2 and naming the Plugin, file, and line number before any report is written.

Closes #252
Validate every Hazard line returned by a Language plugin against its declared hazard-rules list during lowering, stopping the run with exit code 2 before any report is written and naming the Plugin, file, and rule name.

Closes #253
Add has-imports to codeint:plugin/language@0.3.0 and language-facts on codeint:plugin/metric@0.3.0, return true from all five built-in Language plugins, skip manifest, workspace, import, dependency, and entry-point calls when has-imports is false, and document the rules in docs/plugins.md and crates/model/HOW-TO.md.

Closes #254
…nterface-0-3-0

# Conflicts:
#	crates/cli/src/check.rs
#	crates/cli/src/remedy.rs
#	crates/cli/tests/plugins.rs
#	crates/model/src/lib.rs
#	crates/model/src/tests.rs
…rface-0-3-0

# Conflicts:
#	crates/cli/tests/plugins.rs
#	crates/plugin-host/tests/fixtures/sandbox-probes/Cargo.toml
Gate import, manifest, workspace package, declared dependency, and entry point checks in the Seam 2 conformance suite on LanguagePlugin::has_imports, and verify that the no-imports Wasm fixture passes conformance without calling those functions.

Closes #255
…ON and JSON

Carry per-language has_imports into MeasuredLanguage and omit import_cycles, orphan_files, boundaries, and dependencies from TOON and JSON sections (and workspace package entries) when a language has no imports, adding a one-line import_metrics_note instead. Skip no-imports languages in orphan file and dependency hygiene collection, keep Markdown and SARIF compiling cleanly, update reference and plugin documentation, and add process-boundary integration tests.

Closes #256
… without imports

Render the one-line import_metrics_note in Markdown for top-level and per-language sections of languages without imports, omit the Import cycles column from Markdown workspace package tables when no package measures it, exclude files of languages without imports from top-level boundary evaluation so strict_zones never emits SARIF or Markdown boundary Findings for them, update report documentation, and add process-boundary integration tests.

Closes #257
…tals

Compute repository-total Import cycles, Import boundaries, and Workspace package Import cycles from a merged CodeModel containing only languages with has_imports enabled, matching Orphan files and Dependency hygiene. Omit those totals when a Source set or repository has no import-bearing languages so Budgets evaluate against the un-diluted total and never trip on absent totals, mirror the same scoping in CommitMeasurement for diff and trend, document the behavior, and add process-boundary CLI tests.

Closes #258
…/222-plugin-interface-0-3-0

# Conflicts:
#	crates/report/HOW-TO.md
#	crates/report/src/lib.rs
#	crates/report/src/measurement.rs
…face-0-3-0

# Conflicts:
#	crates/cli/src/check/tests.rs
Comment thread crates/cli/tests/plugins.rs Fixed
Comment on lines +124 to +135
assert_eq!(findings[0].specifier.as_deref(), Some("shared"));
assert_eq!(findings[0].source_zone.as_deref(), Some("ui"));
assert_eq!(findings[0].target_zone.as_deref(), Some("secret"));
assert_eq!(
findings[0].reason.as_deref(),
Some("UI must not depend on secret files")
);
}

#[test]
fn multi_file_import_with_public_files_flags_only_non_public_targets() {
let model = model_with_multi_target_import(
Comment on lines +125 to +134
impl Guest for FolderImportLanguagePlugin {
fn extensions() -> Vec<String> {
vec!["fld".to_string()]
}

fn lower(path: String, text: String) -> Result<FileModel, LowerError> {
if !path.ends_with(".fld") {
return Err(LowerError::UnsupportedFile("unsupported".to_string()));
}
let source_set = if path.ends_with("_test.fld") {
Comment on lines +18 to +36
struct ImportsReaderMetricPlugin;

export!(ImportsReaderMetricPlugin);

impl Guest for ImportsReaderMetricPlugin {
fn key() -> String {
"resolved_links".to_string()
}

fn name() -> String {
"Resolved links".to_string()
}

fn description() -> String {
"Test Metric plugin that reads multi-file resolved runtime imports".to_string()
}

fn measure(model: CodeModel) -> Measurement {
let mut findings = Vec::new();
Comment on lines +1446 to +1459
plugin.hazard_rules().is_empty(),
"{name} built-in Language plugin must list no hazard rules"
);
}
}

#[test]
fn language_plugin_exports_hazard_rules_across_wasm_boundary() {
let wasm_path = sandbox_probe_wasm("hazard_rules_language_plugin.wasm");
let declaration = declaration_for("hazard-rules-language", &wasm_path);
let plugin = load_language_plugin(Path::new("."), &declaration, &PluginHostConfig::default())
.expect("hazard-rules Language plugin loads");

assert!(plugin.has_hazard_rules());
- Omit unmeasured plugins from CodeModel.languages and partition measured languages in CommitMeasurement so no-imports-only repos and packages never leak built-in language facts or trigger dependency budgets.
- Make SourceSetMeasurement, SourceSetChanges, and TrendRow import_cycles optional so diff, trend, and MCP omit import_cycles for no-imports scopes while preserving full compatibility for import-bearing languages and saved reports.
- Exclude non-runtime tooling paths and no-imports models from program-start entry points in codeint trace and combine_entry_points.
- Deduplicate repeated targets in resolve_runtime_imports and Boundaries::measure so multi-file resolutions never double-count edges.
- Return Result<Vec<Resolution>, LanguagePluginError> from LanguagePlugin::resolve_imports so memory and time limit errors propagate instead of turning into WrongCount.
- Strip function.coverage on Language plugin lowering so Language plugins cannot spoof coverage facts into Metric plugins.
- Align Orphan files schema description and docs/plugins.md with program-start marks and all report formats.
…no-imports program_start

- Retain workspace member roots on the merged CodeModel returned by measure_working_tree_model_for_package so codeint trace --package recognizes package-relative tooling paths such as <member>/scripts/....
- Clear file.program_start when a Language plugin declares has_imports == false so a no-imports file can never be reported as a program-start entry point in mixed-language repositories.
@avidianity
avidianity marked this pull request as ready for review November 24, 2026 07:54
@avidianity
avidianity merged commit 075187d into main Nov 24, 2026
14 checks passed
@avidianity
avidianity deleted the feat/222-plugin-interface-0-3-0 branch November 24, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment