Skip to content

Compose referent content laws at explicit metadata pairs - #3895

Open
joshlf wants to merge 1 commit into
G5mwz4ieerzmvrwzsvsuahndzgsjmd53sfrom
Gvxor5zd4poticd2jnomp3vuskfptpxar
Open

joshlf wants to merge 1 commit into
G5mwz4ieerzmvrwzsvsuahndzgsjmd53sfrom
Gvxor5zd4poticd2jnomp3vuskfptpxar

Conversation

@joshlf

@joshlf joshlf commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

A content transfer between dynamically sized referents needs the actual
source and destination metadata. Equal byte widths cannot substitute a
different count, especially for zero-sized or uninhabited elements.

Derive each storage view's decoder and metadata from its installed model
profile. Prove initialization, completeness, and transfer composition at
one explicit pair, retaining the same intermediate view and metadata in
both premises. Check wrapper metadata, empty domains, missing storage,
and rejection of undef even with a trivial postcondition.

These helpers do not change native TransmuteFrom promises or admit pointer
execution, resource reasoning, or an assumed model of a local function.

Authored by an AI agent acting on joshlf's behalf.


⬇️ Download this PR

Branch

git fetch origin refs/heads/Gvxor5zd4poticd2jnomp3vuskfptpxar && git checkout -b pr-Gvxor5zd4poticd2jnomp3vuskfptpxar FETCH_HEAD

Checkout

git fetch origin refs/heads/Gvxor5zd4poticd2jnomp3vuskfptpxar && git checkout FETCH_HEAD

Cherry Pick

git fetch origin refs/heads/Gvxor5zd4poticd2jnomp3vuskfptpxar && git cherry-pick FETCH_HEAD

Pull

git pull origin refs/heads/Gvxor5zd4poticd2jnomp3vuskfptpxar

Stacked PRs enabled by GHerrit.

A content transfer between dynamically sized referents needs the actual
source and destination metadata. Equal byte widths cannot substitute a
different count, especially for zero-sized or uninhabited elements.

Derive each storage view's decoder and metadata from its installed model
profile. Prove initialization, completeness, and transfer composition at
one explicit pair, retaining the same intermediate view and metadata in
both premises. Check wrapper metadata, empty domains, missing storage,
and rejection of undef even with a trivial postcondition.

These helpers do not change native TransmuteFrom promises or admit pointer
execution, resource reasoning, or an assumed model of a local function.

gherrit-pr-id: Gvxor5zd4poticd2jnomp3vuskfptpxar
Agent-authored-by: AI agent acting on joshlf's behalf
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T22:22:07.974537Z 476ba6a PR opened
🔒 Security Review ✅ Completed 2026-10-15T22:23:23.481530Z 476ba6a 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.

This was referenced Oct 15, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces the IndexedReferent adapter and its corresponding tests in Lean 4, which compare byte domains at explicit metadata values to support content implications. It also updates the design and audit documentation to reflect these additions. The review feedback focuses on improving the robustness and readability of the Lean code by replacing positional underscores with named arguments in theorems like safe_to_initialized and initialized_to_safe, and making several parameters implicit in transfer_trans to simplify its usage in tests.

Comment on lines +115 to +120
theorem safe_to_initialized {source : RustModel Src} {destination : RustModel Dst}
(sourceView : StorageView source) (sm : sourceView.Metadata)
(destinationView : StorageView destination) (dm : destinationView.Metadata)
(law : sourceView.decoder.Initialized) :
transferAt sourceView sm destinationView dm .safe .initialized :=
Rust.Referent.safe_to_initialized _ source.decode law sm _ _

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.

medium

Using positional underscores (_) for explicit arguments can be fragile and hard to read. In Lean 4, it is more robust and idiomatic to use named arguments for parameters that cannot be automatically inferred, allowing Lean to implicitly synthesize the rest.

theorem safe_to_initialized {source : RustModel Src} {destination : RustModel Dst}
    (sourceView : StorageView source) (sm : sourceView.Metadata)
    (destinationView : StorageView destination) (dm : destinationView.Metadata)
    (law : sourceView.decoder.Initialized) :
    transferAt sourceView sm destinationView dm .safe .initialized :=
  Rust.Referent.safe_to_initialized (decodeModel := source.decode) (initialized := law) (metadata := sm)

Comment on lines +122 to +127
theorem initialized_to_safe {source : RustModel Src} {destination : RustModel Dst}
(sourceView : StorageView source) (sm : sourceView.Metadata)
(destinationView : StorageView destination) (dm : destinationView.Metadata)
(law : destinationView.decoder.CompleteWith destination.decode) :
transferAt sourceView sm destinationView dm .initialized .safe :=
Rust.Referent.initialized_to_safe _ destination.decode law dm _ _

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.

medium

Similarly to safe_to_initialized, using named arguments here avoids fragile positional underscores and improves readability.

theorem initialized_to_safe {source : RustModel Src} {destination : RustModel Dst}
    (sourceView : StorageView source) (sm : sourceView.Metadata)
    (destinationView : StorageView destination) (dm : destinationView.Metadata)
    (law : destinationView.decoder.CompleteWith destination.decode) :
    transferAt sourceView sm destinationView dm .initialized .safe :=
  Rust.Referent.initialized_to_safe (decodeModel := destination.decode) (complete := law) (metadata := dm)

Comment on lines +141 to +151
theorem transfer_trans {source : RustModel Src} {middle : RustModel Mid}
{destination : RustModel Dst}
(sourceView : StorageView source) (sm : sourceView.Metadata)
(middleView : StorageView middle) (mm : middleView.Metadata)
(destinationView : StorageView destination) (dm : destinationView.Metadata)
(firstState middleState lastState : Rust.Referent.State)
(first : transferAt sourceView sm middleView mm firstState middleState)
(second : transferAt middleView mm destinationView dm middleState lastState)
(width : sourceView.decoder.byteSize sm = middleView.decoder.byteSize mm) :
transferAt sourceView sm destinationView dm firstState lastState :=
Rust.Referent.transfer_trans _ _ _ _ _ _ _ _ _ first second width

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.

medium

Many of the explicit parameters of transfer_trans (such as the views, metadata, and states) can be uniquely inferred by Lean's elaborator from the types of first, second, and width. Making these parameters implicit ({}) simplifies the theorem's usage significantly. Additionally, using named arguments for the call to Rust.Referent.transfer_trans avoids fragile positional underscores.

theorem transfer_trans {source : RustModel Src} {middle : RustModel Mid}
    {destination : RustModel Dst}
    {sourceView : StorageView source} {sm : sourceView.Metadata}
    {middleView : StorageView middle} {mm : middleView.Metadata}
    {destinationView : StorageView destination} {dm : destinationView.Metadata}
    {firstState middleState lastState : Rust.Referent.State}
    (first : transferAt sourceView sm middleView mm firstState middleState)
    (second : transferAt middleView mm destinationView dm middleState lastState)
    (width : sourceView.decoder.byteSize sm = middleView.decoder.byteSize mm) :
    transferAt sourceView sm destinationView dm firstState lastState :=
  Rust.Referent.transfer_trans (first := first) (second := second) (middleWidthAgrees := width)

Comment on lines +91 to +93
example : transferAt unitSliceView (0#usize) unitSliceView (2#usize) .safe .safe :=
transfer_trans unitSliceView (0#usize) unitSliceView (1#usize) unitSliceView (2#usize)
.safe .safe .safe (unit_slice_transfer _ _) (unit_slice_transfer _ _) rfl

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.

medium

With the implicit parameter changes suggested for transfer_trans, this call can be simplified significantly, removing all the redundant explicit arguments.

example : transferAt unitSliceView (0#usize) unitSliceView (2#usize) .safe .safe :=
  transfer_trans (unit_slice_transfer _ _) (unit_slice_transfer _ _) rfl

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.62%. Comparing base (f3ccf5d) to head (476ba6a).

Additional details and impacted files
@@                        Coverage Diff                         @@
##           G5mwz4ieerzmvrwzsvsuahndzgsjmd53s    #3895   +/-   ##
==================================================================
  Coverage                              48.62%   48.62%           
==================================================================
  Files                                     35       35           
  Lines                                   4759     4759           
==================================================================
  Hits                                    2314     2314           
  Misses                                  2445     2445           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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