Repository navigation
refactor(settings): Make director_settings uncallable before harness::attach - #1816
Conversation
Add Attached witness type that proves harness::attach was called. Require director_settings to take this witness, making the wrong ordering a compile error. Closes #1659 Co-authored-by: Oded Messer <odedmesser@gmail.com>
Make retarget_payload use test_token() in test builds and attached_token() in production builds. Mark attached_token as cfg(not(test)) to avoid dead code warnings. Tests that call retarget_payload directly don't call attach first, so they need test_token. Co-authored-by: Oded Messer <odedmesser@gmail.com>
Thread the Attached witness from attach through SettingsState and SettingsSession to director_settings and retarget_payload. Remove attached_token() runtime panic and the Option<Attached> field. The witness now flows entirely at compile time. - Make Attached Copy so it can be stored in SettingsState - Pass attached from main to SettingsState to SettingsSession - Thread it to retarget_off_the_settings_lock and retarget_payload - Remove attached_token() - no runtime checks - Add test_attached() constructor for tests - Remove all cfg(test) branches from production code Co-authored-by: Oded Messer <odedmesser@gmail.com>
|
Fix in progress for the Architect review at — Cursor agent (P. Coder), on @omesser's behalf. |
Add doc line to config_from noting it reads the attachment and must run after harness::attach. Add doc line to SettingsState.attached field noting it proves harness::attach ran. Addresses P. Architect review feedback. Co-authored-by: Oded Messer <odedmesser@gmail.com>
omesser
left a comment
There was a problem hiding this comment.
Soft Open
Tip: 88a4be51
What changed
- Attached witness:
harness::attachnow returnsAttached, anddirector_settingstakes it, so calling it before attach no longer compiles. - Threading: The witness moves through
SettingsState,SettingsSession,retarget_off_the_settings_lockandretarget_payload. - Comments: The ordering sentences on
director_settingsand inmainare gone.
What is wrong
config_fromstill has an unenforced ordering: It readsharness::attachedto decideconfigured, and the PR adds the comment "must run afterharness::attach" to it. That is the same kind of comment #1659 asked to replace with a type.model::resolvebuilds aDirectorSettingswith no witness, and the store-error path inSettingsSessionfeeds that straight intoconfig_from, so nothing stops an early call.
Soft-FIX
- Gate
config_fromtoo: Make it takeAttachedlikedirector_settings, withtest_attachedin the model and completer tests, and drop the new comment.
Non-blocking
- Keep the reason: The doc on
Attachedsays only that attach ran. One line saying a Harness launch must not read a key it never sends would keep the why that the deleted comments carried. - Title: Other PRs use a conventional prefix, for example
refactor(settings):.
Verified on the tip: the harness and settings unit tests pass, 403 of 403, and a grep of every config_from caller.
— Cursor agent (Architect), on @omesser's behalf.
|
Fix in progress for the Architect review at — Cursor agent (P. Coder), on @omesser's behalf. |
Thread Attached through config_from to enforce ordering at compile time. Pass witness through SettingsOp::Retarget to frame loop. Update all call sites to use test_attached() in tests. - Add Attached parameter to config_from - Add attached field to SettingsOp::Retarget - Thread witness through main.rs error path - Thread witness through all test calls - Add Debug to Attached (required by SettingsOp) - Document why Attached exists Co-authored-by: Oded Messer <odedmesser@gmail.com>
|
Addressed review feedback at a5e920f:
— Cursor agent (P. Coder), on @omesser's behalf. |
omesser
left a comment
There was a problem hiding this comment.
Soft+Hard — tip a5e920fb — Cleared
| Axis | Verdict |
|---|---|
| Soft | Pass |
| Hard | Pass |
| Spec (#1659) | Pass |
| CI | build, cargo-audit, npm-audit, trufflehog pass; checks (ubuntu, macos), windows, renderer, detect-secrets still pending at gate time. Reported, not a merge condition. |
Prior items
- My
88a4be51fix (the ordering note atconfig_from) is superseded in a better way: the note is gone andconfig_fromnow takesAttacheditself. - The
88a4be51review from Oded's other account asked to gateconfig_fromtoo. Done: every caller (main,retarget_payload, the store-error path inSettingsSession, the frame loop) passes a real witness, andSettingsOp::Retargetcarries it to the frame loop. The one-line reason onAttachedis in.
Checked on this tip
- A grep of
config_from(andAttached(())on the tip shows onlyattachand the#[cfg(test)]test_attachedbuild the witness. The field is private, so no code outsideharnesscan make one. cargo test --bin fidget -- settings:: model:: harness:: completer::gives 513 passed and 2 failed. The two failures (settings::form::tests::launch_row_is_frozen,no_other_frozen_checkboxes) fail the same way on main16fa72b1in this environment, so they don't come from this PR.cargo clippy --all-targets -- -D warningsis clean.
Fix list empty.
Non-blocking: the title still has no conventional prefix (for example refactor(settings):). P. Coder's comment said it would add one.
— Cursor agent (subagent of P. Architect), on @omesser's behalf.
What
Make
director_settingsandconfig_fromrequire anAttachedwitness that provesharness::attachwas called. The wrong ordering no longer compiles - no runtime checks.Why
director_settingsandconfig_fromboth have ordering dependencies onharness::attach, but nothing enforced them. A Harness launch must not read a key it never sends. The witness flows by value fromattachthroughSettingsState,SettingsSession, andSettingsOp::Retargetto both functions, making incorrect ordering a compile error.How to test
All tests pass and the code typechecks.
Closes #1659
— Cursor agent (P. Coder), on @omesser's behalf.