Skip to content

id(artifact): validate known-kind bodies in SignedArtifact::sign / sign_after (#5623) - #6240

Merged
dezren39 merged 1 commit into
mainfrom
queue/10523-5623-sign-validate-known-kinds
Nov 5, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/10523-5623-sign-validate-known-kinds

Conversation

@developing-today

@developing-today developing-today Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5623. Queue task 10523.

What

Construction-vs-receipt symmetry for signed artifacts: SignedArtifact::sign / sign_after (and with them ArtifactLog::sign / sign_after and the directory producers that route through them) now run the receipt check — SignedArtifact::parsed() — on the artifact before returning it. A direct caller can no longer obtain a signed friend_remove, home_declared, document, or tag artifact that parsed() / ArtifactLog::insert would refuse.

  • Known-kind bodies that break a receipt rule fail at signing time with the same Refusal::Forbidden naming the rule; authenticity failures stay Refusal::Unauthenticated — the classes do not blur.
  • Unknown kinds are untouched: still signable envelope-only, parsed() still returns None (forward compatibility preserved).
  • Receipt-side tests that intentionally craft signed-but-refusable artifacts now build them via a new #[cfg(test)] SignedArtifact::sign_unchecked (plus a typed sign_kind_unchecked test helper), following the existing sign_raw_after precedent — receipt refusal stays fully testable.
  • New test signing_a_known_kind_refuses_the_bodies_receipt_refuses pins the symmetry for every known kind, using parsed() on a raw-signed copy as the oracle (per the repo testing doctrine: the oracle is named — it is the receipt check itself).

Tests

On the laptop (CI-first note: run locally on amd-6, not the sandbox):

  • cargo test --lib artifact:: — 38 passed, 0 failed.
  • cargo test --lib (full id lib) — 2256 passed, 0 failed, 6 ignored.

cargo fmt --check reports pre-existing diffs across the repo with the installed rustfmt (untouched files included); no fmt changes were made.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…gn_after (#5623)

Construction-vs-receipt symmetry: sign_after now runs the receipt check (SignedArtifact::parsed) on the artifact it is about to return, so the generic signing helpers and ArtifactLog::sign refuse the same typed-body rules ArtifactLog::insert enforces — friend_remove signed by a non-party, oversize documents, malformed tags, home declarations for another account. Unknown kinds stay signable envelope-only and parsed() still returns None for them; failures stay Refusal::Forbidden, distinct from authenticity failures.

Receipt-side tests that craft signed-but-refusable artifacts now build them through a #[cfg(test)] SignedArtifact::sign_unchecked (plus a typed sign_kind_unchecked helper), following the existing sign_raw_after precedent. New symmetry test signing_a_known_kind_refuses_the_bodies_receipt_refuses pins both sides for every known kind with parsed() as oracle.
@developing-today
developing-today Bot requested review from a team and dezren39 as code owners November 5, 2026 14:00
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 333f9f07-8cfe-40c2-8c77-fee837f51eda

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 merged commit cc45860 into main Nov 5, 2026
5 checks passed
@dezren39
dezren39 deleted the queue/10523-5623-sign-validate-known-kinds branch November 5, 2026 14:40
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.

id(artifact): validate known-kind bodies in generic signing helpers

1 participant