Skip to content

Restore V1 installation and daily usage telemetry alongside V2 - #1672

Open
lihongguang-0014 wants to merge 5 commits into
mainfrom
fix/restore-v1-telemetry
Open

lihongguang-0014 wants to merge 5 commits into
mainfrom
fix/restore-v1-telemetry

Conversation

@lihongguang-0014

@lihongguang-0014 lihongguang-0014 commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Scope

The V2 rollout disconnected both V1 Gateway upload jobs and the completed-turn daily usage collector, leaving installation/version and daily token metrics unreported. Restore V1 collection and uploads alongside V2, starting uploads only after Gateway readiness and cancelling the owned daily task before storage closes.

Scope boundary: Gateway startup, shared turn finalization, V1 reporting vetoes, daily upload identity, recovery copies, regression tests, privacy documentation, and release notes. Preserve installation identity, endpoints, and payload fields; pending completed days resume through the existing retry loop. Daily event IDs now derive from a random discriminator persisted atomically in each aggregate database, preventing different profiles on the same machine from sharing a deduplication key. Restarts, retries, concurrent connections, and database moves keep the same key. A fresh recovery target that clears daily counters also clears the discriminator; ordinary backups and existing targets retain it. Existing table schemas and public APIs remain compatible.

Upgrade compatibility: acknowledged historical days remain untouched. Pending legacy days move to the new database-specific key namespace. Older versions did not persist upload-attempt state, so a historical upload accepted by the collector whose acknowledgment was lost may be counted again during this one-time transition; resolving that ambiguity requires collector-side reconciliation. The privacy documentation and release note disclose this boundary.

Non-goals: resurrecting the provider install-ID header, changing V2 events, reconstructing uncollected historical daily totals, or deploying the collector.

Branch

Base branch: main

Target exception: N/A

Issue

Linked issue: None

If None, reason: fixes a telemetry regression verified directly in the current runtime and Gateway startup paths.

Release Note

Release note: CHANGELOG.md Unreleased / Fixed documents restored V1 statistics alongside V2.

Tests

Ruff: uv run --no-sync ruff check src tests passed.

Pytest: 1,037 passed and 4 skipped in the latest combined run across V1 collection/upload/identity, actual runtime turns, Gateway boot, V2 runtime/server, reporting configuration, recovery copies, persistent preferences, release consistency, and architecture import contracts.

CI repair validation: 151 passed and 2 skipped across Windows shard allocation, duration governance, and bounded output capture. Register both new telemetry test files with provisional duration weights and their matching shards. The background output regression now waits for collector finalization before asserting retained state and removing its session; an injected delay reproduced the original intermediate state and passed. This test-only synchronization change is platform-neutral and changes no runtime timeout, persisted state, or public interface. Ruff and diff whitespace checks passed.

Build: not run; no packaging or generated assets changed.

Regression tests: added

Notes: uv run --no-sync mypy src/opensquilla --show-error-codes passed for 1,598 source files. Regression tests fail with the original startup/collector disconnections and pass with the restoration. Actual synthetic turns verify exactly one daily count and all four token totals per completed turn while V2 result facts still fire. Startup tests cover both readiness orders, embedded construction, failures, repeated callbacks, and cancellation before storage closure. Thirteen new identity tests exercise both current and legacy database shapes against an idempotent HTTP mock collector: profiles with 1 and 2 turns retain all 3 turns, retries after a lost acknowledgment and database relocation do not duplicate, and opt-outs create no upload identity. The stale V1-retirement documentation contract is updated; all 56 release consistency tests pass. Existing Windows state-write and multiprocessing identity tests pass; the new SQLite identity and recovery behavior is platform-neutral for Linux, macOS, and Windows. Independent re-review and a separate synthetic collision/restart/concurrency reproduction found no remaining actionable defects.

The default test path remains offline, deterministic, credential-free, and safe for forks.

Maintainer Live Check

Maintainer live check: no

Surface: N/A

Safety

V1 respects the unified reporting switch, migrated scope declines, legacy opt-outs, product-analytics environment veto, CI/test suppression, and DO_NOT_TRACK at collection and upload boundaries. Existing V1 pseudonymous identity behavior is retained and documented separately from V2; raw MAC/IP values and conversation content are not sent. No live telemetry was sent for validation. Only synthetic fixtures are added; no credentials, transcripts, or machine-specific paths are included.

Third-Party Origin

Third-party origin: none

Documentation Changes

  • Links point to existing repository files or stable external pages.
  • Code fences and Markdown tables render correctly on GitHub.
  • Examples avoid real secrets, local private paths, and private transcripts.

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.

1 participant