Compare commits

..

1 Commits

Author SHA1 Message Date
Alexander Whitestone
74365aec0c feat: track NH broadband install lifecycle (#533)
Some checks failed
Self-Healing Smoke / self-healing-smoke (pull_request) Failing after 26s
Smoke Test / smoke (pull_request) Failing after 28s
Agent PR Gate / gate (pull_request) Failing after 37s
Agent PR Gate / report (pull_request) Successful in 7s
2026-04-22 00:45:55 -04:00
5 changed files with 439 additions and 132 deletions

299
GENOME.md
View File

@@ -1,144 +1,209 @@
# GENOME.md — Timmy_Foundation/timmy-home
Generated by `pipelines/codebase_genome.py`.
# GENOME.md — the-nexus
## Project Overview
Timmy Foundation's home repository for development operations and configurations.
`the-nexus` is a hybrid repo that combines three layers in one codebase:
- Text files indexed: 3181
- Source and script files: 231
- Test files: 95
- Documentation files: 755
1. A browser-facing world shell rooted in `index.html`, `boot.js`, `bootstrap.mjs`, `app.js`, `style.css`, `portals.json`, `vision.json`, `manifest.json`, and `gofai_worker.js`
2. A Python realtime bridge centered on `server.py` plus harness code under `nexus/`
3. A memory / fleet / operator layer spanning `mempalace/`, `mcp_servers/`, `multi_user_bridge.py`, and supporting scripts
## Architecture
The repo is not a clean single-purpose frontend and not just a backend harness. It is a mixed world/runtime/ops repository where browser rendering, WebSocket telemetry, MCP-driven game harnesses, and fleet memory tooling coexist.
Grounded repo facts from this checkout:
- Browser shell files exist at repo root: `index.html`, `app.js`, `style.css`, `manifest.json`, `gofai_worker.js`
- Data/config files also live at repo root: `portals.json`, `vision.json`
- Realtime bridge exists in `server.py`
- Game harnesses exist in `nexus/morrowind_harness.py` and `nexus/bannerlord_harness.py`
- Memory/fleet sync exists in `mempalace/tunnel_sync.py`
- Desktop/game automation MCP servers exist in `mcp_servers/desktop_control_server.py` and `mcp_servers/steam_info_server.py`
- Validation exists in `tests/test_browser_smoke.py`, `tests/test_portals_json.py`, `tests/test_index_html_integrity.py`, and `tests/test_repo_truth.py`
The current architecture is best understood as a sovereign world shell plus operator/game harness backend, with accumulated documentation drift from multiple restoration and migration efforts.
## Architecture Diagram
```mermaid
graph TD
repo_root["repo"]
angband["angband"]
ansible["ansible"]
briefings["briefings"]
codebase_genome["codebase_genome"]
config["config"]
configs["configs"]
conftest["conftest"]
dns_records["dns-records"]
evennia["evennia"]
evennia_tools["evennia_tools"]
repo_root --> angband
repo_root --> ansible
repo_root --> briefings
repo_root --> codebase_genome
repo_root --> config
repo_root --> configs
browser[Index HTML Shell\nindex.html -> boot.js -> bootstrap.mjs -> app.js]
assets[Root Assets\nstyle.css\nmanifest.json\ngofai_worker.js]
data[World Data\nportals.json\nvision.json]
ws[Realtime Bridge\nserver.py\nWebSocket broadcast hub]
gofai[In-browser GOFAI\nSymbolicEngine\nNeuroSymbolicBridge\nsetupGOFAI/updateGOFAI]
harnesses[Python Harnesses\nnexus/morrowind_harness.py\nnexus/bannerlord_harness.py]
mcp[MCP Adapters\nmcp_servers/desktop_control_server.py\nmcp_servers/steam_info_server.py]
memory[Memory + Fleet\nmempalace/tunnel_sync.py\nmempalace.js]
bridge[Operator / MUD Bridge\nmulti_user_bridge.py\ncommands/timmy_commands.py]
tests[Verification\ntests/test_browser_smoke.py\ntests/test_portals_json.py\ntests/test_repo_truth.py]
docs[Contracts + Drift Docs\nBROWSER_CONTRACT.md\nREADME.md\nCLAUDE.md\nINVESTIGATION_ISSUE_1145.md]
browser --> assets
browser --> data
browser --> gofai
browser --> ws
harnesses --> mcp
harnesses --> ws
bridge --> ws
memory --> ws
tests --> browser
tests --> data
tests --> docs
docs --> browser
```
## Entry Points
## Entry Points and Data Flow
- `codebase_genome.py` — python main guard (`python3 codebase_genome.py`)
- `gemini-fallback-setup.sh` — operational script (`bash gemini-fallback-setup.sh`)
- `morrowind/hud.sh` — operational script (`bash morrowind/hud.sh`)
- `pipelines/codebase_genome.py` — python main guard (`python3 pipelines/codebase_genome.py`)
- `scripts/agent_pr_gate.py` — operational script (`python3 scripts/agent_pr_gate.py`)
- `scripts/audit_trail.py` — operational script (`python3 scripts/audit_trail.py`)
- `scripts/auto_restart_agent.sh` — operational script (`bash scripts/auto_restart_agent.sh`)
- `scripts/autonomous_issue_creator.py` — operational script (`python3 scripts/autonomous_issue_creator.py`)
- `scripts/backlog_cleanup.py` — operational script (`python3 scripts/backlog_cleanup.py`)
- `scripts/backlog_triage.py` — operational script (`python3 scripts/backlog_triage.py`)
- `scripts/backlog_triage_cron.sh` — operational script (`bash scripts/backlog_triage_cron.sh`)
- `scripts/backup_pipeline.sh` — operational script (`bash scripts/backup_pipeline.sh`)
### Primary entry points
## Data Flow
- `index.html` — root browser entry point
- `boot.js` — startup selector; `tests/boot.test.js` shows it chooses file-mode vs HTTP/module-mode and injects `bootstrap.mjs` when served over HTTP
- `bootstrap.mjs` — module bootstrap for the browser shell
- `app.js` — main browser runtime; owns world state, GOFAI wiring, metrics polling, and portal/UI logic
- `server.py` — WebSocket broadcast bridge on `ws://0.0.0.0:8765`
- `nexus/morrowind_harness.py` — GamePortal/MCP harness for OpenMW Morrowind
- `nexus/bannerlord_harness.py` — GamePortal/MCP harness for Bannerlord
- `mempalace/tunnel_sync.py` — pulls remote fleet closets into the local palace over HTTP
- `multi_user_bridge.py` — HTTP bridge for multi-user chat/session integration
- `mcp_servers/desktop_control_server.py` — stdio MCP server exposing screenshots/mouse/keyboard control
1. Operators enter through `codebase_genome.py`, `gemini-fallback-setup.sh`, `morrowind/hud.sh`.
2. Core logic fans into top-level components: `angband`, `ansible`, `briefings`, `codebase_genome`, `config`, `configs`.
3. Validation is incomplete around `wizards/allegro/home/skills/red-teaming/godmode/scripts/auto_jailbreak.py`, `timmy-local/cache/agent_cache.py`, `wizards/allegro/home/skills/red-teaming/godmode/scripts/parseltongue.py`, so changes there carry regression risk.
4. Final artifacts land as repository files, docs, or runtime side effects depending on the selected entry point.
### Data flow
1. Browser startup begins at `index.html`
2. `boot.js` decides whether the page is being served correctly; in HTTP mode it injects `bootstrap.mjs`
3. `bootstrap.mjs` hands off to `app.js`
4. `app.js` loads world configuration from `portals.json` and `vision.json`
5. `app.js` constructs the Three.js scene and in-browser reasoning components, including `SymbolicEngine`, `NeuroSymbolicBridge`, `setupGOFAI()`, and `updateGOFAI()`
6. Browser state and external runtimes connect through `server.py`, which broadcasts messages between connected clients
7. Python harnesses (`nexus/morrowind_harness.py`, `nexus/bannerlord_harness.py`) spawn MCP subprocesses for desktop control / Steam metadata, capture state, execute actions, and feed telemetry into the Nexus bridge
8. Memory/fleet tools like `mempalace/tunnel_sync.py` import remote palace data into local closets, extending what the operator/runtime layers can inspect
9. Tests validate both the static browser contract and the higher-level repo-truth/memory contracts
### Important repo-specific runtime facts
- `portals.json` is a JSON array of portal/world/operator entries; examples in this checkout include `morrowind`, `bannerlord`, `workshop`, `archive`, `chapel`, and `courtyard`
- `server.py` is a plain broadcast hub: clients send messages, the server forwards them to other connected clients
- `nexus/morrowind_harness.py` and `nexus/bannerlord_harness.py` both implement a GamePortal pattern with MCP subprocess clients over stdio and WebSocket telemetry uplink
- `mempalace/tunnel_sync.py` is not speculative; it is a real client that discovers remote wings, searches remote rooms, and writes `.closet.json` payloads locally
## Key Abstractions
- `codebase_genome.py` — classes `FunctionInfo`:19; functions `extract_functions()`:58, `generate_test()`:116, `scan_repo()`:191, `find_existing_tests()`:209, `main()`:231
- `evennia/timmy_world/game.py` — classes `World`:91, `ActionSystem`:421, `TimmyAI`:539, `NPCAI`:550; functions `get_narrative_phase()`:55, `get_phase_transition_event()`:65
- `evennia/timmy_world/world/game.py` — classes `World`:19, `ActionSystem`:326, `TimmyAI`:444, `NPCAI`:455; functions none detected
- `timmy-world/game.py` — classes `World`:19, `ActionSystem`:349, `TimmyAI`:467, `NPCAI`:478; functions none detected
- `wizards/allegro/home/skills/red-teaming/godmode/scripts/auto_jailbreak.py` — classes none detected; functions none detected
- `uniwizard/self_grader.py` — classes `SessionGrade`:23, `WeeklyReport`:55, `SelfGrader`:74; functions `main()`:713
- `uni-wizard/v3/intelligence_engine.py` — classes `ExecutionPattern`:27, `ModelPerformance`:44, `AdaptationEvent`:58, `PatternDatabase`:69; functions none detected
- `scripts/know_thy_father/crossref_audit.py` — classes `ThemeCategory`:30, `Principle`:160, `MeaningKernel`:169, `CrossRefFinding`:178; functions `extract_themes_from_text()`:192, `parse_soul_md()`:206, `parse_kernels()`:264, `cross_reference()`:296, `generate_report()`:440, `main()`:561
### Browser runtime
- `app.js`
- Defines in-browser reasoning/state machinery, including `class SymbolicEngine`, `class NeuroSymbolicBridge`, `setupGOFAI()`, and `updateGOFAI()`
- Couples rendering, local symbolic reasoning, metrics polling, and portal/UI logic in one very large root module
- `BROWSER_CONTRACT.md`
- Acts like an executable architecture contract for the browser surface
- Declares required files, DOM IDs, Three.js expectations, provenance rules, and WebSocket expectations
### Realtime bridge
- `server.py`
- Single hub abstraction: a WebSocket broadcast server maintaining a `clients` set and forwarding messages from one client to the others
- This is the seam between browser shell, harnesses, and external telemetry producers
### GamePortal harness layer
- `nexus/morrowind_harness.py`
- `nexus/bannerlord_harness.py`
- Both define MCP client wrappers, `GameState` / `ActionResult`-style data classes, and an Observe-Decide-Act telemetry loop
- The harnesses are symmetric enough to be understood as reusable portal adapters with game-specific context injected on top
### Memory / fleet layer
- `mempalace/tunnel_sync.py`
- Encodes the fleet-memory sync client contract: discover wings, pull broad room queries, write closet files, support dry-run
- `mempalace.js`
- Minimal browser/Electron bridge to MemPalace commands via `window.electronAPI.execPython(...)`
- Important because it shows a second memory integration surface distinct from the Python fleet sync path
### Operator / interaction bridge
- `multi_user_bridge.py`
- `commands/timmy_commands.py`
- These bridge user-facing conversations or MUD/Evennia interactions back into Timmy/Nexus services
## API Surface
- CLI: `python3 codebase_genome.py` — python main guard (`codebase_genome.py`)
- CLI: `bash gemini-fallback-setup.sh` — operational script (`gemini-fallback-setup.sh`)
- CLI: `bash morrowind/hud.sh` — operational script (`morrowind/hud.sh`)
- CLI: `python3 pipelines/codebase_genome.py` — python main guard (`pipelines/codebase_genome.py`)
- CLI: `python3 scripts/agent_pr_gate.py` — operational script (`scripts/agent_pr_gate.py`)
- CLI: `python3 scripts/audit_trail.py` — operational script (`scripts/audit_trail.py`)
- CLI: `bash scripts/auto_restart_agent.sh` — operational script (`scripts/auto_restart_agent.sh`)
- CLI: `python3 scripts/autonomous_issue_creator.py` — operational script (`scripts/autonomous_issue_creator.py`)
- Python: `extract_functions()` from `codebase_genome.py:58`
- Python: `generate_test()` from `codebase_genome.py:116`
- Python: `scan_repo()` from `codebase_genome.py:191`
- Python: `find_existing_tests()` from `codebase_genome.py:209`
- Python: `main()` from `codebase_genome.py:231`
- Python: `get_narrative_phase()` from `evennia/timmy_world/game.py:55`
### Browser / static surface
## Test Coverage Report
- `index.html` served over HTTP
- `boot.js` exports `bootPage()`; verified by `node --test tests/boot.test.js`
- Data APIs are file-based inside the repo: `portals.json`, `vision.json`, `manifest.json`
- Source and script files inspected: 231
- Test files inspected: 95
- Coverage gaps:
- `wizards/allegro/home/skills/red-teaming/godmode/scripts/auto_jailbreak.py` — no matching test reference detected
- `timmy-local/cache/agent_cache.py` — no matching test reference detected
- `wizards/allegro/home/skills/red-teaming/godmode/scripts/parseltongue.py` — no matching test reference detected
- `wizards/allegro/home/skills/red-teaming/godmode/scripts/godmode_race.py` — no matching test reference detected
- `skills/productivity/google-workspace/scripts/google_api.py` — no matching test reference detected
- `wizards/allegro/home/skills/productivity/google-workspace/scripts/google_api.py` — no matching test reference detected
- `morrowind/pilot.py` — no matching test reference detected
- `scripts/sovereignty_audit.py` — no matching test reference detected
- `skills/research/domain-intel/scripts/domain_intel.py` — no matching test reference detected
- `wizards/allegro/home/skills/research/domain-intel/scripts/domain_intel.py` — no matching test reference detected
- `timmy-local/scripts/ingest.py` — no matching test reference detected
- `uni-wizard/scripts/generate_scorecard.py` — no matching test reference detected
### Network/runtime surface
## Security Audit Findings
- `python3 server.py`
- Starts the WebSocket bridge on port `8765`
- `python3 l402_server.py`
- Local HTTP microservice for cost-estimate style responses
- `python3 multi_user_bridge.py`
- Multi-user HTTP/chat bridge
- [medium] `briefings/briefing_20260325.json:37` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `"gitea_error": "Gitea 404: {\"errors\":null,\"message\":\"not found\",\"url\":\"http://143.198.27.163:3000/api/swagger\"}\n [http://143.198.27.163:3000/api/v1/repos/Timmy_Foundation/sovereign-orchestration/issues?state=open&type=issues&sort=created&direction=desc&limit=1&page=1]",`
- [medium] `briefings/briefing_20260328.json:11` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `"provider_base_url": "http://localhost:8081/v1",`
- [medium] `briefings/briefing_20260329.json:11` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `"provider_base_url": "http://localhost:8081/v1",`
- [medium] `config.yaml:37` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `summary_base_url: http://localhost:11434/v1`
- [medium] `config.yaml:47` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: 'http://localhost:11434/v1'`
- [medium] `config.yaml:52` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: 'http://localhost:11434/v1'`
- [medium] `config.yaml:57` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: 'http://localhost:11434/v1'`
- [medium] `config.yaml:62` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: 'http://localhost:11434/v1'`
- [medium] `config.yaml:67` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: 'http://localhost:11434/v1'`
- [medium] `config.yaml:77` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: 'http://localhost:11434/v1'`
- [medium] `config.yaml:82` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: 'http://localhost:11434/v1'`
- [medium] `config.yaml:174` — hardcoded http endpoint: plaintext or fixed HTTP endpoints can drift or leak across environments. Evidence: `base_url: http://localhost:11434/v1`
### Harness / operator CLI surfaces
## Dead Code Candidates
- `python3 nexus/morrowind_harness.py`
- `python3 nexus/bannerlord_harness.py`
- `python3 mempalace/tunnel_sync.py --peer <url> [--dry-run] [--n N]`
- `python3 mcp_servers/desktop_control_server.py`
- `python3 mcp_servers/steam_info_server.py`
- `wizards/allegro/home/skills/red-teaming/godmode/scripts/auto_jailbreak.py` — not imported by indexed Python modules and not referenced by tests
- `timmy-local/cache/agent_cache.py` — not imported by indexed Python modules and not referenced by tests
- `wizards/allegro/home/skills/red-teaming/godmode/scripts/parseltongue.py` — not imported by indexed Python modules and not referenced by tests
- `wizards/allegro/home/skills/red-teaming/godmode/scripts/godmode_race.py` — not imported by indexed Python modules and not referenced by tests
- `skills/productivity/google-workspace/scripts/google_api.py` — not imported by indexed Python modules and not referenced by tests
- `wizards/allegro/home/skills/productivity/google-workspace/scripts/google_api.py` — not imported by indexed Python modules and not referenced by tests
- `morrowind/pilot.py` — not imported by indexed Python modules and not referenced by tests
- `scripts/sovereignty_audit.py` — not imported by indexed Python modules and not referenced by tests
- `skills/research/domain-intel/scripts/domain_intel.py` — not imported by indexed Python modules and not referenced by tests
- `wizards/allegro/home/skills/research/domain-intel/scripts/domain_intel.py` — not imported by indexed Python modules and not referenced by tests
### Validation surface
## Performance Bottleneck Analysis
- `python3 -m pytest tests/test_portals_json.py tests/test_index_html_integrity.py tests/test_repo_truth.py -q`
- `node --test tests/boot.test.js`
- `python3 -m py_compile server.py nexus/morrowind_harness.py nexus/bannerlord_harness.py mempalace/tunnel_sync.py mcp_servers/desktop_control_server.py`
- `tests/test_browser_smoke.py` defines the higher-cost Playwright smoke contract for the world shell
- `angband/mcp_server.py` — large module (353 lines) likely hides multiple responsibilities
- `evennia/timmy_world/game.py` — large module (1541 lines) likely hides multiple responsibilities
- `evennia/timmy_world/world/game.py` — large module (1345 lines) likely hides multiple responsibilities
- `morrowind/mcp_server.py` — large module (451 lines) likely hides multiple responsibilities
- `morrowind/pilot.py` — large module (459 lines) likely hides multiple responsibilities
- `pipelines/codebase_genome.py` — large module (557 lines) likely hides multiple responsibilities
- `scripts/fleet_progression.py` — large module (361 lines) likely hides multiple responsibilities
- `scripts/know_thy_father/crossref_audit.py` — large module (657 lines) likely hides multiple responsibilities
- `scripts/know_thy_father/index_media.py` — large module (405 lines) likely hides multiple responsibilities
- `scripts/know_thy_father/synthesize_kernels.py` — large module (416 lines) likely hides multiple responsibilities
## Test Coverage Gaps
Strongly covered in this checkout:
- `tests/test_portals_json.py` validates `portals.json`
- `tests/test_index_html_integrity.py` checks merge-marker/DOM-integrity regressions in `index.html`
- `tests/boot.test.js` verifies `boot.js` startup behavior
- `tests/test_repo_truth.py` validates the repo-truth documents
- Multiple `tests/test_mempalace_*.py` files cover the palace layer
- `tests/test_bannerlord_harness.py` exists for the Bannerlord harness
Notable gaps or weak seams:
- `nexus/morrowind_harness.py` is large and operationally critical, but the generated baseline still flags it as a gap relative to its size/complexity
- `mcp_servers/desktop_control_server.py` exposes high-power automation but has no obvious dedicated test file in the root `tests/` suite
- `app.js` is the dominant browser runtime file and mixes rendering, GOFAI, metrics, and integration logic in one place; browser smoke exists, but there is limited unit-level decomposition around those subsystems
- `mempalace.js` appears minimally bridged and stale relative to the richer Python MemPalace layer
- `multi_user_bridge.py` is a large integration surface and should be treated as high regression risk even though it is central to operator/chat flow
## Security Considerations
- `server.py` binds `HOST = "0.0.0.0"`, exposing the broadcast bridge beyond localhost unless network controls limit it
- The WebSocket bridge is a broadcast hub without visible authentication in `server.py`; connected clients are trusted to send messages into the bus
- `mcp_servers/desktop_control_server.py` exposes mouse/keyboard/screenshot control through a stdio MCP server. In any non-local or poorly isolated runtime, this is a privileged automation surface
- `app.js` contains hardcoded local/network endpoints such as `http://localhost:${L402_PORT}/api/cost-estimate` and `http://localhost:8082/metrics`; these are convenient for local development but create environment drift and deployment assumptions
- `app.js` also embeds explicit endpoint/status references like `ws://143.198.27.163:8765`, which is operationally brittle and the kind of hardcoded location data that drifts across environments
- `mempalace.js` shells out through `window.electronAPI.execPython(...)`; this is powerful and useful, but it is a clear trust boundary between UI and host execution
- `INVESTIGATION_ISSUE_1145.md` documents an earlier integrity hazard: agents writing to `public/nexus/` instead of canonical root paths. That path confusion is both an operational and security concern because it makes provenance harder to reason about
## Runtime Truth and Docs Drift
The most important architecture finding in this repo is not a class or subsystem. It is a truth mismatch.
- README.md says current `main` does not ship a browser 3D world
- CLAUDE.md declares root `app.js` and `index.html` as canonical frontend paths
- tests and browser contract now assume the root frontend exists
All three statements are simultaneously present in this checkout.
Grounded evidence:
- `README.md` still says the repo does not contain an active root frontend such as `index.html`, `app.js`, or `style.css`
- the current checkout does contain `index.html`, `app.js`, `style.css`, `manifest.json`, and `gofai_worker.js`
- `BROWSER_CONTRACT.md` explicitly treats those root files as required browser assets
- `tests/test_browser_smoke.py` serves those exact files and validates DOM/WebGL contracts against them
- `tests/test_index_html_integrity.py` assumes `index.html` is canonical and production-relevant
- `CLAUDE.md` says frontend code lives at repo root and explicitly warns against `public/nexus/`
- `INVESTIGATION_ISSUE_1145.md` explains why `public/nexus/` is a bad/corrupt duplicate path and confirms the real classical AI code lives in root `app.js`
The honest conclusion:
- The repo contains a partially restored or actively re-materialized browser surface
- The docs are preserving an older migration truth while the runtime files and smoke contracts describe a newer present-tense truth
- Any future work in `the-nexus` must choose one truth and align `README.md`, `CLAUDE.md`, smoke tests, and file layout around it
That drift is itself a critical architectural fact and should be treated as first-order design debt, not a side note.

View File

@@ -1,8 +1,8 @@
# NH Broadband Install Packet
**Packet ID:** nh-bb-20260415-113232
**Generated:** 2026-04-15T11:32:32.781304+00:00
**Status:** pending_scheduling_call
**Packet ID:** nh-bb-20260417-154500
**Generated:** 2026-04-17T15:45:00Z
**Status:** scheduled_install
## Contact
@@ -15,14 +15,46 @@
- 123 Example Lane
- Concord, NH 03301
## Desired Plan
## Availability
residential-fiber
- **Status:** available
- **Checked at:** 2026-04-17T15:45:00Z
- **Exact address confirmed:** yes
- **Notes:** Online availability lookup showed fiber service available at the exact cabin address.
## Pricing + Plan Recommendation
- **Recommended plan:** 1Gbps fiber
- **Monthly cost:** $79.95
- **Install fee:** $99.00
- **Notes:** 1Gbps chosen over 100Mbps because remote work + AI fleet uploads justify the higher tier.
## Installation Appointment
- **Scheduled:** yes
- **Date:** 2026-04-24
- **Window:** 08:00-12:00
- **Confirmation #: NHB-2026-0417**
## Installer Access Notes
- **Installer can reach cabin:** yes
- **Driveway note:** Driveway is gravel but passable for contractor van; call 30 minutes before arrival if mud is present.
- **Site contact:** 603-555-0142
## Payment
- **Method:** credit_card
- **First month due:** $79.95
- **Install fee due:** $99.00
- **Notes:** Card on file approved for first month plus install fee.
## Call Log
- **2026-04-15T14:30:00Z** — no_answer
- Called 1-800-NHBB-INFO, ring-out after 45s
- **2026-04-17T15:45:00Z** — scheduled
- Confirmed exact-address availability, selected 1Gbps, booked morning install window, and recorded confirmation number NHB-2026-0417.
## Appointment Checklist
@@ -34,4 +66,3 @@ residential-fiber
- [ ] Prepare site: clear path to ONT install location
- [ ] Post-install: run speed test (fast.com / speedtest.net)
- [ ] Log final speeds and appointment outcome

View File

@@ -11,10 +11,44 @@ service:
desired_plan: residential-fiber
availability:
status: available
checked_at: "2026-04-17T15:45:00Z"
exact_address_confirmed: true
notes: "Online availability lookup showed fiber service available at the exact cabin address."
pricing:
recommended_plan: 1Gbps fiber
monthly_cost_usd: 79.95
install_fee_usd: 99.0
notes: "1Gbps chosen over 100Mbps because remote work + AI fleet uploads justify the higher tier."
appointment:
scheduled: true
date: "2026-04-24"
window: "08:00-12:00"
confirmation_number: "NHB-2026-0417"
installer_access:
installer_can_reach_cabin: true
driveway_note: "Driveway is gravel but passable for contractor van; call 30 minutes before arrival if mud is present."
site_contact: "603-555-0142"
payment:
method: credit_card
first_month_due_usd: 79.95
install_fee_due_usd: 99.0
notes: "Card on file approved for first month plus install fee."
call_log:
- timestamp: "2026-04-15T14:30:00Z"
outcome: no_answer
notes: "Called 1-800-NHBB-INFO, ring-out after 45s"
- timestamp: "2026-04-17T15:45:00Z"
outcome: scheduled
notes: "Confirmed exact-address availability, selected 1Gbps, booked morning install window, and recorded confirmation number NHB-2026-0417."
speed_test: {}
checklist:
- "Confirm exact-address availability via NH Broadband online lookup"

View File

@@ -11,36 +11,74 @@ from typing import Any
import yaml
DEFAULT_CHECKLIST = [
"Confirm exact-address availability via NH Broadband online lookup",
"Call NH Broadband scheduling line (1-800-NHBB-INFO)",
"Select appointment window (morning/afternoon)",
"Confirm payment method (credit card / ACH)",
"Receive appointment confirmation number",
"Prepare site: clear path to ONT install location",
"Post-install: run speed test (fast.com / speedtest.net)",
"Log final speeds and appointment outcome",
]
def load_request(path: str | Path) -> dict[str, Any]:
data = yaml.safe_load(Path(path).read_text()) or {}
data.setdefault("contact", {})
data.setdefault("service", {})
data.setdefault("call_log", [])
data.setdefault("checklist", [])
data.setdefault("checklist", list(DEFAULT_CHECKLIST))
data.setdefault("availability", {})
data.setdefault("pricing", {})
data.setdefault("appointment", {})
data.setdefault("installer_access", {})
data.setdefault("payment", {})
data.setdefault("speed_test", {})
return data
def validate_request(data: dict[str, Any]) -> None:
contact = data.get("contact", {})
for field in ("name", "phone"):
if not contact.get(field, "").strip():
if not str(contact.get(field, "")).strip():
raise ValueError(f"contact.{field} is required")
service = data.get("service", {})
for field in ("address", "city", "state"):
if not service.get(field, "").strip():
if not str(service.get(field, "")).strip():
raise ValueError(f"service.{field} is required")
if not data.get("checklist"):
raise ValueError("checklist must contain at least one item")
def derive_status(data: dict[str, Any]) -> str:
availability = data.get("availability", {})
appointment = data.get("appointment", {})
speed_test = data.get("speed_test", {})
if str(availability.get("status", "")).strip().lower() == "unavailable":
return "blocked_unavailable"
if speed_test.get("tested_at") and speed_test.get("download_mbps") and speed_test.get("upload_mbps"):
return "post_install_verified"
if appointment.get("scheduled"):
return "scheduled_install"
return "pending_scheduling_call"
def build_packet(data: dict[str, Any]) -> dict[str, Any]:
validate_request(data)
contact = data["contact"]
service = data["service"]
availability = data.get("availability", {})
pricing = data.get("pricing", {})
appointment = data.get("appointment", {})
installer_access = data.get("installer_access", {})
payment = data.get("payment", {})
speed_test = data.get("speed_test", {})
return {
packet = {
"packet_id": f"nh-bb-{datetime.now(timezone.utc).strftime('%Y%m%d-%H%M%S')}",
"generated_utc": datetime.now(timezone.utc).isoformat(),
"contact": {
@@ -55,20 +93,76 @@ def build_packet(data: dict[str, Any]) -> dict[str, Any]:
"zip": service.get("zip", ""),
},
"desired_plan": data.get("desired_plan", "residential-fiber"),
"availability": {
"status": availability.get("status", "unknown"),
"checked_at": availability.get("checked_at", ""),
"notes": availability.get("notes", ""),
"exact_address_confirmed": bool(availability.get("exact_address_confirmed", False)),
},
"pricing": {
"recommended_plan": pricing.get("recommended_plan", data.get("desired_plan", "residential-fiber")),
"monthly_cost_usd": pricing.get("monthly_cost_usd"),
"install_fee_usd": pricing.get("install_fee_usd"),
"notes": pricing.get("notes", ""),
},
"appointment": {
"scheduled": bool(appointment.get("scheduled", False)),
"date": appointment.get("date", ""),
"window": appointment.get("window", ""),
"confirmation_number": appointment.get("confirmation_number", ""),
},
"installer_access": {
"installer_can_reach_cabin": bool(installer_access.get("installer_can_reach_cabin", False)),
"driveway_note": installer_access.get("driveway_note", ""),
"site_contact": installer_access.get("site_contact", contact["phone"]),
},
"payment": {
"method": payment.get("method", ""),
"first_month_due_usd": payment.get("first_month_due_usd"),
"install_fee_due_usd": payment.get("install_fee_due_usd"),
"notes": payment.get("notes", ""),
},
"speed_test": {
"tested_at": speed_test.get("tested_at", ""),
"download_mbps": speed_test.get("download_mbps"),
"upload_mbps": speed_test.get("upload_mbps"),
"provider": speed_test.get("provider", ""),
},
"call_log": data.get("call_log", []),
"checklist": [
{"item": item, "done": False} if isinstance(item, str) else item
for item in data["checklist"]
],
"status": "pending_scheduling_call",
}
packet["status"] = derive_status(packet)
return packet
def _money(value: Any) -> str:
if value in (None, ""):
return "n/a"
try:
return f"${float(value):.2f}"
except (TypeError, ValueError):
return str(value)
def _bool_label(value: bool) -> str:
return "yes" if value else "no"
def render_markdown(packet: dict[str, Any], data: dict[str, Any]) -> str:
contact = packet["contact"]
addr = packet["service_address"]
availability = packet["availability"]
pricing = packet["pricing"]
appointment = packet["appointment"]
installer_access = packet["installer_access"]
payment = packet["payment"]
speed_test = packet["speed_test"]
lines = [
f"# NH Broadband Install Packet",
"# NH Broadband Install Packet",
"",
f"**Packet ID:** {packet['packet_id']}",
f"**Generated:** {packet['generated_utc']}",
@@ -85,13 +179,44 @@ def render_markdown(packet: dict[str, Any], data: dict[str, Any]) -> str:
f"- {addr['address']}",
f"- {addr['city']}, {addr['state']} {addr['zip']}",
"",
f"## Desired Plan",
"## Availability",
"",
f"{packet['desired_plan']}",
f"- **Status:** {availability['status']}",
f"- **Checked at:** {availability['checked_at'] or 'pending'}",
f"- **Exact address confirmed:** {_bool_label(availability['exact_address_confirmed'])}",
f"- **Notes:** {availability['notes'] or 'pending live lookup'}",
"",
"## Pricing + Plan Recommendation",
"",
f"- **Recommended plan:** {pricing['recommended_plan']}",
f"- **Monthly cost:** {_money(pricing['monthly_cost_usd'])}",
f"- **Install fee:** {_money(pricing['install_fee_usd'])}",
f"- **Notes:** {pricing['notes'] or 'confirm on scheduling call'}",
"",
"## Installation Appointment",
"",
f"- **Scheduled:** {_bool_label(appointment['scheduled'])}",
f"- **Date:** {appointment['date'] or 'pending'}",
f"- **Window:** {appointment['window'] or 'pending'}",
f"- **Confirmation #: {appointment['confirmation_number'] or 'pending'}**",
"",
"## Installer Access Notes",
"",
f"- **Installer can reach cabin:** {_bool_label(installer_access['installer_can_reach_cabin'])}",
f"- **Driveway note:** {installer_access['driveway_note'] or 'pending'}",
f"- **Site contact:** {installer_access['site_contact'] or contact['phone']}",
"",
"## Payment",
"",
f"- **Method:** {payment['method'] or 'pending'}",
f"- **First month due:** {_money(payment['first_month_due_usd'])}",
f"- **Install fee due:** {_money(payment['install_fee_due_usd'])}",
f"- **Notes:** {payment['notes'] or 'confirm on scheduling call'}",
"",
"## Call Log",
"",
]
if packet["call_log"]:
for entry in packet["call_log"]:
ts = entry.get("timestamp", "n/a")
@@ -112,6 +237,17 @@ def render_markdown(packet: dict[str, Any], data: dict[str, Any]) -> str:
mark = "x" if item.get("done") else " "
lines.append(f"- [{mark}] {item['item']}")
if speed_test.get("tested_at") or speed_test.get("download_mbps") or speed_test.get("upload_mbps"):
lines.extend([
"",
"## Post-install Speed Test",
"",
f"- **Tested at:** {speed_test['tested_at'] or 'pending'}",
f"- **Download:** {speed_test['download_mbps'] or 'pending'} Mbps",
f"- **Upload:** {speed_test['upload_mbps'] or 'pending'} Mbps",
f"- **Provider:** {speed_test['provider'] or 'pending'}",
])
lines.append("")
return "\n".join(lines)

View File

@@ -32,11 +32,45 @@ def test_load_and_build_packet() -> None:
assert packet["contact"]["name"] == "Timmy Operator"
assert packet["service_address"]["city"] == "Concord"
assert packet["service_address"]["state"] == "NH"
assert packet["status"] == "pending_scheduling_call"
assert packet["availability"]["status"] == "available"
assert packet["appointment"]["scheduled"] is True
assert packet["pricing"]["monthly_cost_usd"] == 79.95
assert packet["installer_access"]["installer_can_reach_cabin"] is True
assert packet["payment"]["method"] == "credit_card"
assert packet["status"] == "scheduled_install"
assert len(packet["checklist"]) == 8
assert packet["checklist"][0]["done"] is False
def test_build_packet_marks_blocked_when_availability_fails() -> None:
data = load_request("docs/nh-broadband-install-request.example.yaml")
data["availability"] = {
"status": "unavailable",
"checked_at": "2026-04-17T16:00:00Z",
"notes": "Address lookup returned no fiber service.",
}
data["appointment"] = {}
data["speed_test"] = {}
packet = build_packet(data)
assert packet["status"] == "blocked_unavailable"
def test_build_packet_marks_post_install_verified_when_speed_test_present() -> None:
data = load_request("docs/nh-broadband-install-request.example.yaml")
data["speed_test"] = {
"tested_at": "2026-05-01T18:30:00Z",
"download_mbps": 942.6,
"upload_mbps": 881.4,
"provider": "fast.com",
}
packet = build_packet(data)
assert packet["status"] == "post_install_verified"
def test_validate_rejects_missing_contact_name() -> None:
data = {
"contact": {"name": "", "phone": "555"},
@@ -86,6 +120,11 @@ def test_render_markdown_contains_key_sections() -> None:
assert "# NH Broadband Install Packet" in md
assert "## Contact" in md
assert "## Service Address" in md
assert "## Availability" in md
assert "## Pricing + Plan Recommendation" in md
assert "## Installation Appointment" in md
assert "## Installer Access Notes" in md
assert "## Payment" in md
assert "## Call Log" in md
assert "## Appointment Checklist" in md
assert "Concord" in md
@@ -97,6 +136,8 @@ def test_render_markdown_shows_checklist_items() -> None:
packet = build_packet(data)
md = render_markdown(packet, data)
assert "- [ ] Confirm exact-address availability" in md
assert "Installer can reach cabin" in md
assert "- **Confirmation #: NHB-2026-0417**" in md
def test_example_yaml_is_valid() -> None: