Skip to content

Conversation

nornagon-openai
Copy link
Collaborator

No description provided.

nornagon-openai and others added 2 commits September 10, 2025 11:09
…st migration test

- set_project_trusted now converts a top-level inline `projects = { ... }` map into explicit `[projects."<path>"]` tables, preserving existing entries and setting `trust_level = "trusted"`.

- Add unit test to cover migrating three existing trusted paths and approving a new directory "/Users/mbolin/code/codex2".

Co-Authored-By: Codex <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
- Convert inline project entries to explicit tables by cloning the inner inline table into a table, preserving all keys.\n- Create the projects table as implicit when creating it, and insert after migration when needed.\n- Update tests to assert preservation of extra fields.\n\nCo-Authored-By: Codex <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Copy link
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

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

Thanks for the updated tests!

fn test_set_project_trusted_migrates_top_level_inline_projects_preserving_entries()
-> anyhow::Result<()> {
let initial = r#"foo = "bar"
projects = { "/Users/mbolin/code/codex4" = { trust_level = "trusted", foo = "bar" } , "/Users/mbolin/code/codex3" = { trust_level = "trusted" } }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to avoid ambiguity in the test output, I wouldn't do foo = "bar" in both places because it makes it more confusing to conclusively determine what moved.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would also include some TOML comments on various things to see where they end up (or if they get lost).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bolinfest those seem like tests that would be better off in the toml_edit crate, i don't feel we should be testing dependencies here.

i'll update foo/bar so it's distinct.

Err(e) => return Err(e.into()),
};

set_project_trusted_inner(&mut doc, project_path)?;

// ensure codex_home exists
std::fs::create_dir_all(codex_home)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I noted a similar thing on #2799, but I would just limit this to the NotFound arm above because that's the only case where it should be necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

eh, i sort of feel like it's conceptually cleaner to ensure the dir exists before writing. in this case i think it's moot because with a blank initial config i don't think set_project_trusted_inner will ever return Err, but it's sort of weird if we create the dir before knowing whether set_project_trusted_inner will succeed—we could end up creating the directory but not creating the file inside it.

i'll leave this as-is for now as i feel it reads better and guards against a possible "read->create dir->error" case in future.

@nornagon-openai nornagon-openai enabled auto-merge (squash) September 10, 2025 22:52
@nornagon-openai nornagon-openai merged commit 95a9938 into main Sep 10, 2025
19 checks passed
@nornagon-openai nornagon-openai deleted the nornagon/trust-accept branch September 10, 2025 23:01
@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants