Jump to content

MindAttic.Psst/BIBLE

From MindAttic Docs

MindAttic.Psst — Project Bible

Single source of truth for what MindAttic.Psst IS, is NOT, and the rules that keep it coherent. README.md says how to build/run; this says how to think about the system.

1. The one sentence

MindAttic.Psst is a Windows .NET notifier — a library plus a psst CLI front door — that plays a short attention-getter sound locally and sends an SMS the moment a wrapped CLI command finishes (or on demand), so you can walk away from a long-running build and still know the instant it lands.

2. The product promise

  • Wrap anything, get pinged. psst -- <command> [args...] runs the command to completion, captures its exit code and wall-clock duration, then fires sound + SMS — whether it passed or failed. See §4.3 WrapAsync.
  • Know without looking. The message states what ran, the OK/FAIL status (with a readable label for well-known NTSTATUS crash codes), and how long it took.
  • SMS that actually arrives. Email-to-SMS carrier fanout is the transport. Exactly one transport per send — no implicit fallback chain at send time (LAW-4).
  • No daemon, no service. A single CLI. Nothing listening on a port; deferred/repeat sends detach to a MindAttic.Scheduler job rather than holding the shell open.
  • Credentials stay out of the repo. Secrets resolve through the shared MindAttic.Vault chain (HOUSE-LAW-3).
  • Drip & defer. psst sms supports --repeat N, --interval/--every <dur>, and --schedule/--start <time> with next-occurrence semantics.

3. What it is NOT

  • NOT a background daemon or system tray app. It is a one-shot CLI process. There is no resident listener, no port, no service registration.
  • NOT cross-platform. It targets net10.0-windows; sound playback is gated on Windows and scheduling goes through MindAttic.Scheduler (scheduler job), which wraps Windows Task Scheduler. PsstSoundPlayer returns "not windows" elsewhere.
  • NOT a general messaging/chat platform. It sends short one-way notifications, not conversations. No inbound handling.
  • NOT a multi-transport fan-out at send time. A single send picks exactly one transport (LAW-4); the only fan-out is across carrier email gateways for one recipient.
  • NOT a secret store. It reads credentials from MindAttic.Vault; it never persists them and never commits them.
  • NOT semantically versioned. Whole-number bumps only (HOUSE-LAW-1).

4. Architecture canon

                       ┌─────────────────────────────────────────────┐
   user shell  ──argv──▶│  MindAttic.Psst.Cli  (psst.exe front door)  │
                       │   PsstCli — parse argv, dispatch subcommands │
                       └───────┬───────────────────────┬─────────────┘
                               │                        │
                  wrap/test/sms│             scheduled/ │ contacts
                               │             pending    │
                               ▼                        ▼
        ┌──────────────────────────────┐   ┌────────────────────────────┐
        │  MindAttic.Psst  (library)   │   │  Scheduling (CLI-local)     │
        │                              │   │  ScheduledTaskRegistrar     │
        │  PsstNotifier ──┬── sound    │   │  ScheduledTaskLister        │
        │                 │   PsstSound│   │    └─▶ watchdog job          │
        │                 └── SMS      │   └────────────────────────────┘
        │     ISmsClient               │
        │      └─ EmailSmsClient (MailKit, carrier fanout)
        │  PsstConfiguration ◀── MindAttic.Vault chain
        └──────────────────────────────┘

4.1 Projects

  • MindAttic.Psst — the library/NuGet package (net10.0-windows). Owns the notifier, transports, sound, configuration, contacts, and duration/time parsing. File: MindAttic.Psst/MindAttic.Psst.csproj.
  • MindAttic.Psst.Cli — the psst.exe console front door (AssemblyName=psst, OutputType=Exe). Owns argv parsing, subcommand dispatch, and scheduled sends through MindAttic.Scheduler. File: MindAttic.Psst.Cli/MindAttic.Psst.Cli.csproj.
  • MindAttic.Psst.Tests — NUnit test project (103 tests). File: MindAttic.Psst.Tests/MindAttic.Psst.Tests.csproj.

4.2 Domain model — NOUNS

  • PsstNotifier (MindAttic.Psst/PsstNotifier.cs) — orchestrates one notification: runs sound + SMS concurrently, dispatches through the email-to-SMS transport, returns a NotifyResult.
  • NotifyResult — snapshot of one notify call (Sound, Sms).
  • ISmsClient / SmsResult (MindAttic.Psst/Sms/ISmsClient.cs) — single-shot SMS dispatcher contract + its outcome record.
  • EmailSmsClient (MindAttic.Psst/Sms/EmailSmsClient.cs) — MailKit SMTP transport that delivers through carrier email-to-SMS gateways.
  • CarrierGateways (MindAttic.Psst/Sms/CarrierGateways.cs) — US carrier gateway catalog + phone normalization + recipient fan-out/combine helpers.
  • PsstConfiguration / EmailSettings (MindAttic.Psst/Configuration/PsstConfiguration.cs) — strongly-typed settings loaded from the Vault IConfiguration chain, with partial-config diagnostics.
  • PsstConfigurationSources (MindAttic.Psst/Configuration/PsstConfigurationSources.cs) — resolves the on-disk settings.json path via Vault path math.
  • Contact / ContactBook / ContactStore (MindAttic.Psst/Contacts/) — the contact book domain + persistence.
  • PsstPlayResult (MindAttic.Psst/Sound/PsstSoundPlayer.cs) — outcome of a sound play.
  • PendingTask (MindAttic.Psst.Cli/Scheduling/ScheduledTaskLister.cs) — one pending scheduled send.

4.3 Key services — VERBS

  • PsstNotifier.NotifyAsync — play sound (unless silent) + dispatch SMS concurrently.
  • PsstCli.RunAsync (MindAttic.Psst.Cli/PsstCli.cs) — dispatch only: the configuration chain, the usage text and one line per command handing it to its handler.
  • WrapCommand / TestCommand / RemindCommand / WhenCommand / TriggersCommand / WatchTickCommand / PingCommand / SoundCommand / ContactsCommand / SmsCommand / ScheduledCommand (MindAttic.Psst.Cli/Commands/) — one handler per command (RunAsync, or Run); Announcer.NotifyAsync is the announcement wrap, test and watch-tick share.
  • WrapCommand.ResolveExecutable — PATH × PATHEXT resolution so bare npm/yarn .cmd shims launch.
  • SmsCommand.ParseSmsFlags — single-pass flag parser for --repeat/--interval/--every/--schedule/--start.
  • PsstConfiguration.Load — build typed settings from IConfiguration.
  • PsstSoundPlayer.PlayAsync — play the embedded clip (MP3 via NAudio, WAV via SoundPlayer fallback).
  • CarrierGateways.BuildFanout / Combine / NormalizeTo10Digits — recipient list math.
  • DurationParser.TryParse/Format (MindAttic.Psst/Time/DurationParser.cs) — 30s/5m/2h/1d durations.
  • TimeOfDayParser.TryParse (MindAttic.Psst/Time/TimeOfDayParser.cs) — next-occurrence wall-clock times.
  • ScheduledTaskRegistrar.RegisterAsync (MindAttic.Psst.Cli/Scheduling/ScheduledTaskRegistrar.cs) — register a deferred send as a Scheduler job (scheduler job add, via SchedulerClient).
  • ScheduledTaskLister.ListAsync/CancelAsync (MindAttic.Psst.Cli/Scheduling/ScheduledTaskLister.cs) — enumerate/cancel pending sends.

5. The Laws

This project inherits the org-wide House Rules at MindAttic.HouseRules.md by reference — they are not restated here. Directly relevant inherited laws: HOUSE-LAW-1 whole-number versioning, HOUSE-LAW-3 credentials via MindAttic.Vault, HOUSE-LAW-6 one engine, many front doors, HOUSE-LAW-8 done is verified, not asserted, HOUSE-LAW-9 psst only on explicit request.

The laws below are project-specific to MindAttic.Psst.

M.PSST-LAW-1 — Notify on every exit, pass or fail

A wrapped command fires the notification regardless of its exit code, and even when the child fails to start. psst returns the child's exit code so it stays transparent in a pipeline. (WrapAsync.)

M.PSST-LAW-2 — Sound is best-effort and non-blocking

Audio failure never fails a notification. Sound and SMS run concurrently (Task.WhenAll); the MP3 path falls back to WAV, and a non-Windows host degrades to a silent no-op rather than throwing. (PsstNotifier.NotifyAsync, PsstSoundPlayer.PlayAsync.)

M.PSST-LAW-3 — Over-send, never miss

For an unknown carrier, the email transport fans out to every known US carrier gateway for the recipient's number. Duplicate buzzes are an acceptable price for guaranteed delivery; wrong-carrier gateways silently drop. (CarrierGateways.)

M.PSST-LAW-4 — One transport per send, no send-time fallback

Each send goes through the one transport Psst has, email-to-SMS; there is no transport choice and the notifier never tries a second channel when the send fails. A second transport, if one is ever added, comes with its own selection and this law is revisited then. (PsstNotifier.BuildClient, M.PSST-T75.)

M.PSST-LAW-5 — Don't recursively re-schedule

A deferred/scheduled invocation must run the send path, never re-register itself. The launcher sets PSST_FROM_SCHEDULE=1, --schedule/--start is stripped from the deferred argv, and the implicit---schedule now branch is suppressed when running as a scheduler child. (SmsCommand.ParseSmsFlags, IsFromScheduler.)

M.PSST-LAW-6 — Self-cleaning scheduled tasks

A successful scheduled send leaves nothing pending: the launcher .cmd cancels its own Scheduler job (scheduler job cancel) and deletes its JSON sidecar after firing. (ScheduledTaskRegistrar, README "How --schedule is implemented".)

M.PSST-LAW-7 — Machine-facing values are culture-invariant

Values that cross a process or OS boundary (elapsed time in the SMS body, the Scheduler --at time/date) are formatted with CultureInfo.InvariantCulture, so a comma-decimal locale can't emit "1,5s" or a date Scheduler misreads. (WrapCommand.FormatElapsed.)

6. Verified state

Evidence captured 2026-10-03 on this working tree.

  • ✅ Build: dotnet build MindAttic.Psst.slnx -c Release — clean (all three projects compile).
  • ✅ Tests: dotnet test MindAttic.Psst.slnx -c Release — 103 passed, 0 failed, 0 skipped (Duration ~0.1s).
  • ✅ Notification pipeline (PsstNotifier) — verified by PsstNotifierTests (10 tests: silent suppression, concurrent sound+SMS, transport selection, cancellation propagation).
  • ✅ Configuration loading (PsstConfiguration) — verified by PsstConfigurationTests and PsstConfigurationSourcesTests (partial-config diagnostics, Vault path resolution).
  • ✅ Duration & time parsing — verified by DurationParserTests and TimeOfDayParserTests (unit forms, next-occurrence semantics, round-trips, malformed rejection).
  • ✅ Scheduler argv quoting (ScheduledTaskRegistrar) — verified by ScheduledTaskRegistrarTests (percent-doubling, cmd metacharacter quoting).
  • ✅ CLI helpers (FormatElapsed, ResolveExecutable, usage text naming the real credential chain) — verified by PsstCliTests, WrapCommandTests and PingCommandTests.
  • ✅ Claude Code hooks are code-page safe (BOM-less .claude/*.ps1 are ASCII, so Windows PowerShell 5.1 output has no mojibake) — verified by RepoScriptsTests.
  • 🟡 End-to-end live SMS delivery (real carrier gateway) — not covered by an automated test (requires live credentials + a real phone). Exercised manually via psst test.
  • 🟡 Live Scheduler registration / sound playback on hardware — unit-tested at the string/quoting level; the actual OS calls are validated manually.

7. Active frontier

  • See docs/USER_STORIES.md for the epic/story breakdown and backlog.
  • See docs/rfc/ for open design notes. Current: RFC 0001 — direct-test coverage for the pure helpers.
  • No structured L5 canon-as-data is warranted (see this bible's §4 — the only catalog, CarrierGateways.UnitedStatesDomains, is small and lives in code by design per M.PSST-LAW-3). Revisit if international carriers or per-region routing get added.

8. Quality bar

A feature is done (✅) only when:

  1. It builds clean under dotnet build -c Release (no new warnings introduced).
  2. It is covered by a green NUnit test named in §6 or in the owning story.
  3. User-facing behavior is reflected in README.md and (if it changes a rule) in §5.
  4. Anything that crosses a process/OS/locale boundary is culture-invariant (M.PSST-LAW-7).
  5. No secret is hard-coded (HOUSE-LAW-3) and versioning stays whole-number (HOUSE-LAW-1).

Anything not meeting all five is 🟡 partial or ⬜ planned — never ✅.

9. Glossary

  • Wrap — psst -- <command>: run a command to completion and notify on exit.
  • Transport — the channel a send uses: only email-to-SMS (EmailSmsClient behind ISmsClient). The Twilio-era transport choice (PsstVia, PSST_VIA, a contact defaultVia) was removed in M.PSST-T75; a defaultVia left in an old contacts.json is ignored.
  • Fanout — sending one email-to-SMS message to every known US carrier gateway for a number, since the carrier is unknown (M.PSST-LAW-3).
  • Carrier gateway — a per-carrier email domain (e.g. vtext.com) that delivers email as SMS.
  • Sidecar — the JSON metadata file written next to a scheduled launcher .cmd so psst scheduled can render a meaningful listing.
  • Launcher — the self-cancelling .cmd a Scheduler job runs to perform a deferred send (M.PSST-LAW-6).
  • Vault chain — the MindAttic.Vault IConfiguration source order (vault files → %APPDATA% settings.json → env vars; never an appsettings.json from the current folder) credentials resolve through.
  • PSST_FROM_SCHEDULE — env marker set by the launcher so a deferred send doesn't recursively re-schedule itself (M.PSST-LAW-5).
From MindAttic.Psst/docs/BIBLE.md via MindAttic.Docs; synced automatically, so edit the repo, not this page.