Skip to content

Say why a policy or hook stop ended the turn - #1059

Merged
Varuas37 merged 11 commits into
mainfrom
cursor/policy-stop-says-so-454a
Oct 21, 2026
Merged

Varuas37 merged 11 commits into
mainfrom
cursor/policy-stop-says-so-454a

Conversation

@Varuas37

@Varuas37 Varuas37 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Before: A rule or hook that stops a turn records the decision, and the conversation goes quiet.

After: The turn says it was stopped, names the rule or the hook and the tool, and the audit keeps that local decision apart from whatever the provider reports later.

Closes #136

#130 stays open. #989 (notify the phone while a permission review waits) is still open and is part of that tracker.

Background

A binding can be configured to end the turn or close the session when it refuses a tool review. A permission-review hook can return the same two outcomes. The audit record already names the rule. The panel reads execution events, not the audit sink, and those events dropped the rule. A hook stop cancelled the review and finished the turn with no notice.

The problem

You ask the agent to run a tool. A rule or a hook refuses and stops the turn. The turn ends, and nothing on screen says why.

flowchart LR
  stop[Configured stop] --> audit[Audit record with the rule]
  stop --> event[Declined-review event without the rule]
  event --> panel[Panel: the turn stopped]
  hook[Hook stop] --> cancel[Cancellation audit]
  hook --> quiet[Panel stays quiet]
  late[Later provider result] --> audit
Loading

The solution

The declined-review event carries the same rule as the audit record. A stop has a rule and a continue has none; both the record and the event use that one check. The snapshot stores the rule and restores it through the same constructors. A saved stop without a rule, or a continue with one, is corrupt.

A hook stop is not relabelled as a rule. When the cancellation is an end-turn or a close-session hook refusal, and the review id is a notice id, the panel names the tool and quotes the hook's reason. A continue stays quiet. A declined-review notice, a hook notice, and a deadline notice are different decisions. The same decimal may name each of them. Admission checks a permission id only against other permission ids, and a decline id only against other decline ids. The wire says which decision the notice is, so no sentence replaces another.

The audit says the turn was running before the decision. After a continue it is still running. After an end-turn it is stopped, because that execution has already finished locally. After a close-session it is closing: the record is the requested close, and cleanup can still be unconfirmed. The panel sentence for that configured close says the session is closing, not that it has closed. The confirmed session transition is the separate session_closed record, whose after is closed. A provider result that arrives later stays a separate late-result record.

flowchart LR
  stop[Configured stop] --> record[Audit record with the rule]
  stop --> event[Declined-review event with the same rule]
  event --> snap[Snapshot]
  event --> panel[Panel names the rule and the tool]
  snap --> panel
  hook[Hook stop] --> cancel[Cancellation audit]
  hook --> notice[Panel names the tool and the hook reason]
  late[Later provider result] --> separate[Separate late-result record]
Loading

The decision is ADR 136. Feature commit 86108c06f. The stress follower follows a subscription again when the change source closes (a7ca42a66). The hook-stop log is written only after the stop is applied (c113a6d10). A hook end-turn sentence is shown only once that execution is cancelled (afa3dcf7a). A hook notice stays when a review notice already uses the same decimal (77c815321). Admission keeps that shared decimal, including through custom storage (3e4144943, 555eb65f8), and a deadline settlement is its own notice kind. A close-session decline records closing, and the panel says the session is closing (8b0200eca, 1c09590a2).

How we checked it

  • A stopped turn still shows the rule after the turn is cancelled, and a later message in that turn does not replace the sentence. A hook end-turn names the tool and the reason. A hook continue, and a hook stop whose review id is not a notice id, add no stop sentence.
  • A declined review and a hook stop with the same decimal both stay on the turn, including when the history is admitted as a snapshot. A later review update rewrites the review sentence and leaves the hook sentence. A deadline settlement with that same decimal stays as a deadline notice. The product wire accepts all three kinds and still rejects two notices of one kind with one decimal. A repeated permission id is still rejected. Custom storage restores a review beside a decline that uses the same decimal, and rejects that permission requested twice.
  • Restoring a snapshot keeps the rule id, revision, and grantor. Stripping the rule from a stop, attaching a rule to a continue, or saving an oversized rule id is rejected.
  • Ending the turn and closing the session still publish the rule on the event when the provider's result arrives afterwards, and when the audit sink stalls.
  • The audit JSON for an end-turn says before running and after stopped. A close-session decline says after closing. A continue stays running. The confirmed close remains session_closed with after closed. The configured close sentence says the session is closing.
  • The gateway log for a configured stop names the rule and the tool. The hook log names the tool, the hook, and the reason, and only after the stop is applied. An end-turn that arrives after the provider has already settled writes no hook-stop warning. Neither log contains the tool arguments or the grantor.
  • cargo clippy -p nessa-sdk -p nessa-protocol -p nessa-server --all-targets -- -D warnings is clean on 8b0200eca. The projection tests for the hook sentence, the shared decimal through admission, the deadline kind, and the wire kind pass. The client view check accepts one review notice, one hook notice, and one deadline notice with the same decimal, and rejects a repeated kind. The custom-storage restoration test passes on 555eb65f8. The configured close sentence test passes on 1c09590a2.

The live gateway still installs a continue refusal, so no conversation can be driven into this notice from the product. The projection tests are the panel contract. No scripted end-to-end run can produce this sentence until a product setting selects a stopping refusal.

Tradeoffs and follow-ups

The panel sentence is computed from the event, so an audit failure cannot hide the reason. A second event type for "policy stop" was not added, because it would be a second owner of the same refusal. A hook is not stored as a rule.

Left for later: a product setting that selects a stopping refusal, and #989.

Rollout

Nothing special. Nessa is alpha and this snapshot field is new; a continue saved without a rule still restores.

Open in Web Open in Cursor 

A configured stop carries its rule on the event the panel reads, and the
snapshot restores that rule. The audit records the turn as running before
the decision and stopped or closed after. A hook that ends the turn or
closes the session names the tool and the hook's reason. A continue stays
quiet.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 13610671-9a0b-4475-9181-73e37f2412d5
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

An in-process restart can deliver source_closed before the socket dies.
The follower treated that as fatal, left the view frozen, and then accepted
a subscription past the connection limit because the server had released
the slot. Subscribe again, as the protocol already says to.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>
@Varuas37
Varuas37 marked this pull request as ready for review October 20, 2026 17:30

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T00:03:54.114070Z 69cf86d Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7ca42a662

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

An end-turn that arrives after the provider has already settled leaves the
session open. The warning was written before that check, so it claimed the
hook had stopped a turn the provider finished on its own.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c113a6d105

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

A provider that has already settled is recorded as continue, so the panel
does not say the hook stopped it. An end-turn cancellation that is followed
by any other finish stays off the turn until the execution is cancelled.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: afa3dcf7a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ReviewDeclineId and PermissionId are different identities. A local notice
now says whether it is the review or the hook, so the same decimal can name
both and the hook sentence stays.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

The client typecheck rejected a notice kind on a part whose type was inferred
without that field.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1423b24e91

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

cursoragent and others added 2 commits October 20, 2026 21:37
A permission id and a decline id are different identities. Admission checks each inside its own type, so a restored history can keep a hook notice beside a review notice that uses the same decimal. A deadline settlement uses its own notice kind, so that sentence stays beside the decline.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>
The decline audit is written before session cleanup is confirmed. Its after field is closing. The confirmed transition stays on the session_closed record.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

The restoration regression still required those identities to collide. A custom adapter may assign the same decimal to both, and one permission requested twice is still rejected.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 555eb65f89

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The decline event requests the close. The panel sentence now says the session is closing. It does not say the session has closed. The confirmed transition stays on session_closed.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 1c09590a24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Both sides already resume a stress subscription when its change source closes. The comments keep that protocol rule and the reason a fatal source_closed freezes the view.

Co-authored-by: Saurav  <saurav.panthee@gmail.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 69cf86d160

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Varuas37
Varuas37 merged commit 13cdd0f into main Oct 21, 2026
13 checks passed
@Varuas37
Varuas37 deleted the cursor/policy-stop-says-so-454a branch October 21, 2026 01:00
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.

A turn stopped by policy has to say so: attribution, audit, and the panel

2 participants