Skip to content

feat(artifacts): inspect RPM package headers and dependency metadata - #10677

Closed
mvanhorn wants to merge 50 commits into
morluto:mainfrom
mvanhorn:feat/rpm-package-metadata
Closed

mvanhorn wants to merge 50 commits into
morluto:mainfrom
mvanhorn:feat/rpm-package-metadata

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add inspect-rpm-package / inspect_rpm_package for read-only inspection of one local RPM: lead/signature/header locations, package identity, dependencies, scriptlet presence, and header file inventory as retained Evidence. Script source is opt-in; payloads are not decompressed and signatures are not verified. No related issue exists; target-execution scope approval is not applicable.

Contract and implementation

  • The RPM parser owns byte interpretation and preserves missing/uncertain facts. Shared stable-artifact admission owns file identity, cancellation, descriptor cleanup and retry; CLI/MCP share application admission and Evidence assembly.
  • Preserve caller-selected parameters, including explicit false/default values. Redact transport URL userinfo through the shared URL owner before success output or malformed-UTF-8 byte diagnostics, preserving other source spelling. Complete reports and retained summary views agree.
  • Validate header extents before allocation. Caller limits bound file/index/file-row/script inputs; shared fixed allowances admit known values and decoded text across both headers before materialization. Limits retain observed facts and snapshot identity, and distinguish adjustable budgets from fixed recovery.
  • Register capability/lifecycle coverage and update the owning guide, specification, generated skill sources and contracts. No runtime dependency or installer change.

Validation

  • Initial integration: 425 focused source/public-boundary/lifecycle tests passed. The final materialization correction: 335 relevant test passes across targeted runs (overlapping coverage), including the shared physical-artifact matrix and registered MCP boundary tests.
  • Source/scripts typechecking, changed-file lint/formatting, architecture/module/numeric guards, Knip, docs, test discovery and advertised-schema checks passed as applicable. Optional C++ RE2 and Rust schema engines were unavailable. Full typed lint and combined local gates are deferred to exact-head CI.
  • Review follow-up: 77 source tests and 10 compiled public tests passed, including actual CLI/MCP malformed-URL refusals without plaintext or hex credential echoes. Three tiny sibling CLI comparisons passed; no sibling source changes. Typecheck, changed-file lint, formatting and architecture guards passed. The byte-prefix diagnostic reports its full length and documents the sample bound.
  • Nine actual compiled CLI/stdio-MCP comparisons, six retained records and six retained summary views matched a pinned official rpm-software-management fixture and upstream query expectations. Input SHA-256 remained unchanged; MCP sessions reported no pending cleanup.
  • Tiny injected component/parser/in-process MCP quotas verify refusal semantics. Ordinary compiled workflows use production allowances; no full-limit exhaustion or OOM experiment was performed. Checks ran serially under resource bounds.

Coverage limits: the official producer fixture is not a locally executed rpm query or a distributor survey. Its homepage/scriptlet tags are absent; benign synthetic fixtures cover those fields. No installation, script execution, payload extraction, signature verification or real Windows execution was performed locally. Exact-head CI/review results will be recorded after completion.

Author readiness

Human owner: @mvanhorn

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-14T21:06:08.966271Z
We couldn’t complete this review. Comment @codex review to try again.
2317e80 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The latest follow-up appears safe to merge; it changes no runtime behavior.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The latest follow-up appears safe to merge; it changes no runtime behavior.

Summary

Adds read-only RPM inspection through CLI and MCP, with package metadata, dependencies, scriptlets, file inventory, and retained Evidence.

  • REA can inspect local RPM headers and dependency details.
  • RPM summaries show package identity and counts without full detail rows.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[CLI or MCP] --> B[Shared caller checks]
  B --> C[Stable file read and hash]
  C --> D[Bounded RPM parser]
  D --> E[Evidence]
  E --> F[Complete report]
  E --> G[Retained summary view]
Loading

Reviews (36) · Last reviewed commit: "chore(rpm): explain diagnostic byte samp..." · Reviewed by Greptile

Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackage.errors.ts Resolved
Comment thread src/cli/rpmPackageCommands.ts Resolved
Comment thread tests/acceptance/rpmPackageCli.test.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
…ection

The RPM command restated its contract fields as hand-written incur options
and mapped them back to contract input. Register it with
registerContractCommand so its option schemas and decimal arguments derive
from inspect_rpm_package and the command-parity test covers it.

The contract projection gains an evidenceDelivery flag that adds the
--detail and --evidence_output options and hands the delivery choice to the
handler; deliverWithService delivers through the shared Evidence path. The
parity test allows those delivery keys alongside the contract fields.
…lure path

The RPM parser had its own RpmPackageFormatFailure class, hand-rolled bounds
checks over raw Buffer reads, and a provider ladder that folded truncation
into malformed. It now reads fields through BinaryReader and throws
ParseFailureError (format "rpm"), so a short lead or a header whose index or
data store runs past the file is reported as truncated, while inconsistent
structure inside a present data store stays malformed.

RpmPackageProvider projects those failures with parseFailureAnalysisError.
The lead and signature facts decoded before a failure still reach the
refusal: ParseFailure gains an optional observed fact, which
parseFailureAnalysisError carries onto the invalid_format issue. Budget
refusals keep RpmPackageCapacityFailure and their per-limit remediation.

src/rpm/ joins the parser folders the architecture guards count.
The RPM CLI acceptance and MCP boundary tests now resolve
inspect_rpm_package by name from RPM_PACKAGE_TOOL_CONTRACTS instead of
importing the full tool catalog, per docs/development/testing.md.
STRING, STRING_ARRAY and I18NSTRING values were read with
toString("binary"), so UTF-8 summaries, file paths and scriptlets came
back as Latin-1 mojibake. Decode them as UTF-8 and keep each value's
stored byte length alongside it, so scriptlet byte counts and the
script budget still use the bytes in the data store.

The fixture encoder now writes UTF-8 instead of "binary", and a new
fixture with a non-ASCII summary, file path and scriptlet covers it.
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
The trigger loop paired TRIGGERNAME entries with TRIGGERSCRIPTS by
position and never read TRIGGERINDEX. TRIGGERNAME lists conditions, not
one name per script, so with names ["foo", "bar", "baz"] and indexes
[0, 0, 1] the second script was labeled "bar" and a condition was lost.

The parser now reads TRIGGERINDEX, refuses a missing, mismatched or
out-of-range index as a malformed ParseFailureError, and groups every
condition under the script it points to. The scriptlet row field is now
a trigger_names list (null for non-trigger rows), with the schema, docs
and tests updated, and a fixture covers indexes [0, 0, 1].
After the signature header decoded, the observing() wrapper kept only
its location and entry count, so a truncated or malformed main header
dropped the signature digests, size and blob presence that had already
been read. The full signature observation is now built right after the
signature header decodes and attached to any later failure, as AGENTS.md
requires for completed observations. The payload digest still falls back
to the main header in the finished report.

A new fixture truncates the main header after a complete signature
header, and its test asserts those fields survive in the error's
observed facts.
SCRIPTLET_SENSE left out RPMSENSE_PRETRANS (0x80) and
RPMSENSE_POSTTRANS (0x20), so a Requires(pretrans) or
Requires(posttrans) row reported scriptlet_only: false and read like an
ordinary runtime requirement. Add both sense bits to RPM_SENSE and the
mask, and cover them with a parser fixture row for each.
When a dependency set had names but no flags tag, dependencies()
invented flags: 0 and scriptlet_only: false, and file rows reported
config: false and doc: false when FILEFLAGS was absent. Callers could
not tell "not recorded" from "false".

Report flags, comparison and scriptlet_only as null for dependency rows
without a flags tag, and flags, config and doc as null for file rows
without FILEFLAGS. The domain schema (and the contract output schema
built from it) now allows those nulls, the guide documents them, and a
parser test covers a package whose flags tags are absent.
The header getters returned undefined for a present tag whose stored
kind did not match, so an in-bounds PREIN stored as INT32 decoded fine,
was then treated as missing, and the report omitted that scriptlet while
claiming complete coverage.

parseHeader now checks every tag the report reads against a per-header
spec of allowed types and, where RPM fixes it, the count (NAME, EPOCH,
SIG_MD5 and siblings) before decoding, and refuses a mismatch through
the shared ParseFailureError path as malformed, keeping signature facts
in observed. The getters return undefined only for an absent tag and
refuse any other kind. The separate MD5 length check is folded into the
signature spec. New tests cover an INT32 PREIN fixture, a two-value
EPOCH, and an 8-byte SIG_MD5.
Header strings were decoded with toString("utf8"), which silently
replaces invalid sequences with U+FFFD, so two different filename byte
sequences could produce the same reported path with no warning. The
separate byte count did not preserve the bytes themselves.

Header text now stays raw until a reader needs it and is decoded with a
fatal UTF-8 decoder. A value the report includes (a file path, package
field, dependency, or requested scriptlet text) that is not valid UTF-8
is refused as malformed through ParseFailureError, matching how the ZIP
and firmware readers refuse lossy names. The refusal names the tag and
entry index and quotes the raw bytes in hex, and keeps lead and
signature facts in observed. Tags the report never reads are no longer
decoded, and omitted scriptlet text still reports its stored byte
length. Tests cover a BASENAMES entry with a Latin-1 byte and a
scriptlet whose invalid text is refused only when requested.
rpm -qp reads a package file without installing it or running scriptlets.
The spec now states the benefit as built-in inspection without RPM on the
host, as the review suggested.
Main now carries its own Evidence delivery projection for contract commands,
so the CLI projection files take main's version and inspect-rpm-package
joins the parity test's command list. parseFailureAnalysisError keeps main's
field parameter and this branch's observed facts. The advertised-dialect
baseline that main added takes the counts the inspect_rpm_package input adds.
@mvanhorn

Copy link
Copy Markdown
Contributor Author

62b8c82 merges current main. Main now has its own Evidence delivery projection for contract commands, so contractCliDescription.ts and contractCommand.ts take main's version and inspect-rpm-package uses it through evidenceDelivery: true. parseFailureAnalysisError keeps main's field parameter alongside this branch's observed facts, and the new advertisedDialectBaseline.ts records the counts the inspect_rpm_package input adds.

Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.ts Resolved
Main now requires every top-level src unit in UNIT_LAYERS. src/rpm is a
provider like src/sqlite, and its two type imports of application ports
are recorded in the upward-import baseline the same way.
A present FILESIZES, FILEMODES, FILEDIGESTS, FILEFLAGS, FILEUSERNAME or
FILEGROUPNAME array must hold one value per BASENAMES row, and a present
TRIGGERSCRIPTPROG one per TRIGGERSCRIPTS entry. A mismatch is now a
malformed refusal instead of null values that read as absent tags.
Comment thread src/rpm/RpmPackageParser.ts Resolved
Comment thread src/rpm/RpmPackageParser.test.ts Resolved
parseFailureAnalysisError now carries a ParseFailureError's observed
facts onto AnalysisUnsupportedTargetError as diagnostics.observed, so an
RPM whose lead names an unsupported signature type keeps the lead facts
through CLI and MCP, as malformed and truncated refusals already do.
A header whose declared index and data store run past the end of the
file is now refused as truncated before the max_header_index_entries
budget is checked, so a corrupt count no longer suggests raising a
budget that cannot supply the missing bytes.
Packages with large files store per-file sizes in LONGFILESIZES (5008,
INT64). files() now prefers it and falls back to FILESIZES, and checks
the chosen array against BASENAMES the same way.
The per-file and TRIGGERSCRIPTPROG mismatch refusals no longer set
observed to the array length, which the detail already states, so
observing attaches the lead and signature facts read before them.
Match failure.kind and failure.field, and the saved lead and signature
facts, instead of the explanatory message text.
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Main moved again, so fc790a0 merges the latest main into this branch. Main dropped src/cliCommandNames.ts and now declares each tool's CLI command and effects on its contract, so inspect_rpm_package takes cli: true and its effects there, and the RPM entries in scripts/lib/test-projects.mjs, scripts/verify/architecture-guards.mjs and the module-layer baseline follow main's format. npx tsc --noEmit -p tsconfig.json passed. npm run verify:module-boundaries passed. npx vitest run src/application/rpm/RpmPackageService.test.ts src/domain/analysisView/rpmPackageView.test.ts src/domain/rpm/package.test.ts src/rpm/RpmPackageParser.test.ts tests/acceptance/rpmPackageCli.test.ts tests/boundary/mcp/rpmPackageMcp.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/mcp/contractToolBindings.test.ts tests/evaluation/providerLifecycleCoverage.test.ts failed.

Comment thread src/rpm/RpmPackageProvider.ts Resolved
Comment thread src/rpm/RpmPackageProvider.ts Resolved
A BASENAMES or other per-file array could declare millions of empty strings
in a zero-filled store, and every value was built before the max_files
budget was checked. Refuse a main-header per-file tag whose declared count
is above max_files before decodeEntry reads it.
…lure

rpmFailure and rpmFailurePrimary repeated the shared rules for file
identity, cancellation, limits, paths and fallback errors. Route every raw
failure through classifyProviderFailure with an RPM dialect that names only
the parser format refusals and the budget refusals with their recovery text.
List tests/acceptance/rpmPackageCli.test.ts as the public-workflow case for
the rpmPackage capability so the provider conformance suite covers it.
The RPM provider imported its port from the application layer, which the
baseline allowance rpm -> application hid. Move the port beside the other
provider ports, point the service and provider at it, and drop the
allowance so the upward baseline is empty again.
Comment thread src/rpm/RpmPackageParser.ts Resolved
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Main moved again, so a8b7bf9 merges the latest main into this branch. The only conflict was the source test glob in scripts/lib/test-projects.mjs, where main added compression and this branch added rpm; the merge keeps both. npx tsc --noEmit -p tsconfig.json passed. npm run verify:module-boundaries passed. npx vitest run src/application/rpm/RpmPackageService.test.ts src/domain/analysisView/rpmPackageView.test.ts src/domain/rpm/package.test.ts src/rpm/RpmPackageParser.test.ts tests/acceptance/rpmPackageCli.test.ts tests/boundary/mcp/rpmPackageMcp.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/mcp/contractToolBindings.test.ts tests/evaluation/providerLifecycleCoverage.test.ts failed.

A main-header per-file tag whose declared count cannot fit in the bytes
stored after its offset, such as FILEMODES with a count above max_files
but one stored value, threw RpmPackageCapacityFailure and advised raising
max_files. Placement and the minimum stored extent are now checked first,
without reading or allocating the value, so that file is refused as
malformed. The budget still runs before any rows are built.
Main now refuses new hand-built AnalysisResourceConstraintError copies
(morluto#11456). The RPM provider reports the one limit it stopped at through
decodeLimit and parseLimitConstraint, keeping its recovery advice, and
the inspect_rpm_package advertised catalog summary picks up the output
schema change from main.
Conflicts resolved:
- scripts/verify-grok-client.mjs: main now pages native search_tool past
  the uint8 limit with bounded keyword queries, which covers the same
  catalog growth this branch handled; main's version is kept.
- docs/index.md, docs/specs/README.md and the ko, th, zh and zh-TW
  READMEs: main's tables and lists are kept with the RPM package rows
  and links added back.
The stable-artifact consumer tests enroll every provider in the nested
descriptor owner and recorded-cancellation cases. The RPM dialect had no
readCleanup, so a read whose close failed lost its cleanupPrimary. It
now reports the read's cleanup around the original physical failure or
the recorded cancellation, bound to the read's descriptor leases.
@mvanhorn

Copy link
Copy Markdown
Contributor Author

b3cd308 merges the latest main into this branch: the client verifier script under scripts/ takes main's version, since main now pages search_tool past the uint8 limit the same way this branch did, and docs/index.md, docs/specs/README.md and the ko, th, zh and zh-TW READMEs keep main's tables with the RPM rows and links added back. 51ca8b1 then gives the RPM failure dialect a readCleanup, so a read whose descriptor close fails keeps the original failure or cancellation as its cleanup primary.

gensokyo-dev and others added 2 commits November 17, 2026 15:02
Preserve the contributor history and current main registrations. Produce named
parser limits before allocation, retain stable-file identity and exact cleanup
owners, redact only transport URL userinfo, and record caller-selected inputs
through CLI, MCP, retained views and late cancellation.

Validate bounded source/public/lifecycle controls and compare the built tool
against pinned official RPM producer fixture expectations without running rpm,
installing packages, executing scriptlets or unpacking payloads.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Co-authored-by: gensokyo-dev <[email protected]>
Share element and decoded-text allowances across both RPM headers. Admit known
vectors before allocation, decode stored text lazily once, and retain observed
header facts with fixed parser refusals. Keep omitted script source undecoded.

Cover tiny component quotas, parser producers and registered in-process MCP
refusals, alongside ordinary compiled CLI/MCP and official-fixture comparisons.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Co-authored-by: gensokyo-dev <[email protected]>

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the RPM integration and follow-up materialization ownership against the current contracts. Local targeted validation and the pinned producer-fixture CLI/MCP comparisons are documented, including the absence of a local rpm query, signature verification and real Windows execution. Exact-head CI remains required before merge.

Comment thread src/rpm/RpmPackageParser.ts Resolved
Project the known URL's raw bytes through the shared transport URL owner before
hex quoting a UTF-8 refusal. Preserve noncredential byte spelling, omit an
ambiguous credential-bearing quote, and retain strict failure and file identity.

Cover parser and actual CLI/MCP diagnostics with benign fixture credentials,
plus working malformed-text comparisons for sibling metadata readers.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Co-authored-by: gensokyo-dev <[email protected]>

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the final RPM integration and malformed-URL diagnostic correction. Credential filtering now occurs before raw-byte diagnostic projection, with strict refusal and snapshot provenance retained. Targeted source and actual CLI/MCP regressions passed; coverage limitations remain documented. Require final exact-head CI before merge.

Document the diagnostic prefix as a sample whose complete byte count is already reported, satisfying the architecture guard without changing runtime behavior.

Assisted-by: Suika (gensokyo-skills:suika-scatter-gather-planning)
Co-authored-by: gensokyo-dev <[email protected]>

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the final RPM integration, credential-safe malformed-URL diagnostic and documented byte-prefix sample bound. Focused parser and actual CLI/MCP regressions, typecheck, changed lint and architecture guards passed; documented coverage limits remain. Final exact-head CI is required before merge.

@N0zoM1z0
N0zoM1z0 enabled auto-merge (squash) November 17, 2026 15:47
@N0zoM1z0
N0zoM1z0 disabled auto-merge November 17, 2026 15:53
@N0zoM1z0 N0zoM1z0 closed this Nov 17, 2026
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants