Commit Graph
18 Commits
Author SHA1 Message Date
UKMesh Readiness 3a6b2a2be8 Select tagger keys and fold duplicate checks into authorization 2026-11-28 13:22:42 +00:00
gadgethd eab389c387 Merge current main into ukmesh-dev
Adapt main fixes to DEV ownership of split MQTT intake, private projections, lean Compose, and on-demand charts. Preserve deployed migration identities and standalone owner sessions.
2026-11-27 20:21:28 +00:00
hermes-gadget 8e091a41a0 feat(tagger): local UKMesh tagger backend with TypeSafe/Jev fallback (#253)
* feat(tagger): local UKMesh tagger backend with TypeSafe/Jev fallback

Port of the tagger that has been running in production from the deployment
tree but existed in no commit: it was an uncommitted local modification on
the UKMesh VPS, so any deploy from origin/main would have silently reverted
tagging to the TypeSafe cloud call.

Changes carried over verbatim from the deployed tree:

- `TAGGER_BACKEND` selects the backend: `local` (default) calls the UKMesh
  tagger (`ukmesh-tagger/run-base4`) on the pinned GPU lane through the GPU
  gateway; `jev` keeps the original TypeSafe call as a rollback lever.
- Local responses are reshaped into the same `answers` structure `flatten()`
  already consumes, so tag storage is unchanged.
- `TAGGER_URL` / `TAGGER_MODEL_ID` / `TAGGER_API_KEY` (or
  `TAGGER_API_KEY_FILE`) configure the local endpoint; startup fails loudly
  when the selected backend has no key instead of silently tagging nothing.
- Every `message_tags` reference is qualified as `mesh.message_tags`, matching
  the schema move (migration 078). Unqualified references depended on the
  connection search_path.
- `api_tag()` now takes `(sender, message)` and builds the state string itself.

`docker-compose.yml` passes the four `TAGGER_*` variables through to the
tagger-worker service with the same defaults the deployment uses.

Verified: `python3 -m py_compile` clean; `docker compose config -q` clean;
`test_tagger_candidates.py` collects (8 skipped without a database).

* test(tagger): fixture mirrors the deployed schema (mesh.message_tags)

The candidate-paging fixture built `public.message_tags`, which is exactly the
stale duplicate the qualified worker exists to stop writing to. Migration 121
moved the table to `mesh`; the fixture now creates `mesh.message_tags` and
addresses it fully qualified, so the test asserts the real target instead of
the compatibility name.

* test(tagger): follow api_tag's (sender, message) signature in the revocation case

api_tag now takes the message parts rather than a pre-rendered state string, so
the side_effect stub must accept two arguments. Passing one raised TypeError
instead of the intended RuntimeError and the assertion read as a tagging bug.
2026-11-18 02:03:06 +00:00
Codex 634c29ca28 Keep tagger startup within its migrated database permissions 2026-11-14 03:00:40 +00:00
Codex 0a4c79d91d refactor(workers): own runtime contexts and isolate graph generations 2026-11-12 19:18:42 +00:00
Codex b5c5b6d8ef chore(release): prepare 2.0 candidate identity and upgrade notes 2026-11-12 10:28:32 +00:00
ben 1a351dd3ef refactor(tagger): remove the duplicate inline tagging retry loop
The main loop reimplemented tag_message's three-attempt fetch/insert path.
tag_message now reports tagged/skipped/failed and owns insertion, so one
retry policy covers both fresh messages and the retry queue.
2026-11-12 01:51:36 +00:00
hermes-gadgetandhermes-gadget 3884bc54a0 test: repair post-move integration fixtures and gate map visibility (#217)
* test(privacy): run the convergence suite at head again

The suite could not execute after the P1 move band, so its own fixtures had
gone stale rather than failing loudly:

* the read-only role was granted only on public, where the product tables are
  now compatibility views over mesh/core/analytics/ops;
* the 066 rollback no longer runs because 134 re-asserts 074's row triggers on
  the same function, so rolling the fence back at head has to remove those
  first and re-apply both migrations;
* two LOCK TABLE probes still matched the pre-move spelling, so the writer they
  gate never committed and the case under test degraded into a 5s lock timeout;
* the missing-materialization probe renamed an ops table back through an
  invalid schema-qualified RENAME TO.

All 17 subtests pass on a throwaway TimescaleDB 16.

* ci: point the smoke stack at the consolidated owner-auth tables

Owner-auth was consolidated into the primary database; 073 creates core.owner_*
there, and the separate legacy owner database is provisioned by
scripts/newuser.sh on a real deployment. The empty-volume smoke stack has no
such database, so the backend died at startup with
`database "meshcore_owner_auth" does not exist` and took the Workers and
Compose job down with it.

* test: use the shared fresh-deployment fixture in the remaining suites

Four suites still seeded `base.sql` by hand and then replayed the band without
the documented bootstrap approval, which #202's ledger guard refuses — the
runtime gate in `Backend` died on exactly that. They now use the same helper
the ingest suites do, and address the post-move namespaces.

* ram/runtime (F15/F16 SIGTERM gate): 1/1 on a throwaway TimescaleDB
* db/regionScoping: 1/1
* ws/regionScoping: 1/1
* db/silentRecovery: the fixture runs now, and it exposes a separate product
  question — abandoned privacy claims are not dead-lettered, so it is left
  failing and tracked rather than papered over.

tsc clean.

* ci: interpolate the owner database at the primary database for the smoke stack

The previous attempt set OWNER_POSTGRES_DB on the backend service, but
docker-compose.yml builds OWNER_DATABASE_URL from that variable at compose
interpolation time, so a service-level value arrives too late. Set it in the
job env instead: compose then renders
`postgresql://meshcore:***@timescaledb:5432/meshcore`, where 073 has created
core.owner_accounts / core.owner_account_nodes / core.mqtt_node_logins.

Verified with `docker compose config`: the rendered OWNER_DATABASE_URL points
at /meshcore. Production still sets its own OWNER_DATABASE_URL in .env.

* test(tagger): build the post-move schema in the candidate fixture

The tagger-worker suite creates its own scratch database and used to declare
every relation in `public`. The product SQL now names `ops.tagger_retry`,
`ops.public_visibility_state`, `ops.packet_visibility_materialization_state`
and `ops.privacy_rematerialization_queue` in full, and reaches `packets` /
`message_tags` through the post-move search_path, so the fixture produced
`relation "ops.packet_visibility_materialization_state" does not exist` on all
eight cases.

The fixture now creates `mesh`/`core`/`analytics`/`ops` and connects with
`-c search_path=mesh,core,analytics,ops,public`, mirroring the deployment.

Verified 8/8 inside the CI tagger image against the compose stack's database.

* ci: qualify the E2E readback against the post-move namespaces

The observer round-trip check read `nodes`, `packets`, `packet_paths` and
`packet_hourly_stats` unqualified. `public` keeps compatibility views for the
first three but not for the hourly rollup, which moved to `mesh`, so the
readback failed with `relation "packet_hourly_stats" does not exist`.

* test: keep the unwired silent-recovery suite out of this CI fix

---------

Co-authored-by: hermes-gadget <hermes-gadget@users.noreply.github.com>
2026-11-05 23:12:14 +00:00
hermes-gadget ec7fdfd452 ci: unblock the empty-volume smoke stack and its post-move browser fixtures (#220)
* ci: create the owner-auth database in the smoke stack

The backend derives its owner connection from DATABASE_URL with the database
name swapped for meshcore_owner_auth, and dies at startup when that database is
absent. Production creates it out of band (newuser.sh, restore-drill.sh); a
fresh CI volume never did, so 'Build every application image and smoke an
empty-volume stack' failed with 'database meshcore_owner_auth does not exist'.

Mirror production: an init-hook script creates the database and applies the
shipped owner-auth.sql to it. The SQL is mounted outside initdb so it is not
applied to the main database as well.

* test(tagger): build the fixture in the post-move ops namespace

The suite creates its own database and then runs the worker's real poll SQL,
which reads ops.public_visibility_state, ops.packet_visibility_materialization_state,
ops.privacy_rematerialization_queue and ops.tagger_retry since the P1 moves.
The fixture still created those tables in public, so all eight tests failed with
'relation "ops.packet_visibility_materialization_state" does not exist'.

This was masked until now: the smoke stack never got past backend startup, so
this step never ran. packets and message_tags stay unqualified - the worker
resolves those through the connection search_path, as the deployed P1
search_path does.

Verified against a disposable TimescaleDB with the same invocation CI uses:
8 tests, OK.

* ci: read the smoke-stack assertions from the post-move schemas

The empty-volume smoke readback still queried nodes, packets, packet_paths and
packet_hourly_stats by their pre-move public names. 116/123/124/125 moved them to
core and mesh, so the psql step failed with 'relation "packet_hourly_stats" does
not exist' once the stack got far enough to run it.

Use the canonical names; the public spellings are compatibility views at best and
for two of these relations no longer exist.

* test(e2e): warm the MapLibre module graph during setup

maplibre-gl is excluded from optimizeDeps because Vite's pre-bundling
rewrites the worker URL and kills it, so the first cold request pays for
transforming the whole module graph. On the CI runner that is 41-47s for
maplibre-gl-worker.mjs (measured from the retained traces on run
41887037964), which is most of the 60s map-health budget in the map specs:
the map starts ~57s after the document load and the assertion expires just
before the basemap turns healthy.

Playwright starts webServer before globalSetup, so warm the two heaviest
dev-server modules there. The cost moves into setup; assertions stay tight.
Failures are logged and ignored - this is never a gate.

Fixes #190

* test(e2e): log module warm-up response shape

The CI warm-up reported 200/116ms, but the browser still waited 47.8s for the
worker module and the map stayed loading. Log Content-Length and Content-Type
for each warm-up response so we can distinguish the transformed worker from a
fast SPA fallback before changing the fix.
2026-11-05 21:57:57 +00:00
hermes-gadget a2ae0c798b p1: qualify tagger state for ops 2026-11-03 00:18:03 +00:00
hermes-gadget 51d5b02552 p1: qualify tagger visibility state for ops 2026-11-03 00:11:21 +00:00
gadgethd 36f3741b74 Reconcile audited performance and correctness fixes with current main 2026-11-01 14:33:49 +00:00
gadgethd 078b417c49 Merge release/security-20261025; reconcile 61 conflicts and 19 findings
Port security remediation onto the newer main/VPS behavior. Preserve applied
migration names using exact checksum proof; retain durable ingest, egress,
worker recovery, telemetry normalization and newer main operational fixes.

Ledger: docs/reviews/20261025-merge-ledger.md
Validation: backend tsc/build; 708 tests, 0 fail, 3 DB skips; frontend
tsc/build; 166 tests, 0 fail, 10 opt-in browser skips; contract check;
confirmed-grant onboarding and isolated authenticated receiver fixtures.

Resolved paths:
- .env.example
- .github/workflows/ci.yml
- .gitignore
- .gitleaks.toml
- backend/package-lock.json
- backend/src/api/contracts.ts
- backend/src/api/routes.ts
- backend/src/api/routes/auditwave.integration.test.ts
- backend/src/api/routes/auditwave.performance.test.ts
- backend/src/api/routes/exports.test.ts
- backend/src/api/routes/misc.test.ts
- backend/src/api/routes/owner.ts
- backend/src/api/routes/ownerPacketSharing.test.ts
- backend/src/api/routes/regions.test.ts
- backend/src/api/routes/regions.ts
- backend/src/db/ownerAuth.ts
- backend/src/db/packetBatch.integration.test.ts
- backend/src/index.ts
- backend/src/metrics.ts
- backend/src/mqtt/client.ts
- backend/src/mqtt/envelopeSafety.test.ts
- backend/src/mqtt/envelopeSafety.ts
- backend/src/owner/ownerAccess.ts
- backend/src/owner/ownerLastHopPrewarm.test.ts
- backend/src/owner/ownerLastHopPrewarm.ts
- backend/src/owner/ownerRepository.ts
- backend/src/owner/packetShareForwarder.test.ts
- backend/src/owner/packetShareForwarder.ts
- backend/src/owner/packetShareRepository.integration.test.ts
- backend/src/owner/packetShareRepository.ts
- backend/src/owner/publicFeedForwarder.test.ts
- backend/src/owner/publicFeedForwarder.ts
- backend/src/owner/publicFeedRepository.ts
- backend/src/path-learning/rebuild.ts
- backend/src/ram/liveRead.ts
- backend/src/repositories/nodes.ts
- backend/src/spam/cluster.test.ts
- backend/src/spam/cluster.ts
- backend/src/spam/config.ts
- backend/src/spam/repository.ts
- backend/src/tools/rebuildRegionParticipation.ts
- backend/src/workers/alert-receiver.ts
- backend/src/workers/synthetic-monitor.ts
- backend/src/ws/server.ts
- backup-receipts/latest.json
- backup-receipts/latest.json.sig
- docker-compose.yml
- docs/openapi.yaml
- docs/operations.md
- docs/spam-detection.md
- frontend/playwright.config.ts
- frontend/src/components/Map/RegionsMap.tsx
- frontend/src/components/Map/regionOverlay.test.ts
- frontend/src/components/Map/regionOverlay.ts
- frontend/src/pages/RegionsPage.tsx
- frontend/src/pages/TopologyPage.browser.test.ts
- frontend/src/pages/regions-page.css
- frontend/src/pages/regionsModel.ts
- frontend/test/e2e/dashboard.spec.ts
- tagger-worker/Dockerfile
- vacuum-compressed-chunks.sh
2026-10-25 04:42:05 +00:00
gadgethd 29eec4bc90 fix(privacy): fence path-learning and tagger egress on packet privacy
Path-model training scanned 30 days of packets with no privacy predicate and
carried raw path hashes into prev_prefix; public reads filtered only node ids.
The tagger authorised in its poll query but re-read decrypted content by hash
alone and re-sent retries after a packet became private.

- training/network selectors use publicPacketPrivacySql
- priors whose prefix/prev_prefix match a private node id are dropped at
  publication and filtered on public read
- tagger re-reads by (hash, time, rx_node_id, network) plus the predicate and
  drops retries that are no longer public

Audit: backend/src/path-learning/rebuild.ts:training-packet-selection-omits-packet-privacy
       tagger-worker/tagger_worker.py:tag_message.decrypted-reread-without-visibility-or-generation-fence
2026-10-23 16:09:46 +00:00
hermes-gadget 5312b342e9 ci: retry transient image and apt failures without replaying test gates 2026-10-23 08:54:10 +01:00
Hermes Agent 48fb91acda chore(recovery): capture deployed 2026-10-20 working tree
Exact snapshot of the tree that produced the running images (HEAD 1f94bd8)
including the 199 uncommitted/untracked production changes: regions, owner
packet sharing, public feed, RAM ingest, privacy rematerialisation, path-beta
updates, migrations 052-060, tests and deploy scripts.

Excluded: .env*/knowledge.md/.private-config (gitignored secrets); runtime
backup receipts restored to HEAD; mosquitto ACL/passwd are gitignored (kept
in the private pre-change snapshot). No functional changes.
2026-10-20 11:37:34 +01:00
gadgethd 1d243222ef chore(sync): reconcile with production deploy tree — features, docs, plans gitignored
Bring main up to date with the live UKMesh production tree, reconciled
per-file (tree-wins for deployed features; main-wins where main evolved
past the tree's lineage; hand-merges for mixed files). Verified locally
on the deploy host: backend + frontend typechecks, backend unit suite
(543 pass / 0 fail), frontend suite (147 pass / 0 fail), OpenAPI
contract check, frontend production build, scripts typecheck.

Highlights:
- Deployed features land: tags + recent tags, owner public feed,
  Viterbi path prewarm and prior rebuilds, region participation,
  owner packet-sharing JWT scope, pathing docs, README updates.
- Main-side hardening retained: CI RAM steps + smoke cleanup trap,
  hardened scripts, gitleaks/logging rules, stale-MQTT observer
  protections, alert-receiver queue module, health-status refactor
  with tree retention additions (owner_packet_share_deliveries +
  public_feed_deliveries @30d, node_status_samples @30d — matching
  live TimescaleDB policies).
- Credential-generation client close restored on the tree's ownerAccess
  so the operator revocation tool (owner-auth:revoke) keeps working.
- Migrations renumbered to follow main's 058/059 ledger migrations:
  055_public_feed, 060_region_scope_participation,
  061_packet_share_owner_scope_and_jwt; migration-registry test
  assertions updated to the final numbering.
- Planning/report artifacts removed from the repo; local plans/, *.bak*
  patterns gitignored (deploy tree tidied to match).
2026-10-14 01:48:11 +00:00
gadgethd 1d86e043a5 feat(tags): live message tags for feed + app
- tagger-worker: persistent retry queue (tagger_retry) so API outages cannot
  drop tags; overlap 20s->120s; only publicly-visible in-scope messages are
  sent to the API (visibility + network filter)
- backend: tags joined into /feed/messages, /packets/recent, /packets/:hash
  and the WS initial state; new GET /tags/recent for live enrichment; contract
  + openapi entries
- frontend: tag chips under the row meta line (feed + app), live 15s tag poll,
  Message tags section in the packet detail panel
2026-09-18 00:13:01 +00:00