Skip to content

Commit 7ebf0fd

Browse files
Tech-debt remediation: lib/bin split + D1–D5 resolved (#37)
* fix(gossamer): Week 1 tech-debt — wire dead registry/settings/resources cmds, drop speculative scaffolding D1: service registry is a fixed env-driven set; wire service_list (get_registry) + service_set_url (update_service_url); remove vestigial register/unregister command stubs (no backing fns). D2: wire settings_save + llm_coding_system_resources (read_system_memory + SystemResources + new CPU sampler); remove unused WorkspaceLock, PendingAction, SpawnRequest.task_list. clippy -D warnings clean. D5: rewrite TECHNICAL_DEBT.md as verified 30-day plan; fix arch link. Also de-Tauri'd llm_coding/commands.rs header (Gossamer). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(coprocessor): Week 2 — real Zig FFI dynamic loading (D4) Add libloading 0.8 dep (once_cell already present). FfiState now owns the loaded libloading::Library; copro_load_ffi does a real dlopen + copro_init; copro_ffi_dispatch resolves copro_dispatch/copro_free from the live handle and calls the C ABI (was a stub). Symbols resolved per-call (no self-referential 'static storage). De-Tauri'd coprocessor comments. Removed stale libloading/once_cell TODOs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor: lib/bin split — testable logic crate; wire orphaned coprocessor (D3) Add [lib] panll target (GTK-free): http_client, service_registry, settings, identity, groove, llm_coding + the previously-orphaned coprocessor (declared by no crate root → never compiled; D4's FFI fix now actually builds and is tested). main.rs keeps only system_tray (gossamer_rs/GTK) and imports the rest via use panll::*. cargo test --lib now runs WITHOUT linking libgossamer/GTK: 18/18 pass (6 new D3 tests for http_client + service_registry, 12 coprocessor). Cleared 11 latent clippy lints surfaced once coprocessor compiled (10 empty-line-after-doc, 1 should_implement_trait — justified allow). clippy --all-targets -D warnings clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: Week 4 — hardening, hypatia reconcile, changelog, doc finalize (W4) - Fold cross-module integration tests into the lib test surface so they run via cargo test --lib (no GTK bin build): 23/23 pass. - Reconcile .github/hypatia-rules/panll-v0.2.0-fixes.yml v1->v2: retire 8 stale panic-attack rules that false-positive on now-correct code; keep one precise regression guard (panll-cmd-disabled); fix doc-ref path. - CHANGELOG.md: document lib/bin split, coprocessor wiring, add/remove/fix. - TECHNICAL_DEBT.md: mark D1-D5 resolved with execution log; record honest environment caveat (bin link needs GTK) and follow-up debt F1 (40 orphaned dirs) / F2 (coprocessor IPC wiring) / F3 (dev env). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs: correct F1 — 38 orphaned dirs are unwired panel backends, not dead code Inspection showed every 'orphan' dir is a real PanLL panel backend (aerie/hypatia/ai/farm/provenance/…), orphaned by the same defect as coprocessor. Decision: integrate, not delete. Added F1 integration workstream plan (coprocessor pilot → census → bulk wire). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 75a213e commit 7ebf0fd

13 files changed

Lines changed: 598 additions & 588 deletions

File tree

Lines changed: 51 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -1,230 +1,77 @@
1-
# Hypatia Scanner Rules for PanLL v0.2.0 Fixes
2-
#
3-
# These rules detect and remediate common issues found during the v0.2.0 panic attack
4-
# Rules are designed to work with the gitbot fleet for automated repository maintenance
1+
# Hypatia Scanner Rules for PanLL — tech-debt regression guards
2+
#
3+
# Reconciled 2026-05-17 against the verified tree (see docs/TECHNICAL_DEBT.md).
4+
#
5+
# The original v0.2.0 "panic attack" rule set (panll-001..008) was retired:
6+
# every issue it described is resolved, and its patterns generate false
7+
# positives against now-correct code — e.g. it flagged the valid
8+
# `use crate::http_client;`, every `-> String` function, and every
9+
# `unwrap_or_else(|_| "http://localhost:…")` env fallback. Detecting
10+
# resolved problems against correct code is worse than no rule.
11+
#
12+
# What replaces it: a single, precise regression guard for the one failure
13+
# mode that actually recurred (commands disabled by commenting them out to
14+
# force compilation), plus clippy `-D warnings` in CI for everything the
15+
# old rules tried to approximate (PathBuf misuse, unused doc comments,
16+
# result-type shape, error handling).
17+
18+
version: "2.0"
519

6-
version: "1.0"
720
rules:
8-
# Rule 1: Detect unresolved http_client imports
9-
- id: "panll-001"
10-
name: "Unresolved http_client Import"
11-
description: "Detects unresolved crate::http_client imports that need proper module implementation"
21+
# Regression guard for D1: during the panic attack, IPC command handlers
22+
# were commented out wholesale to make the crate compile. That is the
23+
# specific, recurring pattern worth catching — not "any commented code".
24+
- id: "panll-cmd-disabled"
25+
name: "Commented-out IPC command registration"
26+
description: >
27+
A `app.command("…")` registration that has been commented out.
28+
This is how functionality was silently dropped to force a build;
29+
re-enable it or delete the dead handler and its backing fn.
1230
severity: "high"
1331
patterns:
14-
- pattern: "use crate::http_client;"
15-
- pattern: "use crate::http_client::"
16-
remediation:
17-
action: "comment"
18-
message: "Unresolved http_client import detected. Ensure http_client module exists or implement proper HTTP client infrastructure."
19-
suggestions:
20-
- "Create http_client.rs module with reqwest-based implementation"
21-
- "Add proper ServiceEndpoint struct and HTTP methods"
22-
- "Ensure module is properly exported in lib.rs"
23-
tags: ["import", "module", "http"]
24-
25-
# Rule 2: Detect commented-out modules that should be implemented
26-
- id: "panll-002"
27-
name: "Commented Out Modules"
28-
description: "Identifies modules commented out during panic attack that need implementation"
29-
severity: "medium"
30-
patterns:
31-
- pattern: "// mod (\w+);"
32-
- pattern: "// \w+::"
32+
- pattern: '^\s*//\s*app\.command\('
3333
remediation:
3434
action: "ticket"
35-
message: "Commented out module detected. This module was disabled during panic attack and needs implementation."
36-
suggestions:
37-
- "Implement the module or remove references completely"
38-
- "Update documentation to reflect module status"
39-
- "Add to technical debt backlog"
40-
tags: ["module", "technical-debt", "implementation"]
41-
42-
# Rule 3: Detect improper App handling in Gossamer
43-
- id: "panll-003"
44-
name: "Improper Gossamer App Handling"
45-
description: "Detects incorrect handling of Result<App, Error> types in Gossamer commands"
46-
severity: "high"
47-
patterns:
48-
- pattern: "register_commands(&mut app);"
49-
- pattern: "system_tray::init(&app);"
50-
- pattern: "app\.run\(\);"
51-
context:
52-
- "where app is Result<App, Error>"
53-
remediation:
54-
action: "suggest"
55-
message: "Improper App handling detected. App should be unwrapped or handled as Result before use."
56-
suggestions:
57-
- "Use if let Ok(ref mut app_ok) = app { ... } pattern"
58-
- "Properly handle the Result type before passing to functions"
59-
- "Add error handling for App initialization failures"
60-
tags: ["gossamer", "error-handling", "app"]
61-
62-
# Rule 4: Detect PathBuf Display trait issues
63-
- id: "panll-004"
64-
name: "PathBuf Display Trait Misuse"
65-
description: "Identifies incorrect usage of PathBuf with Display trait"
66-
severity: "high"
67-
patterns:
68-
- pattern: "\.to_string\(\)"
69-
- pattern: "format!\("{}", .*\)"
70-
context:
71-
- "where type is PathBuf or Path"
72-
remediation:
73-
action: "replace"
74-
message: "PathBuf cannot be directly converted to String. Use to_str() or display() method."
75-
suggestions:
76-
- "Use path.to_str().unwrap_or(\"\") for string conversion"
77-
- "Use path.display() for display formatting"
78-
- "Handle potential invalid Unicode paths"
79-
tags: ["path", "filesystem", "display"]
80-
81-
# Rule 5: Detect result type mismatches in commands
82-
- id: "panll-005"
83-
name: "Command Result Type Mismatch"
84-
description: "Detects functions returning String when Result<Value, String> is expected"
85-
severity: "high"
86-
patterns:
87-
- pattern: "result_to_json\(.*\)"
88-
- pattern: "-> String"
89-
context:
90-
- "in command handlers"
91-
- "where return type should be Result<Value, String>"
92-
remediation:
93-
action: "replace"
94-
message: "Command should return Result<Value, String> but returns String. Wrap in proper Result type."
95-
suggestions:
96-
- "Wrap return value in Ok(): Ok(result_to_json(...))"
97-
- "Handle errors properly with Err() variant"
98-
- "Ensure all command handlers follow consistent return type pattern"
99-
tags: ["command", "result", "type-safety"]
100-
101-
# Rule 6: Detect unused doc comments
102-
- id: "panll-006"
103-
name: "Unused Documentation Comments"
104-
description: "Identifies doc comments that are not attached to any item"
105-
severity: "low"
106-
patterns:
107-
- pattern: "///.*"
108-
- pattern: "/\*\*.*\*\/"
109-
context:
110-
- "not followed by item declaration"
111-
- "in commented out sections"
112-
remediation:
113-
action: "cleanup"
114-
message: "Unused documentation comment detected. Either attach to item or remove."
115-
suggestions:
116-
- "Remove comment if no longer relevant"
117-
- "Attach to proper item if documentation is needed"
118-
- "Update comment to reflect current code state"
119-
tags: ["documentation", "cleanup", "style"]
120-
121-
# Rule 7: Detect hardcoded service URLs
122-
- id: "panll-007"
123-
name: "Hardcoded Service URLs"
124-
description: "Identifies hardcoded service URLs that should use configuration"
125-
severity: "medium"
126-
patterns:
127-
- pattern: "http://localhost:[0-9]+"
128-
- pattern: "localhost:[0-9]+"
129-
remediation:
130-
action: "configurize"
131-
message: "Hardcoded service URL detected. Should use configuration or environment variables."
132-
suggestions:
133-
- "Use std::env::var() with fallback"
134-
- "Add to service registry configuration"
135-
- "Make configurable via settings panel"
136-
tags: ["configuration", "hardcoding", "best-practice"]
137-
138-
# Rule 8: Detect improper error handling in commands
139-
- id: "panll-008"
140-
name: "Improper Command Error Handling"
141-
description: "Identifies command handlers that don't properly handle errors"
142-
severity: "high"
143-
patterns:
144-
- pattern: "\.map_err\(.*\)\?"
145-
- pattern: "\.unwrap\(\)"
146-
- pattern: "\.expect\("""
147-
context:
148-
- "in command handler functions"
149-
remediation:
150-
action: "refactor"
151-
message: "Improper error handling in command. Should use proper Result propagation."
35+
message: >
36+
Disabled IPC command detected. Either re-enable it (and its backing
37+
function) or remove both plus any now-dead support code. Do not leave
38+
commented command handlers in tree.
15239
suggestions:
153-
- "Use ? operator for proper error propagation"
154-
- "Return Err(e.to_string()) for command failures"
155-
- "Avoid unwrap() and expect() in production code"
156-
tags: ["error-handling", "command", "robustness"]
40+
- "Re-enable the command and wire its backing function"
41+
- "If intentionally removed, delete the handler AND the dead backing fn"
42+
- "Record the decision in docs/TECHNICAL_DEBT.md"
43+
tags: ["command", "regression", "technical-debt"]
15744

158-
# Remediation Patterns
159-
remediation_patterns:
160-
- id: "result-wrapper"
161-
name: "Wrap in Result"
162-
description: "Standard pattern for wrapping command results"
163-
pattern: |
164-
// Before
165-
result_to_json(function_call())
166-
167-
// After
168-
Ok(result_to_json(function_call()))
169-
170-
- id: "path-conversion"
171-
name: "Safe Path Conversion"
172-
description: "Standard pattern for PathBuf to string conversion"
173-
pattern: |
174-
// Before
175-
let path_str = path.to_string();
176-
177-
// After
178-
let path_str = path.to_str().unwrap_or("");
179-
180-
- id: "app-handling"
181-
name: "Proper App Handling"
182-
description: "Standard pattern for handling Result<App, Error>"
183-
pattern: |
184-
// Before
185-
register_commands(&mut app);
186-
app.run();
187-
188-
// After
189-
if let Ok(ref mut app_ok) = app {
190-
register_commands(app_ok);
191-
app_ok.run();
192-
}
45+
# Everything the retired rules approximated is now enforced by the compiler
46+
# and clippy in CI, which is precise where regex patterns were not:
47+
quality_gate:
48+
command: "cargo clippy --all-targets --all-features -- -D warnings"
49+
covers:
50+
- "PathBuf/Display misuse (was panll-004) — rustc type errors"
51+
- "unused / detached doc comments (was panll-006) — clippy::empty_line_after_doc_comments"
52+
- "command result-type shape (was panll-005) — rustc type checking of result_to_json"
53+
- "error handling (was panll-008) — clippy lints, reviewed per-call"
54+
unit_tests: "cargo test --lib # GTK-free; see lib/bin split"
19355

194-
# Scanner Configuration
19556
scanner:
19657
exclude:
19758
- "**/tests/*"
19859
- "**/benches/*"
19960
- "**/examples/*"
20061
- "**/target/*"
20162
- "**/node_modules/*"
202-
20363
include:
204-
- "**/src/**/*.rs"
20564
- "**/src-gossamer/**/*.rs"
20665

207-
# GitBot Fleet Configuration
20866
gitbot:
209-
auto_remediate:
210-
- "panll-004" # PathBuf Display issues
211-
- "panll-006" # Unused doc comments
212-
- "panll-007" # Hardcoded URLs
213-
21467
create_ticket:
215-
- "panll-001" # http_client implementation needed
216-
- "panll-002" # Commented out modules
217-
- "panll-003" # App handling issues
218-
- "panll-005" # Result type mismatches
219-
- "panll-008" # Error handling issues
220-
68+
- "panll-cmd-disabled"
22169
notification:
222-
teams: ["backend", "devops", "qa"]
223-
severity_threshold: "medium"
70+
teams: ["backend"]
71+
severity_threshold: "high"
22472

225-
# Documentation References
22673
documentation:
22774
technical_debt: "docs/TECHNICAL_DEBT.md"
228-
architecture: "docs/ARCHITECTURE.md"
75+
architecture: "docs/architecture/ARCHITECTURE.md"
22976
contribution: "CONTRIBUTING.md"
230-
code_of_conduct: "CODE_OF_CONDUCT.md"
77+
code_of_conduct: "CODE_OF_CONDUCT.md"

CHANGELOG.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
### Added (2026-05-11 — Harness schema: Binary Star architecture declaration)
11-
- **`binary_star` object in panll-harness-v2 schema** — panels can now declare
12-
their relationship to the Binary Star architecture (panes A/L/N/W) via
13-
four optional fields:
14-
- `spans` — panes the panel inhabits (primary state or computation)
15-
- `flow` — ordered sequence describing data/control movement
16-
- `surfaces_in` — panes where outputs become visible to other panels
17-
- `perspective` — vantage point (canonical: observer, meta-observer, actor,
18-
sensor, transformer)
10+
### Changed (2026-05-17 — Tech-debt remediation: lib/bin split)
11+
- **`[lib] panll` crate extracted** — all GTK-free backend logic
12+
(`http_client`, `service_registry`, `settings`, `identity`, `groove`,
13+
`llm_coding`, `coprocessor`) moved into a library crate. `main.rs` keeps
14+
only `system_tray` (depends on `gossamer_rs`). `cargo test --lib` now runs
15+
the unit suite (23 tests) without linking libgossamer/GTK/WebKit.
16+
- **`coprocessor` wired into the build** — it was orphaned (declared by no
17+
crate root, never compiled). Now part of the lib, with real Zig FFI
18+
dynamic loading via `libloading 0.8` (`dlopen` + `copro_init`,
19+
`copro_dispatch`/`copro_free`), replacing the previous no-op stubs.
1920

20-
Backward compatible: all fields optional, existing valid v2 manifests remain
21-
valid. Unblocks `hyperpolymath/hypatia#197` and `hyperpolymath/hypatia#177`.
21+
### Added (2026-05-17)
22+
- Service-registry runtime reconfiguration: `service_list` and
23+
`service_set_url` IPC commands; `settings_save` (bulk replace);
24+
`llm_coding_system_resources` (host memory + `/proc/stat` CPU sampler).
25+
- Unit + integration tests for `http_client`, `service_registry`,
26+
`llm_coding`, `coprocessor`.
27+
28+
### Removed (2026-05-17)
29+
- Speculative, never-referenced scaffolding: `WorkspaceLock`,
30+
`PendingAction`, `SpawnRequest.task_list`, and the vestigial
31+
`service_register`/`service_unregister` command stubs.
32+
- Stale Tauri references in `coprocessor`/`llm_coding` comments.
33+
34+
### Fixed (2026-05-17)
35+
- `docs/TECHNICAL_DEBT.md` rewritten from a stale 2024-dated placeholder
36+
document into a verified, executed plan; broken `docs/ARCHITECTURE.md`
37+
link repointed to `docs/architecture/ARCHITECTURE.md`.
38+
- `.github/hypatia-rules/panll-v0.2.0-fixes.yml` reconciled (v1 → v2):
39+
retired 8 false-positive panic-attack rules, kept one precise regression
40+
guard for disabled IPC commands.
2241

2342
### Fixed (2024-04-15 — v0.2.0 Panic Attack Remediation)
2443
- **Critical Build Issues** — Resolved 37 compilation errors and warnings during panic attack:

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ edition = "2021"
2020
license = "PMPL-1.0-or-later"
2121
repository = "https://github.com/hyperpolymath/panll"
2222

23+
# Testable logic library — GTK/WebKit-free. `cargo test --lib` runs without
24+
# linking libgossamer or the GTK/WebKit stack. The bin depends on this lib.
25+
[lib]
26+
name = "panll"
27+
path = "src-gossamer/src/lib.rs"
28+
2329
[[bin]]
2430
name = "panll-gossamer"
2531
path = "src-gossamer/src/main.rs"
@@ -55,6 +61,9 @@ libc = "0.2"
5561
which = "7"
5662
uuid = { version = "1.22.0", features = ["v4"] }
5763

64+
# Dynamic loading of the Zig coprocessor FFI shared library (Phase 2 data plane)
65+
libloading = "0.8"
66+
5867
[dev-dependencies]
5968
tokio = { version = "1", features = ["macros", "rt"] }
6069

0 commit comments

Comments
 (0)