Skip to content

fix: fail on missing HOME, bound GitHub API waits, reject unknown hook keys - #218

Merged
furedea merged 2 commits into
mainfrom
fix/missing-home-http-timeouts-silent-config-loss
Nov 11, 2026
Merged

furedea merged 2 commits into
mainfrom
fix/missing-home-http-timeouts-silent-config-loss

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Closes #215

概要

小さな不具合5件をまとめて修正する.計画: #215 (comment)

# 修正
1 HOME 未設定時は . へフォールバックせずエラーにする(install / verify / sync-*-config).--prefix 指定時は従来どおり
2 GitHub REST の ureq agent に接続10秒・応答30秒・本文30秒のタイムアウトを設定
3 hooks.json の PROVIDERS 以外のキーを検証エラーにする
4 status ファイルが壊れていても record_failure が失敗せず,元の取得エラーを返す.status 書き込み自体が失敗した場合も元のエラーに context として付与する
5 TOML マージを as_table_like_mut にし,インラインテーブルをキー単位でマージする

検証

  • 回帰テスト: tests/missing_home.rs(2件),agent_bounds_connect_response_and_body_waits,read_hooks_rejects_an_unknown_provider_key,refresh_reports_the_fetch_error_when_the_recorded_status_is_corrupt,merge_item_keeps_existing_entries_of_an_inline_table
  • 項目 1,3,4,5 は修正前に失敗することを確認済み.項目 2 はテストより先に修正を書いたため,修正前の失敗は未確認
  • cargo test: 全件成功
  • cargo clippy(lefthook pre-commit)と cargo fmt --check: 成功
  • cargo clippy --all-targets には既存テストコード由来の警告が残る(本PRの変更箇所は含まない)

🤖 Generated with Claude Code

…k keys

- fail install, verify and config sync when HOME is unset instead of using "."
- set connect, response and body timeouts on the GitHub REST agent
- reject unknown provider keys in hooks.json
- keep the original fetch error when the status file is corrupt or unwritable
- merge Codex TOML inline tables key by key instead of overwriting them

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T13:34:50.488379Z adb88c9 Manual request
ℹ️ 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.

match (target.as_table_mut(), source.as_table()) {
match (target.as_table_like_mut(), source.as_table_like()) {
(Some(target), Some(source)) => merge_tables(target, source),
_ => *target = source.clone(),

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.

P2 — When the target is an inline table and the source has a standard sub-table under a key the target doesn't have yet, merge_tables calls entry(key).or_insert(Item::None) on the InlineTable. Then this fallback writes source.clone(), an Item::Table, into it. An inline table can only hold values. As far as I know, toml_edit's inline-table encoder only writes Item::Value entries and skips Item::Table, so the merged entries disappear from the output without any error.

Example: base config.toml has permissions = {} (or permissions = { other = 1 }). The protection fragment is [permissions.guarded.filesystem] (two implicit parent tables, then real keys). guarded gets inserted as an Item::Table inside the inline permissions, and the generated config loses every guarded read denial and glob_scan_max_depth. That silently drops a safety control. Before this change, as_table_mut didn't match an inline target, so the source table replaced it and the protections were kept. External [features.<sub>] tables merged into an inline features hit the same problem.

I couldn't run this in the review sandbox, so please confirm with a test such as permissions = {} merged with [permissions.guarded.filesystem]\n"/a" = "read". Possible fix: when the target is an InlineTable and the source item is an Item::Table, insert Item::Value(Value::InlineTable(table.clone().into_inline_table())). Alternatively, turn the target inline table into a standard table before merging.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

Blocking findings (P0/P1): 0

  • P2 src/generation/codex_config.rs: the TOML merge now uses as_table_like_mut. When the target is an inline table that lacks a sub-key, a standard Item::Table from the source gets written inside it. I expect toml_edit to leave that out of the output, so protection entries like [permissions.guarded.filesystem] can vanish if the base config has permissions = {}. Before this change, the source table replaced the inline table and the protections were kept. I couldn't reproduce this in the sandbox, so please confirm it with a test.

Other items I checked and found no problems with:

  • HOME handling: --prefix still skips the HOME lookup, and sync-*-config fails with a clear error.
  • ureq 3 timeouts are configured correctly.
  • Unknown hook keys: version, claude and codex are named fields, so only the flattened provider keys are checked. Every key in the repo's hooks.json files is in PROVIDERS.
  • record_failure: errors are now handled and the original fetch error is kept. One side effect is that any status read error, including I/O errors and not just bad JSON, now overwrites the status file. That seems acceptable.

🤖 Generated with Claude Code

@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: 3d4b92325a

ℹ️ 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 on lines +118 to 120
match (target.as_table_like_mut(), source.as_table_like()) {
(Some(target), Some(source)) => merge_tables(target, source),
_ => *target = source.clone(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Convert nested tables before merging into inline tables

When the target contains an inline parent such as permissions = { ... } and the generated protection fragment contributes a previously absent nested table such as [permissions.guarded.filesystem], this branch clones an Item::Table directly into an InlineTable. toml_edit inline tables require value-form entries, so the resulting document cannot be serialized correctly and installation can fail or omit the generated filesystem protections. Convert nested tables to inline-table values or promote the target inline table before recursively merging.

Useful? React with 👍 / 👎.

Comment thread src/cli.rs Outdated
Comment on lines +432 to +435
fn home_dir() -> Result<PathBuf> {
std::env::var_os("HOME")
.map(PathBuf::from)
.context("HOME is not set; pass --prefix or set HOME")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Do not suggest --prefix for sync commands

When HOME is unset during sync-config or any hidden sync-*-config alias, this shared helper tells the user to pass --prefix, but those commands only accept --source and --target; following the suggested remediation therefore produces a clap unknown-argument error. Use a context-specific message for sync commands or actually expose a supported override.

Useful? React with 👍 / 👎.

@furedea-agent

furedea-agent Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

レビュー対応(adb88c9):

  • インラインテーブルへの標準テーブル混入(P1/P2): permissions = {} と permissions = { other = 1 } に [permissions.guarded.filesystem] をマージするテストを追加したところ,現行コードでも保護エントリは出力に残り,再パース後も読めた.toml_edit の TableLike::entry は InlineTable への Item::Table 挿入を値に変換するため,再現しなかった.挙動は回帰テストとして固定し,実装は変更していない
  • --prefix の案内(P2): sync-*-config には出さないよう,ヒントを --prefix を受け付ける install / verify 側だけに移した

🤖 Generated with Claude Code

@furedea

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread src/cli.rs
target: &args.target,
};
crate::config_sync::sync(provider.spec(), &paths, &default_home_dir())
crate::config_sync::sync(provider.spec(), &paths, &home_dir()?)

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.

P3: home_dir()? runs before dispatch, so sync-codex-config, sync-devin-config, sync-hermes-config and sync-dsh-config now fail when HOME is unset. Only ConfigSync::MergeClaudeSettings reads home (src/config_sync.rs:22), and those four providers ran fine without HOME before this change. Since nix/providers.json wires these commands into activation, any environment that runs them without HOME will now break for no reason. One option: resolve HOME lazily, only for the Claude settings merge.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

No blocking findings (no P0 or P1).

I reviewed all five fixes: the missing-HOME error, the ureq timeouts, rejecting unknown provider keys in hooks.json, record_failure handling a corrupt status file, and the inline-table TOML merge. Each one has a regression test.

  • P3 (src/cli.rs:332): sync-{codex,devin,hermes,dsh}-config now require HOME, but only the Claude settings merge actually reads it.

What I checked:

  • The repo's hooks.json files contain only version and known provider keys, so the new unknown-key check rejects none of them.
  • Re-rendering a non-inline Table inserted into an inline table is covered by merge_item_keeps_nested_source_tables_under_an_inline_table.

I could not run cargo test here: the sandbox needed approval for the command. This review is from reading the code only.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: adb88c9abf

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

@furedea
furedea merged commit c0b936d into main Nov 11, 2026
21 checks passed
@furedea
furedea deleted the fix/missing-home-http-timeouts-silent-config-loss branch November 11, 2026 15:15
furedea pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.9.13](agent-harness-v0.9.12...agent-harness-v0.9.13)
(2026-11-12)


### Features

* **codex:** apply the secret path policy to the guarded filesystem
([#233](#233))
([0830fd9](0830fd9))
* **pi:** run Pi shell and file tools inside srt
([#228](#228))
([37de3ac](37de3ac))


### Bug Fixes

* dedupe the Nix socket in Pi's srt policy and name the failed sidecar
write ([#237](#237))
([1ccafe0](1ccafe0))
* fail on missing HOME, bound GitHub API waits, reject unknown hook keys
([#218](#218))
([c0b936d](c0b936d))
* **install:** publish atomically and keep Claude settings keys the
harness does not own
([#219](#219))
([c914c76](c914c76))
* **pi:** confirm ask decisions and deliver skills, instructions, and
settings ([#223](#223))
([2e755af](2e755af))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
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.

fix: HOME fallback, HTTP timeouts, unknown hook keys, masked refresh errors, inline TOML merge

1 participant