Skip to content

fix(telemetry): usage sharing can tell "never asked" from "asked and refused" (abilityai/trinity-enterprise#1397) - #4786

Merged
vybe merged 1 commit into
devfrom
fix/ent1397-usage-sharing-opt-out
Nov 27, 2026
Merged

vybe merged 1 commit into
devfrom
fix/ent1397-usage-sharing-opt-out

Conversation

@dolho

@dolho dolho commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The usage-sharing consent flag is off both for an install that was never asked and for one whose admin switched sharing off. A caller that turns sharing on for the operator could not tell them apart.
  • telemetry_sharing_service.has_opted_out() answers it from rows the service already writes: the consent row stored as off, a consent time left from when sharing was on, or the "Don't ask again" mark.
  • No behaviour changes in this repository. The caller is in the private module; its PR is linked in a comment below.

Changes

  • src/backend/services/telemetry_sharing_service.py: the new read. Deleting the rows (the generic settings DELETE, the reset path) returns the install to "never asked". An unreadable store counts as a refusal.
  • tests/unit/test_ent1397_usage_sharing_opt_out.py: every state is reached through the service's own writers (set_consent, mark_ask_dismissed), not by seeding keys.
  • tests/registry.json: the entry for the new file.

Test Plan

  • cd tests && pytest unit/test_ent1397_usage_sharing_opt_out.py unit/test_ent437_telemetry_consent.py unit/test_ent12_telemetry_sharing.py: 76 passed, 1 skipped (run in the backend image).
  • Full unit suite: left to CI.

Related to abilityai/trinity-enterprise#1397 (the fix itself lands in the private module).

🤖 Generated with Claude Code

…refused" (Abilityai/trinity-enterprise#1397)

The consent flag is off both for an install that was never asked and for
one whose admin switched sharing off. A caller that turns sharing on for
the operator had no way to tell them apart.

`telemetry_sharing_service.has_opted_out()` answers it from the rows the
service already writes: the consent row stored as off, a consent time left
from when sharing was on, or the "Don't ask again" mark. Deleting the rows
(the reset path) returns the install to never asked. An unreadable store
counts as a refusal.

No behaviour changes in this repository: the caller is in the private
module.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@dolho

dolho commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The private half, which calls this: https://github.com/Abilityai/trinity-enterprise/pull/1400 (draft until this PR is on dev).

@webmixgamer

Copy link
Copy Markdown
Contributor

/review + /validate-pr: APPROVE (head 2d2c17d98)

No blocking findings. Reviewed together with the private half that calls this read.

Scope: clean. One read added to telemetry_sharing_service (29 lines), one new test file, one registry entry. No behaviour changes in this repository. Lane B (no router, schema or image change).

Execution coverage

changed symbol executed by live consumer verdict
has_opted_out() (src/backend/services/telemetry_sharing_service.py) all 10 tests of tests/unit/test_ent1397_usage_sharing_opt_out.py; every state is reached through set_consent / mark_ask_dismissed none in this repository: the caller is in the private module, in the PR linked above executed; the consumer is in the paired PR

No test asserts source text.

Fix mutation. With the service at the merge-base 7eefcc383 the function does not exist, so all 10 tests fail. Single-line mutations at the head:

mutation result
PM1 a stored "false" alone is not an opt-out 1 failed
PM2 the consent time is not read 1 failed
PM3 the dismissal is not read 2 failed
PM4 an unreadable store is not a refusal 1 failed
PM5 an install that is sharing reads as opted out 2 failed

Both halves together. Each side's tests stand in for the other: these tests never reach the caller, and the caller's tests replace this service with a stub. So I ran a probe (6 tests, attached to the private PR) that drives the real caller over this function and a real settings store (SQLite), with every state reached through the real writers:

state acceptance of terms
nothing stored sharing comes on, one audit line, one share
switched off after being on stays off; no row changes; nothing audited or sent
switched off, never on stays off; no row changes
"Don't ask again" stays off; no row changes
"Don't ask again", then switched on by the person already on; nothing done twice
already sharing left alone

All pass at both heads, and with both sides merged with their bases (dev ea04de240 here).

Checked by reading.

  • A stored mark is always a person's choice. set_consent is called only from the consent route and mark_ask_dismissed only from the dismiss route; the generic settings PUT refuses the telemetry_sharing_* family; the frontend calls the dismiss route only from the "Don't ask again" button (StepSharing.vue), and Skip is per browser and leaves no mark.
  • The read matches the state table in docs/memory/feature-flows/telemetry-sharing.md: consent on stamps the dismissal, switching off keeps the stored "false", a full delete returns to "never asked".
  • The fail direction is the safe one: an unreadable store reads as a refusal.
  • The real get_setting_value returns the default only for a missing row, as the test's store does.

Pinned guards. 323 guard files derived at the head, CI's flags and seed: 13,290 passed, 98 red (24 failed, 74 errors). They are the same 98 test ids that are red on this machine on dev commit 30ce96ecb (real-app driver and pin tests that need packages missing here). CI's regression diff is green on this head.

Critical

None.

Informational

I1. The feature flow does not mention the new read (8/10)
docs/memory/feature-flows/telemetry-sharing.md is the record of these rows (the identity-rule table). One line there on how "never asked" differs from "refused" would keep it the one place to look.

I2. No test in either repository runs the caller over the real function (7/10)
The probe above does it once. After this lands on dev, one test on the private side over the real service would pin the seam in CI. Not needed for this PR.

Clean categories

  • SQL and data safety: reads only, through the existing settings accessor; no schema change.
  • Concurrency: no new state. The caller reads and then writes; two acceptances at once would both land on the same write-once rows.
  • Auth boundaries: no route added or changed.
  • Error handling: the one broad except is the fail-closed answer and is tested (PM4).
  • Credentials, hosts, emails: none in the diff. No doc lines added, so nothing for the enterprise docs guard.
  • Invariants Setup improvements #5 and feat: SMARTS trading pipeline with Telegram notifications and Miro visualization #13: no agent-server twin, no router changed.

/validate-pr summary

Category Status Notes
Commit messages ✅ one, conventional
Base branch, size ✅ dev; 3 files (+161/-0)
Issue link ✅ Related to abilityai/trinity-enterprise#1397 is the right word here: the fix lands in the private PR, which carries the closing keyword
Journey Impact ✅ check_journey_impact.py exit 0 (none declared)
Requirements, architecture ➖ no behaviour change here
Feature flows ⚠️ I1
Security greps, file modes, host paths ✅ nothing found
Packaging, config vars, audit rows ➖ no new directory, env var or gated write handler
Structural review ✅ this report
Test adequacy ✅ every branch of the read has a red mutation
Cross-surface drift ✅ nothing printed
Merge gate ✅ Tier 1 17 pass, 6 skipped on this head, regression diff included; dev-ci success
Product fit ➖ no user or operator surface path touched

Summary

  • Critical: 0
  • Informational: 2, neither needs a change before merge
  • Scope: clean

Merge order (as the private PR says): this PR first, then the private PR, then the submodule pointer in its own PR after both are in.

🤖 Generated with Claude Code

@webmixgamer webmixgamer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving 2d2c17d98: no critical findings. The /review + /validate-pr report is in the comment above. Merge this one before the private half.

@vybe
vybe merged commit d6629b8 into dev Nov 27, 2026
27 of 55 checks passed
@vybe

vybe commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Merged for the self-serve project on the operator's word of 2026-11-27 ("keep going, make it work"), after the review and validation approval above and a green dev. The fix stacked on this (#4810) needed it on dev.

trinity-ability pushed a commit that referenced this pull request Nov 27, 2026
#4786 landed on dev as d6629b8 (content-identical to 2d2c17d on this
branch). Only conflict: tests/registry.json, both entries kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

3 participants