Skip to content

fix(decode): apply array element contracts in AttrValue::from_term_at - #2047

Merged
norrietaylor merged 4 commits into
mainfrom
inbox-patch/fix-decode-array-contracts-6f54facd0fb0d8c3
Oct 7, 2026
Merged

norrietaylor merged 4 commits into
mainfrom
inbox-patch/fix-decode-array-contracts-6f54facd0fb0d8c3

Conversation

@gominimal-aw-bot

@gominimal-aw-bot gominimal-aw-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABVhE3CQ

AttrValue::from_term_at applies each record field's pending contracts before descending, but the array branch iterated elements raw. Any attr whose validate is Array C therefore accepted whatever its elements held on every consumer path (e.g. env_dir_mappings = [42] evaluated without error despite the Array { read_only | Bool, path | String, class | [| 'Credential, 'State |] } contract).

The array branch now applies the array's pending contracts to each element, mirroring the record branch, so a bad element is rejected.

Behaviour change: configs with array elements that break their declared contract now fail to decode, with a 'contract broken' error that names the element.

Verification

cargo fmt --all --check --manifest-path Cargo.toml — clean
cargo clippy --workspace --all-targets --locked --manifest-path Cargo.toml -- -D warnings — Finished, no warnings
cargo test --locked --manifest-path Cargo.toml -p decode — 71 passed; 0 failed

The array branch iterated elements raw, so an attr whose validate is
Array C accepted any element on every consumer path. Apply the array's
pending contracts to each element, mirroring the record branch, so a
bad element is rejected.
@gominimal-aw-bot
gominimal-aw-bot Bot requested a review from a team as a code owner October 7, 2026 04:24
@gominimal-aw-bot gominimal-aw-bot Bot added the agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. label Oct 7, 2026
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 1 billable file and costs up to $0.25.

Or wait 23 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 6af1a796-3c78-48e2-9072-efd9c746f9a8
📥 Commits

Reviewing files that changed from the base of the PR and between c1072c9 and e19d281.

📒 Files selected for processing (1)
  • crates/decode/src/attrs.rs
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@norrietaylor norrietaylor changed the title fix: Apply array element contracts in AttrValue::from_term_at fix(decode): apply array element contracts in AttrValue::from_term_at Oct 7, 2026
@gominimal-aw-bot gominimal-aw-bot Bot added the agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch label Oct 7, 2026
@norrietaylor

Copy link
Copy Markdown
Member

/review

@minimal-foundry

minimal-foundry Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Approved: no findings at e19d281a33af.

Nothing to do.

Clobber: none: git log -- crates/decode/src/attrs.rs shows only this PR's three commits (fix, plus the two test commits) at the head; nothing reverted.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minimal-review — approved

Verdict APPROVE — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 7, 2026
@norrietaylor
norrietaylor added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit a558026 Oct 7, 2026
37 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/fix-decode-array-contracts-6f54facd0fb0d8c3 branch October 7, 2026 07:25
bryan-minimal added a commit that referenced this pull request Oct 14, 2026
…; comment after #2047

Review (mitodrummer, 10-10): resetting revision to 0 on a bump while a
build patch survives produced a bump PR that fails the ledger rule. The
counter restarts at 0 only when no patch survives, else 1 (spec REV-002
amended to match); test pins both states. The eager-fold comment now gives
its real reason (per-entry messages), since #2047 applies element contracts
on the consumer path too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bryan-minimal added a commit that referenced this pull request Oct 14, 2026
…sequence syntax

Review (mitodrummer, 10-10): resetting revision to 0 on an upstream bump
while a build patch survives produced a bump PR the ledger rule refuses
to load. The counter restarts at 0 only when no patch survives, else 1
(spec REV-002, gominimal/pkgmgr-rs#962); a test pins both states.

CveId now follows CVE syntax: a four-digit sequence may be zero-padded,
five or more digits may not start with zero (CodeRabbit). The eager-fold
comment gives its real reason after #2047.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bryan-minimal added a commit that referenced this pull request Oct 16, 2026
…st it (#1277)

* feat(stdlib): revision counter and typed patch ledger in Attrs

Two attrs for the security-patch convention in gominimal/inbox#511: a
`revision` counting the patch-sets applied on top of upstream_version,
and a typed `patches[]` ledger naming what each one fixed. Entries are
contract-enforced, so a blank cve or origin refuses to parse rather than
producing an SBOM row that asserts nothing.

`upstream_version` gains a contract: it never carries an `-rN` suffix,
because it is the advisory-matching key that feeds and `pkgmgr check`
compare against. None of the registry's recipes violate it.

Attrs is a closed schema, so recipes may set these only once every
consumer carries this stdlib. The publish-boundary `qualified_version()`
in pkgmgr renders `-rN` into SBOM, OpenVEX and secdb output.

Refs: gominimal/inbox#511, gominimal/pkgmgr-rs#750

* feat(stdlib): type the patch ledger by kind, and check revision against it

A ledger entry carries a kind of security, build or vendor; only a
security fix must name its CVE and upstream commit, and the records are
closed so a build or vendor entry cannot carry one. The ledger is checked
entry by entry when the attribute is, because a consumer that reads attrs
as values sees an array's elements without their contracts. Across
attributes, a non-empty ledger needs revision >= 1, and neither revision
nor patches is accepted without an upstream_version to qualify. An attr
that fails now says why. decode gains the tests the spec names for
REV-001, REV-003 and REV-011.

stdlib 0.0.22.

Refs: gominimal/inbox#511

* fix(stdlib): restart revision at 1 when a patch survives a bump; CVE sequence syntax

Review (mitodrummer, 10-10): resetting revision to 0 on an upstream bump
while a build patch survives produced a bump PR the ledger rule refuses
to load. The counter restarts at 0 only when no patch survives, else 1
(spec REV-002, gominimal/pkgmgr-rs#962); a test pins both states.

CveId now follows CVE syntax: a four-digit sequence may be zero-padded,
five or more digits may not start with zero (CodeRabbit). The eager-fold
comment gives its real reason after #2047.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants