Skip to content

Refine W3 design: typing, parser, retry, ADRs#5

Merged
toobuntu merged 2 commits into
mainfrom
w3-doc-refinements
May 10, 2026
Merged

Refine W3 design: typing, parser, retry, ADRs#5
toobuntu merged 2 commits into
mainfrom
w3-doc-refinements

Conversation

@toobuntu
Copy link
Copy Markdown
Owner

@toobuntu toobuntu commented May 10, 2026

Adds class-vs-module decomposition pattern; refines babble.env to two-tier (user/system) with BABBLE_SYSTEM_ENV_TAKES_PRIORITY; strengthens Sorbet typing and adds Testing discipline sections; documents upstream bootsnap fix history; adds Safety and transparency design to ADR 0001 (SHA256 sidecar via .githooks/pre-commit.d/ drop-in, CI enforcement, runtime verification, ohai transparency, cache auto-invalidation, no strip).

Summary by CodeRabbit

  • Documentation
    • Expanded architecture guidance with class-vs-module decomposition and component classification rules
    • Reworked environment/config precedence and added a sysadmin override behavior for env sources
    • Added concrete examples for entry-point, phase, and utility patterns and stricter testing/Sorbet discipline
    • Enhanced Swift quit-alert build strategy with SHA256-sidecar verification, compile/cache transparency, and failure handling notes

Review Change Stack

Copilot AI review requested due to automatic review settings May 10, 2026 06:27
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 27648bca-d645-4629-90e3-c193a8bbaa30

📥 Commits

Reviewing files that changed from the base of the PR and between 01cf5ef and 10193d5.

📒 Files selected for processing (2)
  • docs/migration-investigation/01-decisions.md
  • docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md

📝 Walkthrough

Walkthrough

This PR expands documentation for the W3 Babble migration with architectural patterns, component structure, Swift compilation safety via SHA256 verification, configuration precedence rules, and operational discipline enforcement for typing, testing, and retries across two decision documents and one ADR.

Changes

W3 Architecture & Operational Design

Layer / File(s) Summary
Architectural Decomposition Patterns
docs/migration-investigation/01-decisions.md
New "Class-vs-module decomposition pattern" section defines Ruby structuring rules for state-bearing classes vs pure utilities, W3-specific classification, and shape examples for entry points, phase classes, and utility modules.
W3 Component Structure & Namespace Mapping
docs/migration-investigation/01-decisions.md
Expanded "Module decomposition" guidance with explicit namespace-flattening mapping (Homebrew::Cmd::Babble, Babble::*), W3 component split enumeration (config quartet, TerminalDetector), and collapsing of MacUtils::* / MacOSInterface::* namespaces.
Configuration Precedence & Env File Parsing
docs/migration-investigation/01-decisions.md
Rewrote babble.env section with two-tier lookup order (process env > user $XDG_CONFIG_HOME/... > system /etc/babble/), introduced BABBLE_SYSTEM_ENV_TAKES_PRIORITY sysadmin override, and documented pure-Ruby parsing semantics with regex, prefix filtering, literal handling, and inlined implementation excerpt.
Swift Quit Alert Decision Reference
docs/migration-investigation/01-decisions.md
Decision text updated to reference the auto-compile + SHA256 sidecar approach and point to the ADR for the authoritative build/runtime verification specification.
Bootsnap Cache Retry Guidance
docs/migration-investigation/01-decisions.md
Expanded bootsnap-cache cleanup retry section with upstream discussion references and clarified that retry is a general transient-failure defense.
Operational Discipline: Type Checking, Testing, Retry Strategy
docs/migration-investigation/01-decisions.md
Updated Sorbet guidance to "active enforcement" with per-method sig requirements and strict-typing expectations; added/expanded testing discipline describing RSpec coverage by component, boundary mocking, and CI enforcement via brew tests.
ADR: Swift Quit Alert Build Strategy & Safety Design
docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md
Adds compilation policy (no strip/debug flags), committed SHA256 sidecar (swift/src/quit_alert.swift.sha256), maintenance workflow (pre-commit/CI/script), Ruby runtime verification flow with hash checking before compile, cache-path derivation by arch + source-hash prefix, user-visible stderr on first compile, cache behavior, and explicit failure modes (hash mismatch, compile failure, missing/malformed .sha256).
ADR Consequences & Maintenance Trade-offs
docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md
Updated "Consequences" sections to explicitly reflect compile-time verification guarantees, CI enforcement for .swift/.sha256 drift, first-compile transparency, source-hash-based cache auto-invalidation, and operational cost of .sha256 sidecar synchronization via helper/pre-commit/CI.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 From burrowed notes I nibble truth and cheer,

Classes, modules, envs mapped crystal clear,
SHA256 watches the swift source gate,
Tests and sigs keep every interface straight,
A rabbit hops: steady, tidy, near!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references typing, parser, retry, and ADRs, which align with documentation expansions on Sorbet typing discipline, babble.env parser semantics, bootsnap retry guidance, and ADR-0001 refinements. However, it does not capture the primary architectural change—the class-vs-module decomposition pattern and W3 component namespace restructuring—which dominates the changeset scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch w3-doc-refinements

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/migration-investigation/01-decisions.md`:
- Around line 629-631: The code currently treats any non-empty
BABBLE_SYSTEM_ENV_TAKES_PRIORITY value as enabled, but the docs require it to be
enabled only when set to the string "1"; change the environment-check logic to
test for exact equality (e.g., process.env.BABBLE_SYSTEM_ENV_TAKES_PRIORITY ===
'1') wherever BABBLE_SYSTEM_ENV_TAKES_PRIORITY is read (the sample
implementation block that inverts file precedence), and update any related
boolean coercions or truthy checks so only '1' enables system precedence.

In `@docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md`:
- Around line 211-213: The markdown has three fenced code blocks missing
language tags in
docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md; add
an appropriate language identifier (e.g., text or bash) to each opening fence
for the blocks that contain "<64-hex-chars>  swift/src/quit_alert.swift", the
block starting with "==> Compiling babble's quit_alert helper (one-time)" and
the block showing the cache path
"~/Library/Caches/Homebrew/babble/quit_alert_arm64_a1b2c3d4e5f6" so they become
e.g. ```text or ```bash to satisfy markdownlint MD040.
- Around line 321-328: The helper script uses a relative path for source_file
("swift/src/quit_alert.swift") and generates the SHA from wherever it's run,
which can produce wrong results; update the script to first determine and cd to
the repository root (e.g., via git rev-parse --show-toplevel or resolving the
script directory) before referencing source_file and sha_file so that the shasum
invocation and echo ("shasum -a 256 -- \"${source_file}\" > \"${sha_file}\"" and
the source_file/shasum variables) always operate on the intended file regardless
of current working directory.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: daac1b63-471e-4a2e-8094-ad70d480b931

📥 Commits

Reviewing files that changed from the base of the PR and between 5163893 and 01cf5ef.

📒 Files selected for processing (2)
  • docs/migration-investigation/01-decisions.md
  • docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md

Comment thread docs/migration-investigation/01-decisions.md Outdated
Comment thread docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the W3 migration/design documentation to clarify component decomposition and to add a safety/transparency model for locally compiling the Swift quit-alert helper.

Changes:

  • Expanded ADR 0001 with a “Safety and transparency design” (SHA256 sidecar, verification, cache keying, and user-visible compile transparency).
  • Added a class-vs-module decomposition pattern section and strengthened typing/testing discipline guidance for the W3 Ruby rewrite.
  • Refined babble.env design to a two-tier user/system model with an opt-in system-precedence flag and a pure-Ruby parser.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
docs/migration-investigation/adrs/0001-swift-quit-alert-build-strategy.md Adds detailed safety/transparency and operational workflow for Swift helper compilation and verification.
docs/migration-investigation/01-decisions.md Documents W3 decomposition patterns, env precedence model, and stricter typing/testing discipline expectations.

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

Comment on lines +223 to +226
what the maintainer committed. The .sha256 file is signed
by the maintainer's GPG signature on the commit (per the
org-wide signed-commits convention), so tampering with the
.sha256 file requires breaking the signature too.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The org-wide signed-commits convention is to git sign commits via SSH keys. It is not yet implemented. Hopefully it will be soon.

Comment on lines +367 to +376
sig { returns(String) }
def expected_hash
line = sha256_path.read.lines.first
T.must(line).split(/\s+/, 2).first.to_s.tap do |hex|
if hex.length != 64 || hex !~ /\A[0-9a-f]+\z/
odie <<~MSG
Babble's quit_alert.swift.sha256 file is malformed.
Path: #{sha256_path}
Run `brew update` to restore the canonical version.
MSG
sig { returns(T::Boolean) }
def system_takes_priority?
value = ENV["BABBLE_SYSTEM_ENV_TAKES_PRIORITY"]
!value.nil? && !value.empty?
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows Homebrew's convention. man brew:

       Note that environment variables must have a value set to be detected. For
       example, run export HOMEBREW_NO_INSECURE_REDIRECT=1 rather than just export
       HOMEBREW_NO_INSECURE_REDIRECT.

Any value set causes detection. 1 is simply a convention.

Signed-off-by: Todd Schulman <toobuntu@gmail.com>
@toobuntu
Copy link
Copy Markdown
Owner Author

Address review feedback on PR #5:

  • Signing claim: the .sha256 trust paragraph asserted
    GPG-signed commits as the protection mechanism, but
    cryptographic commit signing is planned (SSH-based) and
    not yet enabled across toobuntu. Rewrote to describe the
    current model honestly (TLS via brew update + planned
    SSH signing) and distinguish from DCO-style --signoff.
    (per Copilot)

  • Error paths: expected_hash and actual_hash raised
    Ruby exceptions before the documented odie could fire
    for missing/empty files. Added explicit .exist? and
    empty-line checks with distinct messages for missing,
    empty, and malformed cases. Updated the Failure mode
    handling list to match. (per ChatGPT)

  • Env-var convention: BABBLE_SYSTEM_ENV_TAKES_PRIORITY
    follows Homebrew's "any non-empty value enables"
    pattern, not literal "=1". Documented in prose with the
    man brew quote and inline above the Ruby helper.
    (per coderabbitai; concern withdrawn after maintainer
    clarification)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines +246 to +250
1. **Pre-commit hook augmentation** at
`babble/.githooks/pre-commit.d/01-update-quit-alert-sha256.sh`.
The canonical pre-commit (synced from repo-foundation)
iterates `.githooks/pre-commit.d/*` in alphabetical order
and invokes each executable file in a subprocess — the
Comment on lines +320 to +324
2. **CI verification** at `.github/workflows/verify-sha256.yml`.
Runs on every PR and push:

```yaml
- name: Verify quit_alert.swift hash
Comment on lines +334 to +343
3. **Standalone helper script** at
`scripts/update-quit-alert-sha256.sh`. Manual fallback
for situations where the pre-commit hook isn't running:
amending a commit that modified the source, fixing CI
failures during initial setup, etc.:

```sh
#!/usr/bin/env bash
set -euo pipefail

@toobuntu toobuntu merged commit 8e49990 into main May 10, 2026
7 checks passed
@toobuntu toobuntu deleted the w3-doc-refinements branch May 10, 2026 21:45
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