2 Commits
Author SHA1 Message Date
PiersandClaude Opus 4.7 b3a5f23450 DD-338 Phase E.python — depend on stallari-mcp-helpers (delete local helpers)
Pure substrate swap. Local `domain_hint.py` (155 LOC) deleted; canonical
`Pattern`, `compute_domain_hint`, `load_patterns_from_yaml` are now imported
from `stallari-mcp-helpers>=0.1.0,<1.0.0`. Local `meta_envelope` +
`append_meta` helpers in `formatters.py` deleted; canonical implementations
re-exported from the lib for backward call-site compatibility.

Surfaced two API divergences vs the spec's "names stay identical" assumption:

1. The lib's `append_meta(body, meta_line)` takes a pre-built meta line; the
   prior blade-local `append_meta(payload, **kwargs)` built the envelope
   internally. All 11 call-sites in `tools/folders.py` (8), `tools/devices.py`
   (1), `tools/instances.py` (1), `tools/system.py` (1) refactored to the
   two-step `append_meta(payload, meta_envelope(...))` pattern.

2. The lib's `compute_domain_hint(record, patterns)` takes 2 args and uses
   built-in dot-path field resolution; the prior blade-local
   `compute_domain_hint(record, patterns, projector)` took a per-blade
   projector callable. The flat record shapes this blade emits (folders +
   devices) resolve identically under either approach. The blade's
   `_syncthing_field_projector` was removed (was only used as the 3rd arg).

Wire-shape change (test fixtures updated for 2 sites):
- `_meta` field order now follows lib convention (matched_total, returned,
  latency_ms, filtered_by, redactions, next_cursor, error_notes?,
  domain_hints?). Prior local helper emitted latency_ms last.
- `_meta.next_cursor` is now always present (defaults to `null`). Tests
  pinning "next_cursor not in meta" updated to "next_cursor is None".
- `_meta.redactions`, `filtered_by`, `error_notes?`, `domain_hints?` all
  unchanged in conditional-inclusion semantics.

Pure substrate swap — no behavioural change to any tool. Pack-spec catalog
declarations unchanged.

Version: 0.7.0 → 0.8.0.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 09:38:46 +10:00
PiersandClaude Opus 4.7 06217b6fdc DD-338 A.2.dom.c — domain_hint patterns + per-record _meta.domain_hints
New per-blade lib (src/syncthing_mcp/domain_hint.py, ~155 LOC) implementing
the shared DD-338 Pattern engine: equals / contains / glob ops, first-match-
wins, YAML pattern loading with graceful degradation (Convention #22).

Server module gains a BladeConfigStore reader honouring STALLARI_STATE_ROOT
override + the sanitized blade-id directory layout the Swift writer ships
(Convention #23 reader-side compliance), plus a polymorphic Syncthing field
projector covering both folder records (id/label/path/type) and device
records (deviceID/name/addresses).

Wired into the two list-returning read tools:
  - syncthing_list_folders (instances.py — newly gains _meta envelope; was
    previously bare fmt(); start time now tracked for latency_ms)
  - syncthing_list_devices (devices.py — extends existing envelope with
    domain_hints kwarg)

formatters.{meta_envelope,append_meta} extended with an optional
domain_hints kwarg; key omitted from the JSON tail when empty / None.

stallari-plugin.yaml gains a blade_domain_hint_patterns: { patterns: [] }
block (0 defaults; users layer their own via the Settings → Blade Domain
Hints editor). No tools[] block exists in this manifest — per-tool
domain_scope flips land in the catalog mirror at stallari-plugins/plugins/
in a separate parent-session action.

pyyaml>=6.0 added to runtime dependencies (gated by ImportError inside
load_patterns_from_yaml so the blade still boots if the wheel is absent).
Version bump 0.5.0 → 0.6.0 (minor — new substrate capability).

Tests: 13 new cases in tests/test_domain_hint.py covering empty-patterns,
folder+device matches, first-match-wins, glob wildcards, unknown-field
projector handoff, YAML well-formed / partial / malformed / non-mapping
root / missing-patterns-key. Full suite 133/133 green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-23 12:46:47 +10:00