Skip to content

feat(cli): scheduled-check with an opt-in OS notification (#267) - #290

Open
hknsahin97-coder wants to merge 4 commits into
avenoxai:mainfrom
hknsahin97-coder:feat/scheduled-check-notify
Open

hknsahin97-coder wants to merge 4 commits into
avenoxai:mainfrom
hknsahin97-coder:feat/scheduled-check-notify

Conversation

@hknsahin97-coder

Copy link
Copy Markdown
Contributor

Closes #267.

beyin.py scheduled-check [--notify]: kullanıcının kendi kurduğu işletim sistemi zamanlayıcısı için önce sync, sonra doctor. Model çağırmaz, servis kurmaz, hiçbir şeyi onarmaz; Beyin zamanlayıcı kurmaz. #255'teki eleştiriler ve #267'deki inceleme listesi madde madde aşağıda.

İnceleme listesine karşılık

Madde Nasıl
Oturum satırı bildirimin başarısına bağlı olmasın Durum dikkat'e geçtiğinde (ve haftalık hatırlatmada) scheduled-notice.json her zaman yazılır, --notify olsun olmasın. İlk açılan oturum bir kez söyler; durum düzelirse söylenmemiş satır geri alınır. Bildirim ek kanal.
Metin sabit kalıp + sayı, sızıntı testi Metin yalnız ISSUE_LABELS kalıpları ve sayılardan kurulur. Test: adı sk-ant-api03-parola-GIZLI olan çakışmış not (conflict, warning, skill, görev, geçerlilik hatası metinlerinde) ne bildirime, ne oturum satırına, ne kayda, ne doctor çıktısına, ne state klasöründeki herhangi bir dosyaya giriyor.
Metin argüman olarak, kabuk yok, zaman aşımı macOS on run argv. Windows: Windows PowerShell 5.1 -EncodedCommand'dan sonra argüman kabul etmiyor (ölçüldü: Cannot process command because a command is already specified), bu yüzden hook komutlarındaki desen: param() bloğu, argümanlar kodlanmış komutun içinde tek tırnaklı literal (' → ''). Yalnız yazdırılabilir ASCII geçer; tipografik tırnak gibi karakterler PowerShell'de tırnak sayıldığı için reddedilir ve bildirim failed olur. Her alt süreçte zaman aşımı (sync/doctor 900 sn, bildirim 30 sn).
Windows'ta PowerShell 5.1 Mutlak başlatıcı %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe.
Ayrı state dosyası, doctor yalnız okur scheduled-check.json, scheduled-check.lock, scheduled-notice.json, hepsi runtime state'te; .beyin-preferences.json'a anahtar eklenmez. doctor yalnız bilinen alanları bilinen türlerle geçirir, yazmaz. Notice'i söyleyince silen tek yer SessionStart (bir kez söyleme sözleşmesi bunu gerektiriyor).
Kilit İşletim sistemi kilidi (POSIX flock, Windows msvcrt), PID/yaş hesabı yok; ikinci koşu 3 ile çıkar. _portalock doğrudan kullanılmadı: install_v3.py vault'a yalnız beyin_v3*.py modüllerini kopyalıyor, kurulu vault'ta import _portalock No module named '_portalock' ile düştü (InstalledTest). Aynı ilkel, beyin_v3_compact._compact_lock ve beyin_v3_migrate._legacy_lock gibi satır içinde. _portalock'u kurulum kümesine almayı tercih ederseniz ayrı bir değişiklik olarak yaparım.
Çıkış kodları 0 sağlıklı, 1 denetim tamamlanamadı, 3 başka koşu, 4 dikkat; 2 argparse'ta. İnsan modunda 4 "işlem tamamlanamadı" yazmaz.
SessionStart yalnız küçük state dosyasını okur Dosya yoksa tek is_file(). v3_perf_budget_test geçiyor.
Belge macOS: 3.11+ mutlak Python yolu, iCloud/Belgeler için Tam Disk Erişimi, bildirim "Betik Düzenleyici" adıyla. Windows: "yalnız kullanıcı oturum açıkken". Linux: notify-send yoksa sessizce atlanır, satır yine çıkar. Hangi platformun nerede doğrulandığı tablo olarak PREFERENCES.md'de.

Doğrulama

  • tests/v3_scheduled_check_test.py 26 test: durum geçişleri (sağlıklı → dikkat → düzeldi), 7 günlük hatırlatma, aynı sorunda tekrar yok, gerçek ikinci süreçle kilit çakışması ve eski kilit dosyası üstünde 6 eşzamanlı koşu, sahte bildirim aracıyla argv denetimi, gerçek powershell.exe'ye a'b $(Write-Output PWNED); \whoami` "q"metninin aynen ulaşması, ASCII dışı metnin PowerShell'e hiç ulaşmaması, kurulum →update→rollbacksonrasıdoctor` ve SessionStart.
  • 8 mutantın 8'i testleri düşürüyor: satırın yalnız --notify ile yazılması, düzelince geri alınmaması, shown'da silinmesi, '' kaçışının kaldırılması, ASCII denetiminin kaldırılması, metnin betiğe gömülmesi, hatırlatmada satırın yazılmaması, satırın her gece yazılması.
  • Windows 11 / Python 3.14: tam v3_*test.py paketi 1355 test OK (skipped=35).
  • Gerçek masaüstü (yalnız Windows 11): Görev Zamanlayıcı'da "yalnız oturum açıkken" tek seferlik görev, geçici vault'ta sync çakışması: çıkış 4, kayıt notification: shown. Bildirim Bildirim Merkezi'ne düştü, ama kullanıcı tam ekran video izlerken açılır pencere olarak gelmedi; komut yine 0 döndü. Yani "gösterildi" bilgisi gerçekten güvenilmez, oturum satırını her zaman bırakma kararını doğruluyor. Ardından ilk SessionStart satırı söyledi, ikincisi söylemedi. macOS ve Linux yalnız testle doğrulandı.

🤖 Generated with Claude Code

hknsahin97-coder and others added 4 commits October 11, 2026 09:29
`beyin.py scheduled-check` runs sync then doctor for an OS scheduler the user
sets up and records the outcome in the machine-local runtime state; doctor
shows the last run. Exit codes 0 ok, 4 needs attention, 1 the check failed,
3 another run holds the lock; 2 stays argparse's usage error.

`--notify` (default off) shows a platform notification only when the result
changes, plus a reminder every seven days while a problem lasts. The text
names issue kinds and counts, never a note or a path. When it cannot be shown
the line is said once at the next session start.

Addresses the avenoxai#255 review: the run lock is an OS advisory lock (no stale lock
to reclaim, nobody else's lock deleted), human mode no longer reads as a
failed command, doctor passes only known fields of the record, and the docs
cover macOS python 3.11+, Full Disk Access and logs instead of /dev/null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ind tests

- PREFERENCES.md: the schtasks example now uses --% so Windows PowerShell 5.1
  hands /TR to schtasks unchanged; without it 5.1 split the \" escapes and the
  vault path fell out of /TR. Linux systemd example notes Python 3.11+.
- tests: issues() for task/validity counts and their read errors,
  hook-error.json, degraded sync, and decide() for an unreadable or
  future-dated last_notified_at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The session-start line is the channel that always works: it is left whenever a run turns to
  needs attention (and at each weekly reminder), with or without --notify, since a notifier's
  exit 0 does not prove the notification was seen. A session says it once; a recovery takes
  back an unsaid line.
- Windows toast text reaches Windows PowerShell 5.1 as single-quoted literals inside the
  encoded command (the hook-command pattern; 5.1 takes no arguments after -EncodedCommand),
  only printable ASCII passes; no environment hand-off, no shell.
- Bookkeeping renamed to told_status / told_at: it tracks what the user was told by any channel.
- Tests: secret-looking conflicted note name never reaches a text or a state file; quotes and
  subexpressions reach real powershell.exe literally; non-ASCII never reaches PowerShell;
  update + rollback keep doctor and SessionStart working; an already said problem is not
  announced again.
- Docs: Script Editor name on macOS, "only when the user is logged on" on Windows, notify-send
  missing still leaves the session line, and where each platform was verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

[Tasarım / Görüş] Zamanlanmış denetim: sonuç kullanıcıya işletim sistemi bildirimiyle ulaşsın

1 participant