Repository navigation
Make proposed Ask options version responses - #61
Conversation
max-sixty
left a comment
There was a problem hiding this comment.
The resolve door proves only that a newer version number was published, not that the version answered this response. Publishing an unrelated v2 makes latest_published(...) > root["version"], so leaf resolve succeeds even if #choice is unchanged, has no added option, and still has no pick. The request then remains open in the page projection while its version-response thread says resolved—the two readings disagree.
Please gate resolution on the current target actually satisfying the declared request (for lf-options, the version records the resulting pick/option), using the same declaration-driven standing-request projection rather than merely the version number. A negative test with an unrelated v2 should remain refused; the existing chosen-option v2 is the positive control.
leaf-agent
left a comment
There was a problem hiding this comment.
The contract itself reads cleanly — response is a declaration rather than a tag branch, both markup doors validate it, and vocabulary_gaps picks it up on re-vendoring. One thing I'd want your call on before this lands, plus two smaller notes inline.
While the agent's clarification thread is waiting on the reader, the seat's ask is on neither standing surface. seats_with_agent (and seatsWithAgent in asks/model.js) is a union over the seat's threads, so the proposal — still awaiting the agent, and now permanently so, since only a version answers it — keeps the seat subtracted from the reader's list even when the newest thread there is a question to them. Confirmed against the merged tree:
c1 (user, response: version) awaits_agent = True
c2 (claude, same seat) awaits_agent = False
seats_with_agent = {'jobs'}
unanswered_asks deliberately drops the proposal from the Stop gate in exactly that state, so during that window the banner, the Asks tray and the n/p walk say nothing, and the agent's gate says nothing. The reader can still answer — the clarification renders its own reply box in the cell — but nothing routes them there except the Comments panel's Waiting on you (n) button, which is a click inside a panel rather than a page-level surface. Root CLAUDE.md still carries the invariant this crosses, in the paragraph just below the one the PR rewrites: "what leaves the reader's banner lands on the agent's own gate rather than nowhere".
If that's intended, it's worth saying so where the invariant is stated, since the sentence currently reads as ruling it out. If it isn't, the seat reading is the place: subtract a seat only when no thread standing in it awaits the reader, rather than when any thread awaits the agent. That keeps one spelling on both sides — seats_with_agent and seatsWithAgent would change together.
I'm raising it rather than deciding it: it's a judgment about whose list the question belongs on while both threads are open, and the test at test_render_options.py:1959 locks the current answer in, so it wants to be the answer you meant.
Second note inline on a doc sentence the rewrite left behind in two places. Nothing on the resolve door from me — max-sixty's review already has it.
# Conflicts: # plugins/leaf/skills/leaf/references/internals/events.md # plugins/leaf/skills/leaf/scripts/leaf/conversation.py # plugins/leaf/skills/leaf/scripts/leaf/hooks.py # plugins/leaf/skills/leaf/scripts/leaf/http.py # plugins/leaf/skills/leaf/scripts/leaf/validation.py
leaf-agent
left a comment
There was a problem hiding this comment.
The gate is the right shape — one reading (page_awaiting_values) shared with the action door rather than a second projection, and the registry check that a response: version seat declares an x-awaits is what stops the gate from silently reading False on a widget it has nothing to ask about. One case it doesn't cover, with a repro, inline; plus a doc enumeration the new reading joins.
My two earlier threads are unchanged by this commit, so nothing restated here.
leaf-agent
left a comment
There was a problem hiding this comment.
This answers all four of my open threads — the resolve gate now demands an authored change to the named verb's record rather than just an answered Ask, with test_an_already_answered_ask_still_requires_its_version_response pinning the case I reproduced, and the three doc copies still saying "by reply or by resolve" are updated. I've resolved those threads; nothing restated here.
One new case inline, plus a wrap slip. The gate's two halves now disagree about what answering means: the first reads the declared request, where settled answers it, and the second reads the answer record, which settled never writes. A version taking that route leaves the proposal unresolvable and unreplyable for the life of the page.
…ponse # Conflicts: # plugins/leaf/skills/leaf/scripts/leaf/hooks.py # plugins/leaf/skills/leaf/scripts/leaf/projection.py # plugins/leaf/skills/leaf/scripts/leaf/validation.py
leaf-agent
left a comment
There was a problem hiding this comment.
settled and a cleared pick both resolve now, and asking the originating version its own request is the right place to have put it — both halves of the gate ask one question instead of one reading the declaration and the other the record. My two open threads are addressed and I've resolved them; nothing restated here.
One new case, with a repro, plus a wrap slip inline.
A reader action taken after the proposal supplies the transition the version is supposed to make. Both ends of the new comparison read the log-folded projection: page_awaiting_values reaches answered_verb, which prefers folded_facet(*held) over markup_facet whenever a standing choose action holds the coordinate. So an ordinary pick in the browser closes the Ask on the current side while original_awaiting stays True on the originating side, and the return False under that branch hands resolve to any later version.
Move the same pick to before the comment and it is refused, because then it is original_awaiting that reads answered and the record comparison runs. Identical markup, identical unrelated v2, opposite answers according to which side of the reader's own comment their press fell on:
PICK AFTER -> exit 0 {"kind": "resolve", ...}
PICK BEFORE -> exit 1 requires a page version that answers its originating Ask, ...
Repro — one file, both orders, against the merged tree
from click.testing import CliRunner
from interact_support import PAGE, publish
from leaf import cli as cli_model
from leaf import events as events_model
PICK = {
"kind": "action",
"author": "user",
"version": 1,
"widget": "choice",
"action": "choose",
"detail": {"options": ["flag-first"]},
}
PROPOSAL = {
"kind": "comment",
"author": "user",
"version": 1,
"text": "None of these - do the camera first.",
"anchor": {"section": "choice"},
"response": {"kind": "version", "verb": "choose"},
}
def _run(page_dir, pick_first):
asking = PAGE.replace("<lf-options>", '<lf-options id="choice" choose>')
(page_dir / "versions" / "v1.html").write_text(asking)
publish(page_dir)
if pick_first:
events_model.append_event(page_dir, dict(PICK))
proposal = events_model.append_event(page_dir, dict(PROPOSAL))
else:
proposal = events_model.append_event(page_dir, dict(PROPOSAL))
events_model.append_event(page_dir, dict(PICK))
(page_dir / "versions" / "v2.html").write_text(
asking.replace("</main>", "<p>Unrelated update.</p>\n</main>")
)
publish(page_dir, version=2)
return CliRunner().invoke(
cli_model.cli, ["resolve", str(page_dir), "--to", proposal["id"]]
)
def test_pick_after_the_proposal(page_dir):
r = _run(page_dir, pick_first=False)
print("PICK AFTER ->", r.exit_code, r.output.strip()[:120])
def test_pick_before_the_proposal(page_dir):
r = _run(page_dir, pick_first=True)
print("PICK BEFORE ->", r.exit_code, r.output.strip()[:120])Root CLAUDE.md states the contract as "A version that answers an originating open Ask, or changes the declared answer when the Ask was already answered, ends the request", and on this path no version answered anything — the reader did, and v2 only had to exist. It is also the mirror of my earlier thread about answering the Ask before writing the proposal, which test_an_already_answered_ask_still_requires_its_version_response now pins: the pair disagrees about whether a logged pick counts, on nothing but its position in the log.
If the gate's subject is an authored answer, reading both ends off authored markup closes it uniformly — settled and a cleared pick are markup either way, so the two new tests keep their meaning while a logged pick stops moving either end. Passing an empty event list to both page_projection calls is enough to show that: tests/test_interact_product.py and tests/test_interact_contract.py are green under it (227 passed) and the repro above refuses on both orders. It's a sketch rather than a patch — it leaves original_events unused — and it is a judgment about whether a reader who picks after proposing has thereby released the proposal, so I'm raising it rather than pushing one.
leaf-agent
left a comment
There was a problem hiding this comment.
Reading both versions off markup alone closes the pick-order asymmetry from my last thread — I re-ran the repro against this commit and both orders refuse now, and test_a_reader_pick_cannot_substitute_for_an_authored_version_response pins them. The thread that was still open on the wrap slip is fixed too; I've resolved it. Nothing restated here.
Two notes inline, neither a bug. The substantive one is that the edit takes the log out of both readings, so it could as easily have made a standing pick block a legitimate authored response — and no test would have caught that, because every version-response test that expects exit_code == 0 runs on a log with no actions in it at all. The direction does work today: with the reader's choose standing, a v3 that carries their words in as a chosen option resolves the proposal (exit 0). It's a coverage gap rather than a defect, and the parametrized test is one publish away from pinning it.
…ponse # Conflicts: # plugins/leaf/skills/leaf/scripts/leaf/http.py # plugins/leaf/skills/leaf/scripts/leaf/validation.py # tests/test_render_pages.py
When a reader writes "Another option" in a choosing Ask, Leaf now records a version-response thread. The page seat has no inline reply and
leaf replyrejects the thread; clarification moves to a separate exact-section thread. A later published version can add and choose the option before the agent resolves the proposal.The response contract names both the version response and its declared answer verb. It is validated at POST and re-vendoring boundaries and carried in the log for the Stop hook. Agent resolution compares declaration-driven authored state at the proposal and current versions: a standing Ask must become answered, while an Ask that was already answered must change the answer's authored record. Reader actions do not substitute for the revision, and an unrelated update cannot close the thread. Tests cover the browser UI, indirect replies, clarification ownership, forged events, re-vendoring, and publication order.