Repository navigation
feat(plugins): move Plugin interface to version 0.3.0 - #430
Merged
Merged
Conversation
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
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
…ugin-interface-0-3-0
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
…-plugin-interface-0-3-0
… 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 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the public Plugin interface (
wit/language.witandwit/metric.wit), Plugin host, five built-in Language plugins, built-in Metrics, conformance tests, sandbox probes, result cache, and documentation to version0.3.0.Adds optional per-function coverage facts and per-language coverage statements, Hazard lines and
has-hazard-rules/hazard-rulesdeclarations with host-side bounds and rule validation,has-importsso languages without imports omit import-based Metrics cleanly instead of showing0, multi-file resolved imports (resolution.resolved(list of strings)), andfile-model.program-startentry-point marks.Rejects Plugins built for version
0.2.0with exit code2naming 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): touchescrates/plugin-host/**(tier map rule"crates/plugin-host/**") and updates existing assertions for the0.3.0interface (0.2.0->0.3.0,Resolution::Resolved(Vec of String), andresolve_importsreturningResult).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:0.3.0bump acrosswit/language.wit,wit/metric.wit, Plugin host, built-ins, probes, docs; exit-2 rejection andcodeint doctorcontract check for0.2.0Plugins; result cache version5 -> 6+plugin_interface_version: "0.3.0".function.coverage(stripped on Language plugin lowering),code-model.languages(has-coverage,has-hazard-rules,has-imports),has-hazard-rules/hazard-rulesexports,file-model.hazard-lineswithLiftedSizebudgeting and conformance checks, exit-2 validation for out-of-range lines and unlisted rule names.has-importsexport and skipped import/manifest/workspace/entry-point plugin calls; gated Seam 2 conformance assertions; omitted import Metrics andimport_metrics_noteacross TOON, JSON, Markdown, SARIF,diff,trend, andmcp; import-bearing-only repository totals and Budgets; multi-fileResolution::Resolved(list of strings)with empty-list error, deduplication, andresolve-importserror propagation across Import cycles, Orphan files, Import boundaries,codeint trace,impact,coupling, and Metric plugins;file-model.program-startentry-point marks for Production non-tooling files alongside manifest and configuredentry_points.Fail-first 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), andcrates/cli/src/check/tests.rs(lowering_clears_language_plugin_coverage_and_unmeasured_plugins_emit_no_language_facts).0.2.0contract and Round 1/2 revisions (v0_2_0plugin loaded instead of exiting2;diffandtrendemittedimport_cycles: 0.0and leaked unmeasured built-ins;trace --packageemittedfrom_entry_point: "program-start mark"forpackages/app/scripts/tool.fld; duplicate multi-file targets counted twice;resolve_importsturned memory cap errors intoWrongCount).Checks
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo 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-pythoncargo test --locked -p codeint-cli --libcargo test --locked -p codeint-cli --test plugins --test reference --test checkcargo test --locked -p codeint-cli --test integration(report::,diff::,trend::,doctor::,trace::,boundaries::,orphan_files::,mcp::)lefthookpre-commit: links, secrets, format, duplicates, markdown, repository; commit-msg)cargo run --locked -p xtask -- merged-result,no-comments --base origin/main,commit-message --range origin/maincargo run --locked -p codeint-cli -- diff origin/main --format toonSafety proof
diff,trend,trace,doctor,SavedReportre-rendering, andResultCacheupgrades for the five built-in languages remain backward-compatible with unchanged semantics; (2) external0.3.0Language and Metric plugins uphold every contract boundary (version rejection, coverage stripping, hazard-line bounds/rules, no-imports omission acrosscheck/diff/trend/mcp/--package, multi-file deduplication and limit propagation, andprogram-starttooling exclusion).2176e7b) builttarget/debug/codeintand ran empirical probes across the Rust self-check, a 5-language repo, 16codeint reportre-render combinations (v0.2.0 and v0.3.0 payloads across JSON/TOON/Markdown/SARIF), poisoned v5ResultCachemiss verification, no-imports-only repos with straypackage.jsonandbudgets.unused_dependencies: 0.0,--packagescopes, mixed-language and split-source-set repos,codeint mcpJSON-RPC calls (check,diff,trend,trace), multi-file folder imports, andcodeint doctor; both Safety Facts PROVEN.interrogate:361b5d9, FAIL, 6 verified findings): (1) unmeasured built-ins leaked intocode-model.languagesand causeddiffto triggerunused_dependenciesbudget on no-imports-only repos; (2)diff,trend, andmcpemittedimport_cycles: 0.0instead of absent; (3)tracemarkedprogram_startfiles in non-runtime tooling paths (scripts/main.prog) and no-imports models as entry points; (4)Boundaries::measuredouble-counted duplicate targets[a, a]in one resolved list; (5)WasmLanguagePlugin::resolve_importsswallowed limit errors via.unwrap_or_default()intoWrongCount; (6)function.coveragefrom Language plugins was forwarded to Metric plugins. All 6 fixed in2176e7bwith regression tests.2176e7b, FAIL, 1 verified finding + 1 defensive observation): all 6 Round 1 findings verified fixed; discoveredcodeint trace --package member(and MCPtracewithpackage) clearedmodel.workspaceduring filtering somember/scripts/...was falsely marked"program-start mark", plus defensive clearing offile.program_startwhen!has_imports. Fixed in3f6a877with regression tests.3f6a877, Independent Verifier on isolated worktree): empirically verified CLI and MCPtrace(with and without--package), no-importsprogram_startstripping, side-effect audit, and targeted test suites -> Verdict: PASS (0 open verified findings).Runtime evidence
Build revision:
3f6a877onfeat/222-plugin-interface-0-3-0.Verified against built
target/debug/codeintbinary acrosscheck,diff,trend,trace,impact,doctor,report, andmcp(JSON, TOON, Markdown, SARIF) for all five built-in languages and all compiled WASM0.3.0and legacy0.2.0sandbox probes; verdict: PASS.Gaps