Repository navigation
fleet gh: Metadata create path — parse, stamp, insert (#9073) - #12988
Conversation
Native slice 9 of the #9073 amendment (design doc/2026-11-12T22-50-00Z_design_pm-board-hierarchy-genealogy §12-§15, extending #9016 step 2): fleet gh issue/pr create calls now - parse the caller's pm-metadata block (fail-closed on a malformed block, before any GitHub write), - stamp the full provenance set from fleet sources (queue record via the broker, session state, host, worktree, agent identity) and sign it with the #12586 stamp signature when a key is configured (FLEET_GH_STAMP_KEY_ID + the broker secret fleet-gh.stamp-signing-key-pkcs8, by name only), - insert the full record into the metadata store (#9074's pm_metadata schema over SQLite) after a successful create; a failed insert leaves the item intact and is reported for the §16 ingestion sweeper to heal. The block layer, canonical form, signature, and extraction rules port the hosted edition (pkgs/fleet/hosted-worker, #12585/#12586) and #9074's reader; the hosted golden vectors are reproduced byte-exact in the native test suite. New dependencies for the fleet crate: ed25519-dalek 3 (deterministic RFC 8032 signing as a library call — the conformance surface is byte-exactness with the hosted vectors) and rusqlite 0.42 bundled (#9074's schema over SQLite; same pin fleet-queue already carries). base64 0.23 was already an optional dep of the crate and joins the gh feature.
The gh module imports its siblings explicitly; the create-path hook's references did not resolve without the use line.
Owned String in the queue-record max_by key (the borrowed &str tuple outlived its closure), Debug derives for the parse types (the refusal tests unwrap_err them), and a needless mut.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 13 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 07c2f04413
ℹ️ 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".
| "--fill" | "--fill-first" | "--fill-verbose" => { | ||
| saw_fill = true; | ||
| out.push(token.clone()); |
There was a problem hiding this comment.
Recognize the short fill flag before injecting a body
For a noninteractive fleet gh pr create -f without an explicit body, -f falls through without setting saw_fill, so this path appends a metadata-only --body. The installed gh pr create --help documents -f, --fill as “Use commit info for title and body” and states that an explicit body takes precedence over autofilled content. Consequently, the previously generated commit description is silently replaced by metadata. Recognize -f alongside --fill so these calls retain the intended passthrough behavior.
Useful? React with 👍 / 👎.
| .filter(|v| !v.is_empty()) | ||
| .map(|h| PathBuf::from(h).join(".config")) | ||
| })?; | ||
| let text = std::fs::read_to_string(config_home.join("fleet").join("agent.json")).ok()?; |
There was a problem hiding this comment.
Honor the configured agent profile when stamping identity
When FLEET_AGENT_PROFILE selects a nondefault enrolled profile and FLEET_AGENT is unset, this lookup ignores the selected profile and reads the default agent.json instead. The existing profile resolver in fleet-agent/src/enroll.rs::profile_path explicitly honors FLEET_AGENT_PROFILE, so other Fleet commands use the selected identity while newly created issues and PRs receive a null or different provenance.auth_subject. Resolve the same configured profile here to avoid persisting incorrect attribution.
Useful? React with 👍 / 👎.
| kind: item.kind.clone(), | ||
| number: item.number, | ||
| url: item.url.clone(), | ||
| metadata: block.clone(), |
There was a problem hiding this comment.
Store the final metadata for editor-driven creates
For an editor-driven create with an initial body, such as fleet gh issue create --editor --body-file draft.md, the parser stamps the initial body but still passes --editor to gh. The installed gh issue create --help describes this flag as opening an editor to write the title and body. If the user changes caller-owned metadata such as direct_parent or links there, GitHub receives the edited block while this insert stores the original prepared block, silently making metadata queries disagree with the created item. Either leave editor-driven creates to ingestion or read back the final body before inserting its metadata.
Useful? React with 👍 / 👎.
For #9073 — amendment slice 9, the native fleet gh Metadata create path: parse, stamp, insert.
What lands
fleet gh issue create/pr createnow, inpkgs/fleet/crates/fleet/src/gh_metadata.rs(hooked intogh.rs'srun()before the token rotation):--bodyseparate/=/attached-b,--body-file, or no body with a non-terminal stdin). The caller's pm-metadata block is parsed with the hosted edition's fail-closed rules: a malformed block (dangling marker, unfenced payload, invalid JSON, non-object,pm_meta != 1) refuses the create with exit 2 before any GitHub write. Creates whose body fleet cannot own pass through byte-exact:--web,--fill*without a body,--templatewithout a body,--body-file -, and the interactive (terminal-stdin, no-body) flow.direct_parent,links,lineage) are preserved exactly, with required-field defaults injected when absent. Sources: the queue record read from the broker for the caller's session binding (queue id, scheduled start, pickup time, work-start from progress, lane, model, and every issue the same lane start holds), session state (§14's resolution), host, worktree + workspace ref from git, the caller's agent identity, and the service clock.v1.ed25519.<kid>.<sig>shape, Ed25519. The hosted edition's golden vectors are reproduced byte-exact in the native test suite (canonical bytes and signature, both the hosted-key and native-key fixtures), so the two editions sign and verify each other's stamps. Signing is provisioned by name: whenFLEET_GH_STAMP_KEY_IDis set, the key material is resolved from the secrets broker asfleet-gh.stamp-signing-key-pkcs8(the hosted config's base64url PKCS#8 encoding); a resolution failure stamps unsigned with a stderr note rather than breaking every lane create on a provisioning gap (no stamp key is provisioned anywhere yet, and "unsigned" is a first-class reported state in §15). Unset key id = unsigned, quiet.pm_metadataschema and extraction rules, ported verbatim over SQLite (rusqlite), so the native writer and the aggregator's reader agree field-for-field, extras included. A failed insert leaves the GitHub item intact, keeps gh's exit code, and prints a stderr note naming the miss for the §16 ingestion sweeper (the hosted impl(fleet-hosted): ingestion receiver — GitHub webhook route + scheduled-Worker sweeper (#9076 hosted) #12590 implementation) to heal — the same miss shape its sweeper test covers.Design calls (ambiguities resolved; recorded on #9073 as well)
gh:<repo>#<kind>:<number>— impl(fleet): metadata database + fleet Metadata query surface #9074 left the construction open (its test uses a placeholder); the id is deterministic from the item's identity, and repo/kind/number are also columns, so a future convention change reconciles on them.scheduled_startis stamped as a provenance key (§5 lists it; §12's example doesn't name the key — the hosted route made the same call).$FLEET_METADATA_DB, else~/.local/state/fleet/metadata.db(the fleet state dir). impl(fleet): metadata database + fleet Metadata query surface #9074's store is a bun:sqlite library in the aggregator, not yet wired into a runtime; the native store is the same schema over the same extraction rules, ready to be pointed at the production DB file when the wiring lands.New dependencies (for the
fleetcrate)fleet-queuealready carries in this workspace.ghfeature now also enables it.Evidence
cargo test -p fleet --features fullon amd-6 under~/tools/fleet-build-lock: 127 passed / 0 failed (118 main-binary unittests — 23 of them newgh_metadatatests — plus 9 integration tests; the pre-existing gh rotation/guard/closure suites pass unchanged).FLEET_METADATA_DBunder/proc) leaves the "created" item standing with exit 0 and the stderr heal note; a malformed caller block exits 2 with gh never invoked.Keys and secrets are referenced by name only throughout.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.