Repository navigation
Conversation
9a47b56 to
66690ca
Compare
66690ca to
62b4476
Compare
|
Rebased onto current
Recording ( Full gate on Windows 11: fmt clean, clippy zero warnings, 3599 passed / 0 failed. The 3 remaining failures ( |
62b4476 to
8ec0ecb
Compare
|
Friendly ping: this one is still waiting on workflow approval. The fork-PR CI run for 8ec0ecb is sitting at Re-checked today against develop c356374:
Happy to rebase onto current develop if a fresh head is easier to review. |
5a306cd to
b1a2d72
Compare
|
@KuSh, a gentle nudge on this one when you have a moment. It's small and self-contained (3 files, one commit), and it still merges cleanly onto today's Re-checked today with this branch merged onto e05c7bd, on Windows x86_64-pc-windows-gnu: One thing to watch whenever this is rebased: v1.0 took The fork-PR CI run for b1a2d72 has been waiting on workflow approval since 10-14. Could someone approve it and take a look? If you'd rather it be sliced differently, or folded into something you already have open around tracking, I'm happy to do that. |
6bfebf8 to
0c46285
Compare
KuSh
left a comment
There was a problem hiding this comment.
Round 1 — CHANGES REQUESTED
Claim: parse failures are stamped with the cwd, rtk gain --failures --project scopes them like rtk gain --project scopes savings, and existing DBs gain the column through a schema migration.
Scope: accept (round 1, frozen).
Ran:
- Matrix: rtk's own fallback (
rtk echo …recovered,rtk <missing>failed), recording into a scratchRTK_DB_PATH. 8 cwd cases: project root, subdirectory, sibling, symlink to the root,proj[1],proj1/sub, a project with no failures, a deleted cwd. Builds: merge-base 8157d4d, head b1a2d72, and that head merged onto develop 6c2313a. Also a DB upgraded from 1.0 and then written by 1.0 again, 12 failures under the 10-row window, and the first upgrading open with another connection holding the write lock for 3, 8 and 14 s. - On 0c46285 (the same patch, rebased): the 8 s lock run, the surviving mutations, and fmt/clippy/tests. It no longer applies to develop 3ab08be (tracking.rs), so there is no merge gate this time. The lock run was also made on this patch ported locally onto develop's step engine.
- Invariants: non-default targets; over-cap + accounting (12 total, 10 shown under "last 10"); under the hook (
rtk rewriteleavesrtk gain --failures --projectunchanged); every decision. No filter, so no savings figure applies.
Pins: 18 decisions, 19 mutations. 8 survive the suite, and still do on 0c46285 against 91 core::tracking/analytics::gain tests:
succeededunscoped andtop_commandsunscoped;- in
show_failures: scope not passed, empty-message branches swapped, title branches swapped,Scope:line removed, label guard dropped, label removed.
One more is equivalent (the is_empty() guard in project_dir_name).
Matrix: executed this round; pin check: executed this round.
CI @0c4628578: not run. The run waits for approval, and the branch no longer merges into develop; it runs after the rebase. (@b1a2d72b9: all green.)
Blocks merge (3)
src/core/tracking.rs:506: the migration has to move onto develop's step engine, and on this branch it can stamp the version without the column.-
Why the port: since #4894, develop versions the tracking schema with
SchemaVersionand applies each step in its own transaction.SCHEMA_VERSION3 is nowInitialRecheck's stamp, so this migration is version 4. A DB develop already stamped 3 would never run it. -
The port:
- a
ParseFailuresProject = 4variant directly aboveNext; - its step appended to
MIGRATIONS, adding the column withdb::add_column_if_missingand the index with?(alet _would hide a failed ALTER that the engine otherwise rolls back and retries); - an upgrade test from a DB seeded at
InitialRecheck(seed_schema+upgrade_through_tracker), as the enum's doc asks.
migrate_initialstays as it is: a released step never changes the schema it produces. - a
-
Rows it must pass:
- a fresh DB has
parse_failures.project_path; - a DB stamped 3 gains it on the first
rtk <cmd>, and its existing rows read''; rtk initreplays every step without error;rtk gain --failuresexits 0.
- a fresh DB has
-
Evidence on this branch: v2 DB, another connection holding
BEGIN EXCLUSIVEfor 8 s during the first open.- The ALTER error is discarded and
user_version = 3is written once the lock is free, so the DB ends at version 3 without the column. - The run under the lock and every run after it record no parse failure, with no warning.
- Plain
rtk gain --failuresexits 1 withno such column: project_path. - Reproduced twice on b1a2d72, once on that head merged onto develop 6c2313a, and once on 0c46285.
- The ALTER error is discarded and
-
The port closes it, with no lock-specific test needed: ported locally onto the step engine, the same patch comes out of that run at version 4 with the column, and it records failures.
-
src/analytics/gain.rs:1815: the row label does not identify the project, and none ofshow_failures's decisions is pinned.-
Label: it is the cwd's last component. Failures recorded in
projA/sub,proj[1]/subandproj1/suball print as(sub)inrtk gain --failures. -
Scoped view: the label is suppressed even for rows from a subdirectory of the scope. From
projA, the failure recorded inprojA/subprints exactly like the ones recorded at the root. -
A correct label: tells those three apart in the unscoped view. In the scoped view, a row recorded below the scope carries its subdirectory, and a row at the scope root carries nothing.
-
Evidence (pins): each of these passes all 91
core::tracking/analytics::gaintests:show_failures(&tracker, None)at:632;- swapping the empty-message branch;
- swapping the title branch;
- removing the
Scope:line; - dropping
if project_scope.is_none()from the label arm; - removing the label.
-
Test must record failures in
<root>/a,<root>/a/suband<root>/b/sub(throughcommon::rtk_command(), or a renderer that returns the text), then assert that:- the unscoped labels are distinct;
--projectfromaprintsRTK Parse Failures (Project Scope), theScope:line and thesubrow's label, and leaves outb/sub;--projectfrom an empty directory printsNo parse failures recorded for this project.
Each of the six mutations must turn it red.
-
src/core/tracking.rs:1200,:1215: two of the four scoped queries are unpinned.- Evidence: removing the project filter from the
succeededcount, or from thetop_commandsquery, passes the suite.test_parse_failure_summary_filtered_by_project's only recovered row is in scope, and it never readstop_commands. - Test must put recovered failures and a repeated command in the sibling project (for example two recovered
cmd_otherrows inbeta), then assert that the scopedrecovery_rateis still 50.0 and thattop_commandshas nocmd_other. Each mutation must turn it red.
- Evidence: removing the project filter from the
Optional
- In the scoped view, a project whose only failures predate the column prints
No parse failures recorded for this project.followed byThis means all commands parsed successfully, thoughrtk gain --failureslists the failure. Rows recorded before the upgrade carry''and are correctly out of scope; only the second line's claim is wrong there. get_parse_failure_summaryhas no production caller left and needs#[allow(dead_code)]. Its tests can callget_parse_failure_summary_filtered(None)directly.- The
// added/// changed: …markers on new lines describe the edit, not the code; they read as noise once merged.
Follow-ups
- #5173
rtk gain --projectmis-scopes project paths containing[,*or?. It is pre-existing (project_filter_params, unchanged since v1.0.1 and in v1.2.0, not in this PR's hunks), and this PR's scoped failure view inherits it.
Checked and correct — no need to re-verify
- Rows are stamped with the canonical cwd. Through a symlink they get the target's path. A deleted cwd records
'', and--projectthere fails with the existing cwd error. --projectscoping on head (root plus subdirectories, sibling excluded) replaces the merge-base behaviour, where--failuresignored--projectand listed every project.- 1.0 → 3 upgrade: existing rows read
''and get no label, the index is created, and 1.0's tables are untouched. 1.0 writing into a v3 DB inserts'', and both binaries read it back. - 12 failures in one project: total 12, 10 rows under "last 10".
- These are pinned (their mutations fail the suite): the
project_pathwrite, the ALTER, thetotalandrecentfilters, theproject_pathread-back, andproject_dir_name's separators. - Telemetry still sends only counts.
parse_failures_since, the cleanupDELETEandreset_alldon't depend on the new column. - 0c46285: fmt and clippy are clean, and
cargo test --allpasses 5563 tests. b1a2d72 merged onto develop 6c2313a: 5326 passed, with 1 local failure (go_test_help_is_not_replayed_through_the_injected_json, a toolchain shim on this machine, unrelated; green in CI).
Your questions
- "If you'd rather it be sliced differently, or folded into something you already have open around tracking, I'm happy to do that." → No change of shape: the scope is accepted as it stands, and nothing open on our side touches
parse_failures. - "this PR's migration is 3" (10-25) → since #4894 it is version 4, through the step engine (item 1). A lost bump now fails the build:
MIGRATIONShas to list every variant in order.
Next
Items 1–3: the port onto the step engine, a label that names the project with show_failures pinned, and the two scoped queries pinned. After those, this merges.
Rounds: 1. Threads: 3 open (waiting on the author), 0 resolved this round.
| // concurrent sessions. Non-fatal: `ADD COLUMN` errors harmlessly once the | ||
| // column exists, and SQLite backfills existing rows with the DEFAULT. | ||
| let _ = conn.execute( | ||
| "ALTER TABLE parse_failures ADD COLUMN project_path TEXT DEFAULT ''", |
There was a problem hiding this comment.
This migration needs to move onto develop's step engine (#4894). It becomes a SchemaVersion variant and its step, instead of a statement inside run_schema_migrations behind SCHEMA_VERSION = 3, which develop already uses for InitialRecheck. On this branch, the ALTER error is discarded and the version is stamped anyway. With another connection holding the write lock for 8 s during the first open, the DB ends at version 3 without parse_failures.project_path. From then on no parse failure is recorded, and rtk gain --failures exits 1. Item 1 in the review body has the transcript, the port and the rows it must pass.
| // added: name the project when the view spans several of them — | ||
| // already-scoped output would just repeat the header | ||
| let where_display = match project_dir_name(&rec.project_path) { | ||
| Some(name) if project_scope.is_none() => format!(" ({})", name), |
There was a problem hiding this comment.
project_dir_name keeps only the cwd's last component, so failures from projA/sub, proj[1]/sub and proj1/sub all print as (sub). The guard drops the label in the scoped view even for rows recorded below the scope. None of show_failures's six decisions is pinned: each mutation listed in item 2 passes the suite.
| [], | ||
| "SELECT COUNT(*) FROM parse_failures | ||
| WHERE fallback_succeeded = 1 | ||
| AND (?1 IS NULL OR project_path = ?1 OR project_path GLOB ?2)", // added: project filter |
There was a problem hiding this comment.
Removing the project filter from this succeeded count, or from the top_commands query below, passes the suite: the test's only recovered row is in scope, and it never reads top_commands. The rows a test must assert are in item 3.
`commands` has been stamped with the cwd since project-scoped stats landed, but `parse_failures` was not. A failure could therefore only be related to other telemetry by bare timestamp, which is ambiguous on a machine running concurrent sessions in different projects, so "which project do rtk's filters keep breaking in?" was not answerable from the data. - Add `parse_failures.project_path TEXT DEFAULT ''`, stamped by `record_parse_failure` via the same `current_project_path_string()` helper `record` uses. Call sites are unchanged. - The column and its `(project_path, timestamp)` index arrive as schema step 4 (`SchemaVersion::ParseFailuresProject`), through `db::add_column_if_missing` so a failed ALTER rolls back and is retried instead of being stamped over. `migrate_initial` is untouched. A test upgrades a database stamped at `InitialRecheck` and a second one checks a fresh database and a replay. - Add `get_parse_failure_summary_filtered()` and wire `--project` through `rtk gain --failures`, using the same exact-or-subdirectory GLOB scoping as the `commands` queries. - Label each recent failure by where it happened: the full project path in the unscoped view (the last component alone cannot tell `a/sub` from `b/sub`), the subdirectory below the scope in the scoped view, nothing for a row at the scope root. `show_failures` now renders through `render_failures`, so the output is testable. - Drop the unscoped `get_parse_failure_summary` wrapper, which had no caller left. Tests pin the scoped `recovery_rate` and `top_commands` against a sibling project's recovered rows, the unscoped labels, the scoped header, `Scope:` line and labels, and both empty-state messages. No new field is reported upstream: telemetry sends `parse_failures_24h` and `projects_count`, both counts, and no raw path leaves the machine.
0c46285 to
4346455
Compare
|
@KuSh, I've force-pushed a port of this onto
I mutation-checked the new tests: removing the No path data leaves the machine; only counts are sent. |
Problem
commandshas been stamped with the cwd since project-scoped stats landed, butparse_failureswas not. A failure could therefore only be related to other telemetry by bare timestamp, which is ambiguous on a machine running concurrent sessions in different projects — so "which project do rtk's filters keep breaking in?" was not answerable from the data.Changes
parse_failures.project_path TEXT DEFAULT '', stamped byrecord_parse_failurevia the samecurrent_project_path_string()helperrecorduses. Call sites are unchanged.get_parse_failure_summary_filtered()and wire--projectthroughrtk gain --failures, using the same exact-or-subdirectory GLOB scoping as thecommandsqueries. The unscoped failure log now labels each recent row with its project directory, since that view spans several projects.(project_path, timestamp)to matchidx_project_path_timestamp.Migration handling
The column is added in
run_schema_migrations(), andSCHEMA_VERSIONgoes from 2 to 3. v1.0.0 already stamps databases withuser_version2, so without the bumpTracker::new()'s version gate would skip the new statement on every machine that has run 1.0.test_gated_open_migrates_v2_db_to_parse_failures_project_pathopens a v2-stamped DB through the gated path to pin that (it fails with the version left at 2).Existing rows take the column DEFAULT rather than NULL, so readers never have to tell "old row" from "unknown project".
Privacy
No new field is reported upstream: telemetry sends
parse_failures_24handprojects_count, both counts, and no raw path leaves the machine.Verification
Rebased onto develop 8157d4d (v1.0.0).
cargo test --all --no-fail-faston Windows: every target passes except two known Windows-environment failures in files this PR doesn't touch (find_cmd::run_from_args_propagates_find_exit_statusandstream::test_read_lines_lossy_preserves_lines_after_invalid_utf8. Clippy is clean.On a copy of a production
history.dbreshaped to v1.0's schema (user_version2, noparse_failures.project_path): all 17653 existing rows migrate to'',user_versionbecomes 3, the index is created and 1.0's own tables are untouched.