Repository navigation
Conversation
…xt line Three edges of self-serve `openadapt wrap` from the Nov 30 staging run: - Canary values collided across wraps: the second canary found the first canary's record too and halted on "2 records match the target selector but exactly 1 was expected". Each attempt now adds a short random suffix (`oa` + six hex digits) to one text input of its canary: the longest public input that every new-record claim binds plainly (never a sign-in input, a select's code, a typed value, an email or a URL). The record check still wants exactly one. Run 1's values are still compared with the values as given. `"unique_canaries": false` keeps them as written. - A retry that only admitted the kept draft ended `status: admitted, verified: false` and exited 1. Admission is reached only after a VERIFIED canary, so it now exits 0, with a stderr line that nothing was saved with the caller's inputs. WRAP_PUBLISH.md documents the exit statuses. - A run printed one plaintext-at-rest WARNING per JIT-draft artifact. `at_rest.one_warning_line()` prints one line per run (naming the first write and the ledger); every write still gets its ledger line, strict mode still refuses, and a write the ledger can't record is still refused.
The kept draft exists because the earlier attempt's run 1 already saved, so the stderr line now says that and asks the person to check the app instead of pointing at wrap run. The exit-status table is written around what decides the code (verified, or admitted): a read-back run 1 exits 0 while the program is still a draft or its canary failed. The canary's stamp key is written only when a suffix was applied, and the new e2e tests are skipped under the default at-rest lane until #2842 lands.
Review of #2864: a default suffix on every canary could break a first wrap whose longest plain-bound input only takes certain text (options stored as labels, a date in words). The suffix now goes on only when the system of record already has a record the canary's claim would match (an earlier wrap's or attempt's canary); anything that can't be judged counts as a possible match. A first wrap saves the values as written. Also: the admit-only stderr line no longer claims a test save in this call (the already-admitted path has none), the terminal canary line names the input and suffix, the docs say exactly which inputs are skipped, and admit() has unit tests with a stubbed canary (secret inputs unchanged).
Independent adversarial review: APPROVEFrom: Grok I found no blocker in the stated fix. A second wrap of the same task suffixes one public free-text canary input only when a record already matches what that canary would save. A first wrap with no matching record is saved as written. Behavior
Limitation, not a blocker for this headIf a collision is detected but no input is stampable, the canary is left as written and can still halt on "2 records match". That is fail-closed, and it is the same class of halt this PR cannot suffix away. Teach-over-MCP admission still uses fixed canary values, as the description already notes. I did not run the two MockMed/Chromium e2e tests. Tests at this head (Linux, Python 3.12)
Generality gate: point 1 passes; CI at this head: flow core unit shard 3/4 and default-at-rest shard 3/4 are red on Please merge I didn't push to this branch, and I won't merge it. |
Problem
The Nov 30 staging run of self-serve
openadapt wrap --personadmitted a notes program, but it showed three rough edges:canary_paramsare fixed. When you wrap the same task again on the same app, the second canary finds the first canary's record too and halts: "2 records match the target selector but exactly 1 was expected".status: admitted, verified: false, andwrapreturned0 if verified else 1.Change
Canary suffix (
compile_agent/pipeline.py,integrations/agents/{recording,skills}.py)wrapreads the system of record. If a record already matches what the canary's claim would match (an earlier wrap's or attempt's canary), it adds a suffix to one input of that canary: a space,oaand six random hex digits, for examplecanary note 1 oa3f9c2e. Anything it can't judge (no read, a routed claim, a typed or coded input) counts as a possible match. With no match, the values are saved as written, so a first wrap behaves as before.param, optionallystored). It never goes on:map,kindornullin its binding (a select's code, a typed value);wraptask files turn this on by default."unique_canaries": falsesaves the values as written.FirstRunCompiler.admit,compile_first_runandSkillCachedefault to off, so library callers behave as before.Exit status (
wrap/cli.py)status: admittedexits 0. Admission is reached only after a VERIFIED canary.verifiedis false, stderr says this attempt saved nothing with the caller's inputs and an earlier run may have saved them, so check the app before saving the same values again.verifiedis not changed.docs/WRAP_PUBLISH.mdgains an exit-status table, written around what decides the code:verified: trueoradmitted.One plaintext line per run (
at_rest.py,wrap/cli.py)at_rest.one_warning_line(). In the block, the first plaintext write prints one line that names it and the ledger path. Later writes get their ledger line only.wraprunstask.callinside the block.--serveis not included.refuse=FalseERROR line are unchanged.Docs and map:
WRAP_PUBLISH.mdsteps 3 and 4 (new paragraphs only, outside #2837's step-4 hunk) and a new capabilities row,0158.Tests
tests/test_wrap_rough_edges.py, 24 unit tests:admit()with a stubbed canary: the suffix lands on the public input, a sign-in input is unchanged, no suffix without an earlier match or with the option off.tests/e2e/test_wrap_canary_unique_e2e.py, on the real MockMed app with headless Chromium, an outside MCP command and admitter-key admission, never reset between wraps:"unique_canaries": false, the second canary halts on "2 records match the target selector but exactly 1 was expected". This is the staging failure.admitted,verified: false, exit 0, the stderr line, and at most one plaintext line. Run 1's note is not saved twice.?idempotency=demodedupes every save on one fixed key, and both strict policies require that key. So the e2e uses?fault=okand the bundledpermissivepolicy to model an app that doesn't dedupe. The canary's record check is the same under every policy.test_compile_agent_e2e.py::test_compile_agent_then_replay_with_no_model_calls, hitbrowser_readiness_unavailableunder that load and passed when run alone. ruff and mypy pass on the changed modules, andcheck_engine_generality.pypasses.Not covered
tests/default_at_rest_skips.txtwith that reason. Remove those lines once fix(flow): confirming a draft's parameters recompiles it in plaintext #2842 lands.--personwith feat(flow): wrap --person admits in two questions (one consent, one admit) #2837 merged was not run. The branches merge cleanly. feat(flow): wrap --person admits in two questions (one consent, one admit) #2837's step-4 doc text ("runs a test save (the canary) with yourcanary_params") should mention the suffix in a follow-up.openadapt_flow.request_binding.test_wrap_command_e2e.py::test_an_outside_command_is_compiled_admitted_and_replayedfails the same way on main here.agent/teach.py,admit_and_emit) still uses fixed canary values, so teaching the same task twice can hit the same collision.verifiedon a first run is run 1's record check, sodraftand a first-attemptcanary_failedexit 0 when run 1 was read back. The docs describe this. Whethercanary_failedshould exit nonzero is a separate decision.at_restlevel, not through the CLI.Review
One review pass at high effort, on this branch. It found:
admit()had no direct unit test.