Skip to content

Built-in extractors report their subject's presence - #414

Open
agorischek wants to merge 9 commits into
schema/subject-presencefrom
extractors/subject-presence-sweep
Open

agorischek wants to merge 9 commits into
schema/subject-presencefrom
extractors/subject-presence-sweep

Conversation

@agorischek

Copy link
Copy Markdown
Collaborator

What changed

Stacked on #409 (base schema/subject-presence). It will be retargeted to main after #409 merges. This is Phase 2 of the subject-presence design. Refs #373.

Every built-in extractor now writes presence explicitly on every path, with both values:

  • Subject anchors use subject_exists / subject_matches: github-actions-jobs, cargo-dependencies, rust/swift/go public API, swift-package-dependencies, workspace-dependencies, nestjs-di, spring-di, dotnet-support (dotnet-public-api, dotnet-di, efcore-schema), terraform-infrastructure, azure-what-if, scip-file-references, the SDK's pre-exported database snapshot (prisma, rails-schema and django snapshots), prisma-schema, rails-routes, rails-schema, nuget-dependencies, openrewrite-data-tables, xcode-modules, typescript-support/typescript-public-api, tetragon-policies (paths, renderedManifestsPath, helm chart, kustomize path), github-agentic-workflows and django-schema.
  • Auxiliary inputs keep input_exists: azure templateJsonPath, tetragon agentValuesPath/kernelProfilesPath/workloadPaths/crdPath/helm values, rails-schema inflections.
  • Always present: the repository-wide extractors (code-statistics, repository-map, terraform-modules, renderer-scenarios) and command-output. terraform-modules reads every .tf file through include/exclude globs, so it's repository-wide. There is no python-dependencies built-in on this base.
  • Explicit present where no anchor is checked: for example, typescript-public-api with no declared paths, a SCIP indexer run at the root, openrewrite tables it discovers itself, go import-path patterns and nestjs's default entry.
  • New SDK helpers: Context::subject_matches_any anchors whichever alternative discovery globs match (**/*.csproj/**/*.fsproj/**/*.vbproj, **/*.yaml/**/*.yml), or all of them when none match. A revision that uses only one alternative therefore isn't told the others are missing. testing::extract runs collect and then finish, as serve does. testing::golden now rejects an extraction golden without presence.

Built-in digests change once, because every extraction gains presence. The changelog records this under behaviour changes.

Behaviour decisions

Each decision picks the least surprising option. An absent subject should never fail a comparison (#326), and a present one should never be reported absent.

  1. github-agentic-workflows: paths globs, whether declared or the default .github/workflows/*.md, are now subject_matches anchors. They match against candidate workflow files (.md files that aren't a README and aren't excluded).
    • If every glob is unmatched, the extraction is absent and names the globs. Before, it was a silent empty extraction.
    • If only some are unmatched, it is present and names the unmatched ones in missingInputs, as tetragon already does.
    • paths: [] is now an error. It selects nothing, so it's a definition mistake rather than an absence.
  2. prisma-schema discovery with no .prisma files: absent (missingInputs: ["**/*.prisma"]) instead of an error. An error fails every comparison against a revision from before Prisma was adopted, which is the main case this design exists for. A declared folder with no .prisma files stays an error: the folder exists, so that's a misconfiguration.
  3. django-schema settings module: after the trust check and before Python runs, the extractor checks for a file that could be the module (**/<module path>.py or **/<module path>/__init__.py) anywhere in the revision. The extraction is absent only when there is none. Matching anywhere in the tree avoids false absences in src/ or manage.py-relative layouts. The only revisions that change are ones where Python could not have imported the module anyway.
  4. Other discovery modes follow the same rule for consistency. Before, rails-routes (**/config/routes.rb), rails-schema (**/db/*schema.rb, **/db/*structure.sql), nuget-dependencies (project files), xcode-modules (**/*.xcodeproj/project.pbxproj) and tetragon's default globs silently returned an empty extraction when they found nothing. They are now absent. openrewrite-data-tables discovery keeps its existing error, because that error deliberately tells you to commit the exported CSVs.
  5. Smaller cases:
    • rust-public-api: a requested package that no Cargo.toml declares is now absent, with the package named in missingInputs (it was a silent empty extraction).
    • go-public-api: when every local package pattern names a missing directory, the extraction is absent, even if go.mod exists. Import-path patterns can't be checked, so they count as present.
    • nestjs-di: a missing entry, module or tsconfig is absent, explicitly.

Evidence

All Rust runs used CARGO_TARGET_DIR=/tmp/cargo-target. I unset the session's injected git signing configuration for tests that create commits.

  • cargo test -p <crate> for the SDK, the catalog and all 32 changed extractor crates, first with PROJECTIONS_UPDATE_GOLDEN=1 (regenerating the goldens and the graph renderer's azure/terraform fixtures) and then without it: passed, 286 tests and 0 failures. After the subject_matches_any refactor, I reran the 7 affected crates: passed, 88 tests and 0 failures.

  • New catalog test, catalog/tests/presence.rs:

    • It runs every registered built-in against a revision without its subject and asserts absent (or present for the repository-wide ones). Every built-in must have a case.
    • It also asserts that every golden extraction kept under a built-in's tests/ carries presence: passed.
  • Tests extended with presence assertions:

    • prisma tests/prisma.rs, including discovery that finds nothing
    • tetragon tests/extractions.rs, including default globs
    • workspace-dependencies tests/managers.rs, through its goldens
    • go-public-api unit tests, including import-path patterns
    • openrewrite tests/migration.rs, through its goldens
    • rust-public-api, for an undeclared package and a missing manifest
    • rails-schema discovery
  • New tests:

    • a github-actions-jobs absent golden (delivery/absent.expected.json, the same test name and path as Absent subjects show as not added yet or removed, not as empty #411's)
    • a tetragon test where an auxiliary input is missing but the subject is present: zero policies with no agentValuesPath stays present
    • github-agentic-workflows absent and partial-glob cases
    • rails-routes discovered, declared and absent cases
    • a django absent case
    • an SDK test for subject_matches_any
  • cargo test -p projections-cli --test first_party, with renderer-scenarios skipped locally because it needs the built default comparator: passed. Every other built-in runs identically as a built-in and as a custom __extract command.

  • cargo test -p projections-cli for --test artifact --test execution --test extractors --test native: the failure set matches the base branch, run in the same environment. Those failures come from "default comparator module not embedded" (no JS build here) and HOME being unset. The one extra failure, artifact_readers_reject_symlinks_and_special_files, comes from mkfifo on this session's FUSE-mounted worktree; it passes on the same base in /tmp.

  • cargo fmt --all --check: passed. Edited Markdown was formatted with oxfmt 0.75.0.

  • cargo clippy --all-targets -- -D warnings on the changed crates: clean apart from two unnecessary_to_owned lints in sdk/tests/source.rs (subject_matches(..., &cx.files().unwrap().to_vec())). They come from Extractions report whether their subject is present #409 and are left for that PR.

  • Not run: tools check and the JS or browser suites. This session has no node_modules, and installing them was ruled out to save disk space.

  • Documentation that this change affects is updated, and generated reference
    pages are regenerated (npm run docs:generate). Updated: docs/contracts/extractions.md, the subject-presence proposal (Phase 2 implemented), the SDK and go-public-api READMEs, and the hand-written part of docs/builtins/extractors/go-public-api.md. No descriptor changed, so the generated regions are unchanged.

  • Fixes include a regression test.

  • A changelog fragment at changelog.d/<this PR's number>.md describes what
    users will notice, or the PR has the no changelog label (see
    changelog.d/README.md).

  • No credentials, private source or machine-specific paths are included.

agorischek and others added 8 commits December 5, 2026 02:55
Refs #373

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Refs #373

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Refs #373

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Refs #373

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>
Refs #373

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Refs #373

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Refs #373

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@agorischek
agorischek force-pushed the extractors/subject-presence-sweep branch from e2e8472 to 7c30fef Compare December 5, 2026 02:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved subject-presence bugs can cause extraction failures, incorrect presence reports, and unknown states across several extractors.

7 open issues
What changed in this PR

Implements Phase 2 of subject presence, building on #409 so comparisons can distinguish missing subjects from present-but-empty results.

Changes:

  • Adds explicit presence reporting across built-in extractors, separating subject anchors from auxiliary inputs.
  • Adds SDK discovery/testing helpers, regression coverage, and updated golden fixtures.
  • Documents discovery behavior and the one-time extraction digest change.
File Description
packages/​renderers/​graph/​fixtures/​terraform-modules-before.json Records present Terraform modules.
packages/​renderers/​graph/​fixtures/​terraform-modules-after.json Records present Terraform modules.
packages/​renderers/​graph/​fixtures/​terraform-before.json Records present infrastructure.
packages/​renderers/​graph/​fixtures/​terraform-after.json Records present infrastructure.
packages/​renderers/​graph/​fixtures/​azure-before.json Records present Azure resources.
packages/​renderers/​graph/​fixtures/​azure-after.json Records present Azure resources.
packages/​extractors/​xcode-modules/​tests/​project.rs Tests finalized extraction output.
packages/​extractors/​xcode-modules/​tests/​fixtures/​harbor-app.expected.json Updates presence golden.
packages/​extractors/​xcode-modules/​src/​lib.rs Anchors declared and discovered projects.
packages/​extractors/​workspace-dependencies/​tests/​managers.rs Tests finalized extraction output.
packages/​extractors/​workspace-dependencies/​tests/​fixtures/​yarn-classic.expected.json Updates presence golden.
packages/​extractors/​workspace-dependencies/​tests/​fixtures/​yarn-berry.expected.json Updates presence golden.
packages/​extractors/​workspace-dependencies/​tests/​fixtures/​pnpm.expected.json Updates presence golden.
packages/​extractors/​workspace-dependencies/​tests/​fixtures/​pnpm-catalog.expected.json Updates presence golden.
packages/​extractors/​workspace-dependencies/​tests/​fixtures/​npm.expected.json Updates presence golden.
packages/​extractors/​workspace-dependencies/​tests/​fixtures/​bun.expected.json Updates presence golden.
packages/​extractors/​workspace-dependencies/​src/​lib.rs Anchors the workspace manifest.
packages/​extractors/​typescript-support/​src/​lib.rs Anchors declared TypeScript inputs.
packages/​extractors/​typescript-public-api/​src/​lib.rs Marks successful helper output present.
packages/​extractors/​tetragon-policies/​tests/​fixtures/​skipped/​expected.json Updates presence golden.
packages/​extractors/​tetragon-policies/​tests/​fixtures/​library/​expected.json Updates presence golden.
packages/​extractors/​tetragon-policies/​tests/​fixtures/​deployment/​before.expected.json Updates presence golden.
packages/​extractors/​tetragon-policies/​tests/​fixtures/​deployment/​after.expected.json Updates presence golden.
packages/​extractors/​tetragon-policies/​tests/​fixtures/​credentials/​monitor.expected.json Updates presence golden.
packages/​extractors/​tetragon-policies/​tests/​fixtures/​credentials/​before.expected.json Updates presence golden.
packages/​extractors/​tetragon-policies/​tests/​fixtures/​credentials/​after.expected.json Updates presence golden.
packages/​extractors/​tetragon-policies/​tests/​extractions.rs Covers subject and auxiliary presence.
packages/​extractors/​tetragon-policies/​src/​sources.rs Anchors policy sources and discovery.
packages/​extractors/​tetragon-policies/​src/​lib.rs Keeps workload inputs auxiliary.
packages/​extractors/​terraform-modules/​tests/​modules.rs Tests finalized extraction output.
packages/​extractors/​terraform-modules/​tests/​fixtures/​network/​before.expected.json Updates presence golden.
packages/​extractors/​terraform-modules/​tests/​fixtures/​network/​after.expected.json Updates presence golden.
packages/​extractors/​terraform-modules/​src/​lib.rs Marks repository-wide output present.
packages/​extractors/​terraform-infrastructure/​tests/​terraform.rs Tests finalized extraction output.
packages/​extractors/​terraform-infrastructure/​tests/​fixtures/​aws/​head.expected.json Updates presence golden.
packages/​extractors/​terraform-infrastructure/​tests/​fixtures/​aws/​base.expected.json Updates presence golden.
packages/​extractors/​terraform-infrastructure/​src/​native.rs Anchors native plans and directories.
packages/​extractors/​terraform-infrastructure/​src/​lib.rs Anchors imported plan JSON.
packages/​extractors/​swift-public-api/​tests/​fixtures/​constrained-extensions/​package.expected.json Updates presence golden.
packages/​extractors/​swift-public-api/​tests/​fixtures/​compatibility/​after.expected.json Updates presence golden.
packages/​extractors/​swift-public-api/​src/​tests.rs Tests finalized extraction output.
packages/​extractors/​swift-public-api/​src/​lib.rs Anchors packages or symbol graphs.
packages/​extractors/​swift-package-dependencies/​tests/​package.rs Tests finalized extraction output.
packages/​extractors/​swift-package-dependencies/​tests/​fixtures/​harbor.expected.json Updates presence golden.
packages/​extractors/​swift-package-dependencies/​src/​lib.rs Anchors the declared package input.
packages/​extractors/​spring-di/​src/​lib.rs Anchors snapshots and projects.
packages/​extractors/​sdk/​tests/​source.rs Tests alternative discovery anchors.
packages/​extractors/​sdk/​src/​values.rs Anchors pre-exported database snapshots.
packages/​extractors/​sdk/​src/​testing.rs Finalizes test output and checks goldens.
packages/​extractors/​sdk/​src/​context.rs Adds alternative-glob presence helper.
packages/​extractors/​sdk/​README.md Documents subject-anchor helpers.
packages/​extractors/​scip-file-references/​src/​lib.rs Reports index and indexer presence.
packages/​extractors/​rust-public-api/​src/​lib.rs Reports missing manifests and packages.
packages/​extractors/​repository-map/​src/​lib.rs Marks repository-wide output present.
packages/​extractors/​renderer-scenarios/​src/​lib.rs Marks repository-wide output present.
packages/​extractors/​rails-schema/​tests/​schema.rs Checks discovered-schema presence.
packages/​extractors/​rails-schema/​src/​lib.rs Anchors declared and discovered schemas.
packages/​extractors/​rails-routes/​tests/​routes.rs Covers route-file presence cases.
packages/​extractors/​rails-routes/​src/​lib.rs Anchors declared and discovered routes.
packages/​extractors/​prisma-schema/​tests/​prisma.rs Covers absent and partial schemas.
packages/​extractors/​prisma-schema/​src/​lib.rs Reports absent schema discovery.
packages/​extractors/​openrewrite-data-tables/​tests/​migration.rs Tests finalized extraction output.
packages/​extractors/​openrewrite-data-tables/​tests/​fixtures/​junit5-migration/​before.expected.json Updates presence golden.
packages/​extractors/​openrewrite-data-tables/​tests/​fixtures/​junit5-migration/​after.expected.json Updates presence golden.
packages/​extractors/​openrewrite-data-tables/​src/​lib.rs Reports declared and discovered table presence.
packages/​extractors/​nuget-dependencies/​src/​lib.rs Anchors assets and project discovery.
packages/​extractors/​nestjs-di/​src/​lib.rs Reports missing application inputs.
packages/​extractors/​go-public-api/​src/​lib.rs Reports module and package-pattern presence.
packages/​extractors/​go-public-api/​README.md Documents absent Go API behavior.
packages/​extractors/​github-agentic-workflows/​tests/​fixtures/​repo-ask/​before.expected.json Updates presence golden.
packages/​extractors/​github-agentic-workflows/​tests/​fixtures/​repo-ask/​after.expected.json Updates presence golden.
packages/​extractors/​github-agentic-workflows/​tests/​fixtures/​public/​expected.json Updates presence golden.
packages/​extractors/​github-agentic-workflows/​tests/​fixtures/​docs-bot/​before.expected.json Updates presence golden.
packages/​extractors/​github-agentic-workflows/​tests/​fixtures/​docs-bot/​after.expected.json Updates presence golden.
packages/​extractors/​github-agentic-workflows/​tests/​extractions.rs Covers absent and partial selections.
packages/​extractors/​github-agentic-workflows/​src/​lib.rs Anchors workflow globs; rejects empty selections.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​wide/​before.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​wide/​after.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​release/​before.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​release/​after.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​pipeline/​before.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​pipeline/​after.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​matrix/​before.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​matrix/​after.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​many/​before.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​many/​after.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​delivery/​before.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​delivery/​after.expected.json Updates presence golden.
packages/​extractors/​github-actions-jobs/​tests/​fixtures/​delivery/​absent.expected.json Adds absent-workflow golden.
packages/​extractors/​github-actions-jobs/​tests/​extractions.rs Tests finalized and absent workflow output.
packages/​extractors/​github-actions-jobs/​src/​lib.rs Anchors the workflow file.
packages/​extractors/​dotnet-support/​src/​lib.rs Anchors snapshots, projects, and assemblies.
packages/​extractors/​django-schema/​src/​lib.rs Checks settings-module presence before Python.
packages/​extractors/​django-schema/​Cargo.toml Adds presence-test dependencies.
packages/​extractors/​command-output/​src/​lib.rs Marks command output present.
packages/​extractors/​code-statistics/​tests/​golden.rs Tests finalized extraction output.
packages/​extractors/​code-statistics/​tests/​fixtures/​polyglot/​expected.json Updates presence golden.
packages/​extractors/​code-statistics/​tests/​fixtures/​options/​expected.json Updates presence golden.
packages/​extractors/​code-statistics/​src/​lib.rs Marks repository-wide output present.
packages/​extractors/​catalog/​tests/​presence.rs Checks catalog-wide presence and goldens.
packages/​extractors/​catalog/​Cargo.toml Adds catalog-test dependencies.
packages/​extractors/​cargo-dependencies/​src/​lib.rs Anchors metadata or manifests.
packages/​extractors/​azure-what-if/​tests/​what_if.rs Tests finalized extraction output.
packages/​extractors/​azure-what-if/​tests/​fixtures/​head/​expected.json Updates presence golden.
packages/​extractors/​azure-what-if/​tests/​fixtures/​base/​expected.json Updates presence golden.
packages/​extractors/​azure-what-if/​src/​native.rs Anchors native deployment templates.
packages/​extractors/​azure-what-if/​src/​lib.rs Anchors imported what-if results.
docs/​design/​proposals/​subject-presence.md Records Phase 2 implementation.
docs/​contracts/​extractions.md Documents built-in presence guarantees.
docs/​builtins/​extractors/​go-public-api.md Clarifies absent-module output.
changelog.d/​414.md Records behavior and digest changes.
Cargo.lock Locks added test dependencies.

Review effort: Balanced

Comment thread packages/extractors/sdk/src/context.rs Resolved
- subject_matches_any normalizes alternatives as subject_matches anchors them.
- nuget, rails-routes, xcode and tetragon reject an empty selection, which checked no anchor.
- tetragon carries presence out of its sources: an absent policy set gains no agent,
  kernel or workload enrichment, and a missing chart or kustomization no longer falls
  through to the default globs.

Refs #373

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants