Skip to content

Backends v3.0.0: contract v3 hierarchy, PostgresStore, per-app proxy, app-token trust, one-run import - #27

Merged
kenatleap merged 2 commits into
mainfrom
feat/backends-v3
Nov 14, 2026
Merged

kenatleap merged 2 commits into
mainfrom
feat/backends-v3

Conversation

@kenatleap

Copy link
Copy Markdown
Collaborator

This is the library step of docs/CENTRAL-STORE.md (#26). Everything here is library code; no service exists yet.

What it adds

  • Contract v3: product (from app), stored kind, area, priority (now/next/later), owner, parentId, duplicateOf and votes.
    • Triage PATCH can change any of these, with or without a status change, and writes an audit row.
    • duplicateOf also declines the report with the note "duplicate of …".
    • New routes POST/DELETE /<id>/vote.
    • New list filters: app, kind, area, priority.
    • A v2 record still reads back.
  • bug_report.pg.PostgresStore (extra [postgres]), ported from the fleet dashboard's production store. A triage PATCH is one transaction with the row locked (SELECT … FOR UPDATE).
  • create_proxy_blueprint: an app's /api/bugs forwards every route to the central service. It sends the app's own token and the signed-in person, refuses .. in paths, and returns a generic 502 when the service can't be reached.
  • trusted_caller / TrustedCallers: every request must carry an app token, checked by a verify_token the service supplies.
    • There is no person path (Ken, 2026-11-14): no token gets 401, with no fallback to principal or Tailscale headers.
    • app is taken from the token; a disagreeing X-Leap-App is ignored, and the response says so.
  • bug_report.identity: trusted_person() moves in from the apps; loopback_headers is off by default.
  • import_reports is one run at cutover (Ken). A second run compares the reports already copied and raises ImportMismatch(ids) on any difference, writing nothing. It refuses app names the contract doesn't know.
  • Node backend stores and echoes the v3 fields so both backends pass the same e2e. Its Azure Tables store answers 501 for triage fields and votes; nothing in production uses it.

Tests (rerun by the coordinator in a fresh venv installed the way the README says, T7)

  • Python 346 + CLI 7; e2e 96 (each scenario on files, Postgres and Node).
  • Node: widget 188, triage-ui 17, backend-node 63, none failing.
  • CI gains a postgres:16 service. Without it the Postgres tests skip locally but fail under CI=true (T6).
  • Bite proofs (T4): the worker broke the code under about 50 of the new tests and saw each fail, across both rounds. The list is in the commit messages. The one test that didn't bite at first was tightened and then bit.

End-of-implementation review (T1) was done by a fresh reviewer that saw only the diff.

  • Ken decided the three decide items: no person path, one-run import, and token checks in the service with PyJWT, never decode-only, as the README now says.
  • Closed with tests:
    • the lost update under two concurrent PATCHes, tested on memory, files and Postgres;
    • an unknown app name on import.
  • Optional items done:
    • one wire map;
    • list filters taken from the contract, with a test;
    • effective_kind and apply_changes reused;
    • spec drift checked both ways;
    • Caller.via deleted;
    • since filtered on the indexed column.
  • Left open:
    • no e2e test runs proxy → trust → Postgres over HTTP; that comes with the service repo;
    • the README's prose has no drift guard.

Also fixed (T17): backend-node/tests/router.test.js failed 3 times in 25 on unchanged main. The cause was an unhandled rejection from the FilesystemStore's mkdir racing test cleanup. A one-line fix; it then failed 0 times in 40.

Tag backends-v3.0.0 after merge.

🤖 Generated with Claude Code

kmoy007 and others added 2 commits November 14, 2026 09:27
…dentity, import_reports; Node v3 fields

One central store for every app's reports: triage fields, votes, filters, product/app.
Contract v3 adds to v2 and removes nothing. Also fixes a flaky unhandledRejection in
backend-node's FilesystemStore constructor (3/25 failures on main, 0/40 after).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…at raises on drift, no lost update, review cleanups

- trusted_caller/TrustedCallers: a bearer token is required on every request (401); no gateway-principal or
  Tailscale fallback; identity loopback_headers defaults off.
- import_reports: app must be in APP_PRODUCTS; a second run compares each present report and raises
  ImportMismatch (ids) writing nothing; no resume.
- Store.update_bug: atomic (Postgres SELECT FOR UPDATE + one UPDATE; filesystem per-id lock).
- Proxy refuses .. segments and has generic 502 bodies; Postgres list filters on added_at; list filters and the
  wire/attribute map come from the contract; spec-drift test is two-way.
- docs/CENTRAL-STORE.md: no gateway route, LeapHQ calls as its own identity, one-run import, PyJWT; Ken's two
  assumptions marked still assumed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kenatleap
kenatleap enabled auto-merge (squash) November 14, 2026 17:35
@kenatleap
kenatleap merged commit db9c86d into main Nov 14, 2026
1 check passed
@kenatleap
kenatleap deleted the feat/backends-v3 branch November 14, 2026 17:38
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