Skip to content

fix(proxy): apply a consent refusal before the command that stores it returns - #969

Merged
BolotnyaBoss merged 9 commits into
codemie-ai:mainfrom
aliaksp:fix/consent-refusal-before-tick
Dec 4, 2026
Merged

BolotnyaBoss merged 9 commits into
codemie-ai:mainfrom
aliaksp:fix/consent-refusal-before-tick

Conversation

@aliaksp

@aliaksp aliaksp commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes EPMCDME-18353. With a proxy daemon of the same version running, codemie proxy analytics consent revoke only stored the "no" and left stopping the held sessions to the daemon's next tick. The answers file keeps one answer per project, so a consent grant before that tick erased the "no": the refusal was never applied, and resend released the session that had been held at the revoke.

The command that stores a "no" now applies it itself, before it returns, whatever daemon runs.

Changes

  • consent revoke and a "no" at the consent question of proxy connect stop the held personal-subscription sessions of the project and delete their held data before the command returns. Each session gets its stop marker first, then its files are deleted under the session's forward lock — the lock the daemon's tick and resend already take. A session the daemon is busy with is stopped at once and its files are left for the daemon.
  • The command's output follows what the refusal did. A session or held batch that could not be stopped — its record cannot be read, the destination cannot be named — is reported, the success line is not printed and consent revoke exits non-zero, with the "no" still stored. Files that could not be deleted are reported as left. proxy connect prints no grant hint after a refusal that left a session not stopped.
  • One walk: the refusal runs through one function in consent-refusal.ts, with the selection it shares with the daemon's pass. The daemon's own refusal pass on the tick stays as the second line.
  • deleteSession answers whether every file is gone; the forward lock is taken through one helper.
  • docs/PROXY-AND-ANALYTICS.md and docs/COMMANDS.md say what a revoke does before it returns.

We decided to leave one case as a known limit: a session the daemon has not classified yet at the moment of the revoke is not stopped by it, and stays releasable after a grant until the daemon's second refusal pass (up to two tick periods, four minutes by default). Closing it needs the time of the refusal kept in the answers file, which this change does not touch.

A CLI released before this change, beside a daemon that has it, still only stores the answer.

#965 changes the same helper in connect-consent.ts: whichever lands second takes the other in — its daemon replacement goes before this walk.

Impact

revoke, then grant --yes and resend --yes before the daemon's tick Before After
The session held at the revoke released by resend and sent stopped with consent_revoked before revoke returns; resend releases nothing
Its held data sent deleted by the command, or left unsendable when the daemon holds the session
A session that could not be stopped revoke printed success revoke names it, prints no success line and exits non-zero

Checked by hand on this branch's build: the three commands of the ticket run one after another inside one daemon tick, with a real signed-in Claude Code session held for consent, in an isolated home against a stand-in backend.

Lint, type check, build and the unit and cli test projects pass.

Checklist

  • Self-reviewed
  • Manual testing performed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)

Aliaksei Piatrovich and others added 7 commits December 4, 2026 17:08
The proxy tick and the hold release both built the forward lock's path
themselves. acquireForwardLock names it once, in the current spool scope,
so a third caller locks the same file. No behaviour change.

Task 1 of epmcdme-18353-consent-refusal-before-tick.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
refuseProject stops and deletes the held governed sessions of one project
for the command that stores the "no". It is given the project instead of
reading the answers file, writes the stop outside every lock, deletes the
spool files only under the session's forward lock with one deadline for
the whole walk, and returns one outcome per session: deleted, files_left
or not_stopped. A listing that fails makes the result undefined.

The selection of the sessions is shared with the daemon's pass: the two
walks differ only in how they list and what they do with a session.
applyRefusals behaves as before.

Task 2 of epmcdme-18353-consent-refusal-before-tick.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…turns

With a live daemon of the CLI's own version, `consent revoke` and a "no"
at the consent question of `proxy connect` only recorded the answer and
left the held sessions to the daemon's next tick. A grant inside that tick
replaced the answer, the sessions got no stop, and `resend` published them.

refuseConsent now stores the "no" and runs refuseProject itself, whatever
daemon runs: no daemon lock is taken and the daemon's state is read only
for the older-daemon hint. The output follows the walk:

- a session stopped with its files left is named, with what removes them;
  the command still succeeds
- a session that could not be stopped, or a walk that did not run to its
  end, asks for a second revoke before any grant; `consent revoke` exits
  non-zero without its closing lines and the connect consent step fails

The "no" stays recorded in every case.

Task 3 of epmcdme-18353-consent-refusal-before-tick.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…urns

PROXY-AND-ANALYTICS.md and COMMANDS.md describe what `consent revoke`
does to the sessions the proxy already holds for consent: they are stopped
and their held data is deleted before the command returns; a session
begun since the proxy's last pass is not stopped by it; a busy session is
stopped and its data goes on the proxy's next pass or within 24 hours; a
session that could not be stopped makes the command exit non-zero and ask
for a second run before any grant.

Task 4 of epmcdme-18353-consent-refusal-before-tick.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
A held session or batch whose record cannot be read, and a file the delete
could not remove, are part of the walk's answer: the command names them, and
`consent revoke` fails instead of printing its success line. A walk that
cannot name the destination segment is a failed walk. `proxy connect` prints
no grant hint after a refusal that left a session not stopped, and the line
about data left for a busy session names no time bound. `deleteSession`
answers whether every file is gone.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
The technical analysis, the spec and the plan of the change, both complexity
assessments, the gate run, the review record and the gate decisions.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
…e run

The run's planning files leave the change; the review record and the gate decisions stay, as in the task folders of earlier changes.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
Aliaksei Piatrovich added 2 commits December 4, 2026 21:31
…fusal

The proxy daemon's replay shares no lock with the command and removes a batch
it has consumed. A batch listed and then missing at the read was reported as
unread, so `consent revoke` printed "not stopped yet" and failed though nothing
was left to refuse. Such a batch is skipped now; any other read or parse error
is still reported.
@BolotnyaBoss
BolotnyaBoss merged commit 3a93375 into codemie-ai:main Dec 4, 2026
7 checks passed
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.

2 participants