Skip to content

Add fe build --from-metadata to rebuild from a metadata.json input#1513

Open
cburgdorf wants to merge 3 commits into
argotorg:masterfrom
cburgdorf:from_metadata
Open

Add fe build --from-metadata to rebuild from a metadata.json input#1513
cburgdorf wants to merge 3 commits into
argotorg:masterfrom
cburgdorf:from_metadata

Conversation

@cburgdorf

Copy link
Copy Markdown
Collaborator

fe build --emit metadata produces a complete, deterministic recompilation input, but the reverse step existed only as a test helper. External toolchains (foundry-compilers, Sourcify-style verifiers) need it as a CLI feature: one invocation, JSON in, artifacts out.

fe build --from-metadata <PATH|-> (- reads stdin) materializes the recorded project (regenerated fe.toml per settings.ingots[] entry, sources routed by namespace) into a temporary directory and runs the normal ingot build on it:

  • default target is the settings.compilationTarget contract; --contract overrides
  • optimizer level comes from settings.optimizer.level; an explicit -O wins with a stderr warning that the bytecode deviates
  • compiler.version mismatch warns on stderr without aborting
  • artifacts follow --emit into --out-dir, defaulting to ./out
  • invalid input (bad JSON, language != "Fe", missing sources/ingots) exits 1; combining with [path], --ingot, --standalone, or --report is a clap conflict (exit 2)

The reconstruction lives in crates/fe/src/metadata_input.rs and validates untrusted input (no path traversal out of the temp dir). The round-trip tests now exercise the CLI feature directly; the test helper is removed. New tests cover stdin, target selection, the -O and version warnings, and the error cases.

@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cf21e4478

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/fe/src/metadata_input.rs Outdated
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2851b32faf

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/fe/src/metadata_input.rs Outdated
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@cburgdorf cburgdorf marked this pull request as ready for review July 8, 2026 18:08

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ccec5d164

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/fe/src/build.rs
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0bdcb5c070

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/fe/src/build.rs Outdated
`fe build --emit metadata` produces a complete, deterministic
recompilation input, but the reverse step existed only as a test helper.
External toolchains (foundry-compilers, Sourcify-style verifiers) need
it as a CLI feature: one invocation, JSON in, artifacts out.

`fe build --from-metadata <PATH|->` (`-` reads stdin) materializes the
recorded project (regenerated fe.toml per settings.ingots[] entry,
sources routed by namespace) into a temporary directory and runs the
normal ingot build on it:

- default target is the settings.compilationTarget contract;
  --contract overrides
- optimizer level comes from settings.optimizer.level; an explicit -O
  wins with a stderr warning that the bytecode deviates
- compiler.version mismatch warns on stderr without aborting
- artifacts follow --emit into --out-dir, defaulting to ./out
- invalid input (bad JSON, language != "Fe", missing sources/ingots)
  exits 1; combining with [path], --ingot, --standalone, or --report
  is a clap conflict (exit 2)

The reconstruction lives in crates/fe/src/metadata_input.rs and
validates untrusted input (no path traversal out of the temp dir). The
round-trip tests now exercise the CLI feature directly; the test
helper is removed. New tests cover stdin, target selection, the -O
and version warnings, and the error cases.
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 255c835735

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/fe/src/metadata_input.rs
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 0a2ca37387

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cburgdorf cburgdorf requested a review from sbillig July 9, 2026 19:38
@cburgdorf

Copy link
Copy Markdown
Collaborator Author

This should have shipped with Fe 26.2 already but wasn't ready in time. This will be needed for deeper Sourcify integration as well as for foundry.

@argotorg argotorg deleted a comment from Lifestag Jul 10, 2026
@sbillig

sbillig commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

5.6 feedback:

crates/fe/src/build.rs:1082 silently treats an unresolved
settings.compilationTarget path as though no path was requested, then falls back to ingot-wide
contract-name resolution.

Confirmed repro: metadata specifies src/missing.fe: Foo, while Foo exists only in src/
actual.fe; rebuilding succeeds and emits Foo.runtime.bin from the wrong source.

Required fix:

  • Validate that compilationTarget contains exactly one string path/name pair.

  • When using the recorded target, error unless the path exists and that module defines the
    named contract.

  • Never fall back when a recorded path was supplied.

  • Add failure tests for both a missing path and a path whose module lacks the recorded
    contract.

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