Repository navigation
explore and doctor: propose generated subjects, find DbContext classes by base, report missing SDK pins - #418
Open
agorischek wants to merge 2 commits into
Open
agorischek wants to merge 2 commits into
agorischek wants to merge 2 commits into
Conversation
…report missing SDK pins - explore matches a built-in's detection patterns against generated files too (only vendored files are skipped), so a linguist-generated db/schema.rb or db/structure.sql proposes rails-schema. Whole-repository candidates still skip generated files. - efcore-schema is proposed for any C# file declaring a class that derives from DbContext or IdentityDbContext, whatever the file is named. - doctor and explore's needs report a global.json SDK pin (version and rollForward) that the installed dotnet --list-sdks can't satisfy, and a missing dotnet; explore also reports a rust-toolchain.toml pin rustup lacks. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The dotnet executable check can allow repository-controlled code to run without --trust and with the full process environment, leaving a critical security issue unresolved.
4 open issues
What changed in this PR
Improves Projections’ subject discovery and toolchain diagnostics so setup identifies more usable inputs and missing prerequisites.
Changes:
- Proposes generated subjects while preserving vendored exclusions.
- Detects EF Core contexts by base class rather than filename.
- Reports missing .NET SDK pins and Rust toolchains.
| File | Description |
|---|---|
| packages/extractors/efcore-schema/src/lib.rs | Broadens detection to C# files. |
| packages/cli/tests/authoring.rs | Adds discovery and SDK diagnostic regressions. |
| packages/cli/src/explore/vendored.rs | Separates generated and vendored filtering. |
| packages/cli/src/explore/typescript/tsconfig.rs | Exposes JSON-with-comments parsing. |
| packages/cli/src/explore/typescript.rs | Enables parser reuse. |
| packages/cli/src/explore/tetragon.rs | Shares bounded file reading. |
| packages/cli/src/explore/needs.rs | Adds candidate toolchain needs. |
| packages/cli/src/explore/efcore.rs | Filters C# files for context declarations. |
| packages/cli/src/explore.rs | Integrates discovery filters and needs. |
| packages/cli/src/doctor/toolchains.rs | Shares Rust toolchain checks. |
| packages/cli/src/doctor/dotnet.rs | Adds SDK pin and availability checks. |
| packages/cli/src/doctor.rs | Integrates .NET diagnostics. |
| docs/builtins/extractors/efcore-schema.md | Updates the documented detection glob. |
| changelog.d/418.md | Documents discovery and diagnostic fixes. |
| changelog.d/418-behaviour-changes.md | Documents new doctor failure conditions. |
Review effort: Balanced
| .unwrap_or_else(|| project.to_owned()); | ||
| let pin = Pin::find(&built)?; | ||
| let shown = pin.file.strip_prefix(project).unwrap_or(&pin.file).display().to_string(); | ||
| unmet(&pin, &shown, &dotnet.display().to_string(), || listed(&dotnet)) |
Comment on lines
+267
to
+271
| let runs_dotnet = match &definition["extractor"] { | ||
| Value::String(builtin) => BUILTINS.contains(&builtin.as_str()) && crate::extractors::requires_trust(definition), | ||
| extractor => extractor["command"][0] | ||
| .as_str() | ||
| .is_some_and(|program| ["dotnet", "dotnet.exe"].contains(&program)), |
Comment on lines
+297
to
+301
| let built = definition["inputs"]["project"] | ||
| .as_str() | ||
| .or_else(|| definition["inputs"]["projects"][0].as_str()) | ||
| .and_then(|file| project.join(file).parent().map(Path::to_owned)) | ||
| .unwrap_or_else(|| project.to_owned()); |
| } | ||
|
|
||
| fn declares_context(class: ®ex::Regex, text: &str) -> bool { | ||
| text.contains("Context") && class.is_match(text) |
This branch has not been deployed
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.


What changed
Setup trials found three ways
projections exploreandprojections doctormiss a repository's subjects or needs..gitattributesmarkslinguist-generatedbefore matching detection patterns, so it never proposedrails-schemafor an app whosedb/schema.rbis marked generated, which the default.gitattributesof a new Rails app does. Detection now skips only vendored files, so a generated schema dump,db/structure.sql, lockfile or migration snapshot still proposes the built-in that reads it. Projections of the whole repository still skip generated files and still get the exclusion globs. Vendored paths and the ignored directories (vendor,node_modules,third_party, tests, fixtures) still propose nothing.*DbContext.cs, so a context inDatabaseContext.cswas never found. It now detects**/*.csand, liketetragon-policies, keeps only files that declare a class deriving fromDbContext,IdentityDbContext<…>(or another…DbContextbase, such asApiAuthorizationDbContext<…>). A cheap text scan handles primary constructors and qualified names, and it ignores generic constraints (where T : DbContext) andDbContextOptions.needsof explore's .NET candidates, now read the nearestglobal.jsonabove the project (sdk.version,rollForwardwith itspatchdefault,allowPrerelease, andpathsper the SDK resolver's rules). They compare it withdotnet --list-sdksand report a fail orinstallneed naming the pin, the SDKs the policy accepts and what is installed. A missingdotnet(orinputs.dotnet) is also reported. Nothing is run for snapshot inputs or for a repository-relativeinputs.dotnet, because doctor never runs repository code. Explore's Rust candidates now also report arust-toolchain.tomlchannel that rustup lacks, reusing doctor's existing check.Evidence
npm run tools -- check --fast: passed (includescargo check --all-targets,cargo fmt, considered complexity budgets).cargo test -p projections-cli --lib -- explore:: doctor::: 50 passed. New unit tests cover roll-forward policies, prerelease ordering,paths, the nearestglobal.json, context detection and toolchain needs.cargo test -p projections-cli --test authoring -- explore_proposes doctor_and_explore_report a_candidate_is_shown_and_compared: new regression testsexplore_proposes_generated_subjects_and_contexts_by_their_base_classanddoctor_and_explore_report_an_sdk_global_json_pins_that_isnt_installed(fakedotnetwith only SDK 11 against a pin of 10.0.100) passed, along with the other explore tests.a_candidate_is_shown_and_compared_before_it_is_adoptedfailed locally only because the default comparator Wasm wasn't built (its firstcomparestep); its efcore fixture now derives fromDbContext, and I checked thatadopt --dry-runpath manually with the built CLI.Manual: against a real
dotnetwith only SDK 11.0.100 installed,explore --listfor a repo pinning 10.0.100 (latestFeature) lists the missing SDK as a need.Not run locally (disk): clippy, the full test suites and regenerating reference docs. The one generated line in
docs/builtins/extractors/efcore-schema.mdwas set to exactly whatbuiltins.mjsemits for the newdetects.Documentation that this change affects is updated, and generated reference
pages are regenerated (
npm run docs:generate).Fixes include a regression test.
A changelog fragment at
changelog.d/<this PR's number>.mddescribes whatusers will notice, or the PR has the
no changeloglabel (seechangelog.d/README.md).
No credentials, private source or machine-specific paths are included.