Skip to content

Fix Bulgarian boundary input and scope Phase-A watchdogs - #8

Merged
RMANOV merged 3 commits into
masterfrom
agent/smartkey-next-level-followup
Jul 19, 2026
Merged

Fix Bulgarian boundary input and scope Phase-A watchdogs#8
RMANOV merged 3 commits into
masterfrom
agent/smartkey-next-level-followup

Conversation

@RMANOV

@RMANOV RMANOV commented Jul 19, 2026

Copy link
Copy Markdown
Owner

What

Follow-up to #7 with three post-merge corrections:

  • preserve raw Bulgarian words such as чака and защо at word boundaries by default; legacy boundary autocorrect remains explicit opt-in and replacement lengths stay character-safe
  • align accept_ghost_completion() documentation with the Tab-only contract
  • attach run_id + real/synthetic scope to Phase-A sweeps and filter analysis/watchdog coverage to the exact campaign

The watchdog also fails closed for an explicit unknown campaign and counts raw in-scope events even when calibration validity excludes them.

Why

PR #7 was squash-merged before two review findings and the live Bulgarian boundary regression were fully closed. Without campaign provenance, a synthetic or foreign sweep could incorrectly credit a live campaign. Without raw-event presence counting, a campaign whose stored rows were all excluded could look healthy.

Verification

  • exact clean follow-up tree matches the independently audited next-level tree byte-for-byte
  • targeted campaign/scope regressions: 7 PASS
  • Phase-A + shim: 40 PASS, 1 skip
  • full Python suite: 82 PASS, 1 skip
  • Ruff, py_compile, cargo fmt check, diff check: PASS

Head: 7de283b (same tree as next-level c1752c7)

@RMANOV
RMANOV marked this pull request as ready for review July 19, 2026 20:05
Copilot AI review requested due to automatic review settings July 19, 2026 20:05
@RMANOV
RMANOV merged commit d8c355d into master Jul 19, 2026
6 checks passed

Copilot AI 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.

Pull request overview

This PR is a follow-up to #7 that (1) makes post-commit rewrites explicitly opt-in to prevent Bulgarian boundary corruptions, and (2) scopes Phase-A sweep/watchdog attribution to an exact (run_id, synthetic) campaign so foreign/synthetic runs can’t “cover” a real campaign.

Changes:

  • Add post_commit_autocorrect (default off) and tighten transliteration safety to prevent lossy Bulgarian word rewrites at word boundaries.
  • Attach campaign provenance (run_id + real/synthetic scope) to Phase‑A sweeps, and scope analysis/watchdog coverage checks to the selected campaign.
  • Add regression tests around provenance scoping, legacy sweep migration behavior, and raw-event watchdog presence counting.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_o1_phasea.py Adds campaign provenance + legacy migration regression tests for sweeps/watchdog coverage.
phase_a/validity.py Extends row selection to enforce (run_id, synthetic) scope and adds sweep-row scoping helper.
phase_a/sweep.py Scopes sweeps/watchdog to selected campaign; records provenance in sweeps; adds --run-id.
phase_a/selftest.py Updates selftest sweep simulation and alarm handling to include campaign provenance.
phase_a/paths.py Makes watchdog alarm files campaign/scope-specific (hashed) while keeping a legacy fallback path.
phase_a/harness.py Migrates legacy sweeps schema to add provenance columns and enforce it via trigger/index.
phase_a/corpus_replay.py Enforces synthetic-only replay and stamps sweeps with the replay run_id.
phase_a/analyze.py Scopes analysis watchdog-coverage checks + alarm detection to campaign/scope.
crates/smartkey-core/src/input.rs Adds opt-in post-commit autocorrect and prevents lossy BG transliteration rewrites; updates docs/tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_o1_phasea.py
Comment on lines +176 to +177
selected_ts = _add_campaign(db, "real-selected", synthetic=False)
foreign_ts = _add_campaign(db, "real-foreign", synthetic=False)
Comment thread phase_a/sweep.py
Comment on lines +144 to 148
af = alarm_file(selected_run_id, synthetic=synthetic)
if af.exists():
af.unlink()
(receipts_dir() / f"sweep-{today}.txt").write_text(receipt + "\n", encoding="utf-8")
return receipt
Comment on lines +1326 to 1331
if other_word.is_empty()
|| other_word.chars().count() < 2
|| other_word.chars().count() != word.chars().count()
{
return None;
}
Comment thread phase_a/analyze.py
window,
synthetic=synthetic,
)
selected_run_id = selection.campaign_run_id
RMANOV pushed a commit that referenced this pull request Aug 3, 2026
Close SmartKey input safety audit

Merged with git rather than `gh pr merge` because the gh credential store
(KDE wallet) was locked and every API call hung; SSH was unaffected. Same
merge commit shape GitHub would have produced: --no-ff of 8ef48dc into
master at 8838643.

Verified before pushing, against the MERGE RESULT rather than either
parent: the bg-letter work master carries via #8 survives (its regression
test bg_punctuation_position_letters_commit_exact_words is present),
post_commit_autocorrect is intact, and the audit's own additions
(_cancel_safe, do_set_content_type, latency_sample_count) are present.
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