Repository navigation
Extractions report whether their subject is present - #409
Open
agorischek wants to merge 6 commits into
Open
agorischek wants to merge 6 commits into
agorischek wants to merge 6 commits into
Conversation
… operation Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…sence Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…ts/subjectMatches, presenceChange Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
… skill, and the subject-presence proposal 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
Subject-anchor scope and normalization bugs can misreport presence or produce invalid missing inputs, while short-circuiting validation accepts malformed relationship collections.
4 open issues
What changed in this PR
Adds the subject-presence contract to Projections, laying groundwork for distinguishing missing subjects from empty ones in #373. Built-in extractor adoption and viewer changes remain deferred.
Changes:
- Adds optional
presence, validation, canonical encoding, and presence comparison APIs. - Adds subject-anchor helpers for Rust, Node, and Python.
- Extends conformance tests, documentation, and generated references.
| File | Description |
|---|---|
| packages/sdk/src/extractor/subject.ts | Tracks subject anchors and presence. |
| packages/sdk/src/extractor/result.ts | Includes presence in extraction results. |
| packages/sdk/src/extractor/request.ts | Adds subject-check methods. |
| packages/schemas/test/contracts.test.mjs | Tests presence conformance. |
| packages/schemas/src/typebox/extraction.ts | Defines presence constraints. |
| packages/schemas/src/repository/fixtures.ts | Extends fixture formats. |
| packages/schemas/src/presence.ts | Adds synchronous presence classification. |
| packages/schemas/src/index.ts | Exports presence types and APIs. |
| packages/schemas/schemas/extraction/v0.json | Updates generated extraction schema. |
| packages/schemas/internal/extractor-helpers.json | Updates helper fixture schema. |
| packages/schemas/internal/conformance.json | Allows presence operations. |
| packages/schemas/fixtures/extractor-helpers.json | Adds subject-check cases. |
| packages/schemas/fixtures/conformance.json | Adds presence contract cases. |
| packages/extractors/workspace-dependencies/tests/managers.rs | Adapts to fallible finish. |
| packages/extractors/tetragon-policies/tests/extractions.rs | Adapts to fallible finish. |
| packages/extractors/sdk/tests/source.rs | Tests subject-anchor behavior. |
| packages/extractors/sdk/src/entry.rs | Propagates finalization errors. |
| packages/extractors/sdk/src/context.rs | Tracks anchors and finalizes presence. |
| packages/extractors/prisma-schema/tests/prisma.rs | Adapts to fallible finish. |
| packages/extractors/go-public-api/src/lib.rs | Updates test result propagation. |
| packages/engine/tests/volatility.rs | Tests presence differences between reruns. |
| packages/engine/tests/validation.rs | Tests presence validation and digests. |
| packages/engine/src/volatility/rerun.rs | Reports presence differences. |
| packages/engine/src/presence.rs | Implements presence classification and validation. |
| packages/engine/src/parse/request.rs | Dispatches presence requests. |
| packages/engine/src/parse/extraction.rs | Parses and validates presence. |
| packages/engine/src/parse/encode.rs | Encodes reported presence. |
| packages/engine/src/model/extraction.rs | Stores and exposes presence. |
| packages/engine/src/lib.rs | Exports presence APIs. |
| packages/engine/js/test/engine.test.mjs | Runs presence conformance requests. |
| packages/engine/js/src/engine.ts | Exposes engine.presence. |
| packages/cli/test/extractor-helpers/driver.py | Executes Python subject checks. |
| packages/cli/test/extractor-helpers/driver.mjs | Executes Node subject checks. |
| packages/cli/test/extractor-helpers.test.mjs | Creates fixture file trees. |
| packages/cli/templates/SKILL.md | Documents subject checks for authors. |
| packages/cli/python/projections/__init__.py | Adds Python presence helpers. |
| packages/cli/node/extractor.mjs | Updates bundled Node helpers. |
| docs/reference/schemas/extraction.md | Documents the presence field. |
| docs/reference/renderer-kit.md | Updates extraction type reference. |
| docs/reference/extractor-sdk.md | Documents Rust SDK additions. |
| docs/guides/first-extractor.md | Demonstrates absent-subject handling. |
| docs/design/proposals/subject-presence.md | Describes design and migration phases. |
| docs/contracts/extractors.md | Defines absent-subject output. |
| docs/contracts/extractions.md | Specifies presence semantics. |
| docs/contracts.md | Documents the presence operation. |
| docs/agents/create-projection.md | Mirrors authoring guidance. |
| changelog.d/409.md | Announces the contract and helpers. |
Review effort: Balanced
4 tasks done
- Pass cx.files() to subject_matches directly in the SDK tests (clippy unnecessary_to_owned). - Engine presence: check entities and relationships both before combining them. - Rust subject_matches: drop a leading ./ before compiling the glob; reject an empty one. - Node and Python anchors: reject rooted anchors before trimming, without a polynomial regex; reject a glob that names the project; refuse path anchors outside a declared scope, as Rust does. - Helper fixture schema: write the checks pair with prefixItems (JSON Schema 2020-12). Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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
Refs #373. This is Phase 1 of the subject-presence design (
docs/design/proposals/subject-presence.md): the contract. An extraction can now say whether what its projection describes exists at the examined revision, so later phases can tell "this change adds the workflow" from "this workflow declares no jobs".Schema.
extraction/v0gains an optionalpresence: "present" | "absent". Omitted means not reported, which is unknown and never present. The JSON Schema requires anabsentextraction to have no items and a nonemptymissingInputs. The docs note that v1 will makepresencerequired.Engine (native and Wasm):
presenceand keeps it as written, either value. It's in the canonical bytes when written, so extractions that omit it keep their bytes and digests.invalid-presence,absent-with-itemsandabsent-without-missing-input.varyreports/presence.projections_engine::presence_change(before, after), exposed as thepresenceoperation andengine.presence(before, after). It returns{before, after, change, inferred}, wherechangeisadded,removed,absent,presentorunknown.presentwhen it has items, since an absent extraction can't have any.absentwhen it has no items and names missing inputs (the legacy heuristic).unknown.inferredis true when either side was inferred.presenceChangeandextractionPresencein@githubnext/projections-schemasmirror the function in TypeScript for synchronous callers (the kit and hosts in Phase 3). Newpresencecases in the shared conformance corpus hold the Rust engine, native and Wasm JS, and the TS mirror to the same answers.SDK helpers:
Context::subject_exists(path)andContext::subject_matches(glob, files)check anchors of the subject.finish(now-> Result<Value>) writespresence:absentwhen no anchor checked exists,presentwhen any does. It fails when an absent extraction returned items. An explicitpresenceis kept, andinput_existsstays for auxiliary inputs.request.subjectExists(path)andrequest.subjectMatches(glob).request.subject_exists(path)andrequest.subject_matches(glob).extraction()andresult()acceptpresenceand fill inpresenceandmissingInputsfrom the checks.extractor-helpers.jsongainsfilesandchecks, so both helpers are pinned on real file trees.Docs:
docs/contracts/extractions.mdgains a Presence section, anddocs/contracts/extractors.mdan "An absent subject" section.docs/contracts.mddocuments thepresenceoperation.SKILL.mdand its generated copy, plus the regenerated schema, extractor-SDK and renderer-kit references.docs/design/proposals/subject-presence.md.No built-in extractor changes here, so no built-in output or digest changes. Phase 2 makes built-ins write
presenceon every extraction, which changes their digests once.Evidence
cargo test -p projections-engine -p projections-extractor-sdk -p projections-extractor-go-public-api -p projections-extractor-prisma-schema -p projections-extractor-workspace-dependencies -p projections-extractor-tetragon-policies: passed, 0 failures. This covers:missingInputs, and absent with items is an error.cargo check --workspace --all-targets: passed.node --test packages/engine/js/test/*.test.mjs: 257/257 passed, with the corpus run through the native and Wasm engines.npm test --workspace @githubnext/projections-schemas: 25/25 passed, including the TS mirror against the corpus and the generated-file check.node --test packages/cli/test/extractor-helpers.test.mjs: 39/39 passed (Node and Python).node --test packages/sdk/test/extractor.test.ts: 9/9 passed.node packages/sdk/scripts/extractor-module.mjs --checkalso passed.tsc --noEmitforpackages/sdk,packages/engine/jsandpackages/schemas: passed.npm run tools -- check --fast: format, lint, considered, cargo-fmt, cargo-check and the repository rules passed.Generated files:
docs/reference/schemas/extraction.md,docs/reference/extractor-sdk.mdanddocs/reference/renderer-kit.mdwere regenerated withtools/scripts/reference-docs.mjs --only schemas,rust-sdk,renderer-sdk.docs/agents/create-projection.mdwas not regenerated. Its generator needsprojections help authoringwith every renderer built, which this environment couldn't do, so I mirrored theSKILL.mdedit verbatim.npm run docs:checkin CI verifies it.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 what users will notice, or the PR has theno changeloglabel (see changelog.d/README.md).No credentials, private source or machine-specific paths are included.