Commit Graph
16 Commits
Author SHA1 Message Date
adamfandClaude Opus 5.5 daa2a465fb Cut the edge over from nginx and certbot to Caddy
Test and deploy / test (push) Successful in 3m30s
Test and deploy / deploy (push) Has been cancelled
Caddy takes nginx's place in compose: ports 80/443, the fixed address
172.28.255.251 that cloudflared pins the public names to, the network
aliases, the healthcheck and the autoheal label. nginx and certbot are
removed from compose; Caddy already holds its own certificates in
./caddy/data, obtained while it ran beside nginx. `traffic` now tails
logs/caddy/payloads.log, and the dev override switches Caddy to its dev
sites instead of putting nginx in DEV_MODE.

Docs and comments that described nginx's behaviour now describe Caddy's:
CLAUDE.md, DEPLOYMENT.md (topology, boot paths, TLS, rate limits, runbook
with a rollback, rough edges), the READMEs, .env.example and the comments
in the backend, Python service, Vue source and infra files. nginx/ and
certbot/ stay in the repo as the rollback until this has settled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-17 23:28:28 +00:00
adamfandClaude Opus 5.5 604ac32028 Remove the admin panel's Environment tab and env-apply
Test and deploy / test (push) Successful in 2m2s
Test and deploy / deploy (push) Successful in 1m35s
.env is edited by hand again. Drops the /admin/env endpoints, EnvManager
and its registry, the host-side apply.py watcher and its install script,
the backend's env-apply bind mount, and the Environment tab.

The deploy and maintenance workflows still serialise docker compose, now
on .compose.lock in the checkout instead of env-apply/run/lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 15:29:55 +01:00
adamfandClaude Opus 5.5 99fe175ebf Delete the old job code now that the tracker runs on its own
Test and deploy / test (push) Successful in 1m9s
Test and deploy / deploy (push) Successful in 1m33s
The job tracker has run from its own image at /jobs/ since 931b02c, so its
old copy here goes: the GraphQL schema, resolvers and models for
applications, references, sources, leads and the search profile; the
capture and email handlers and services; the Python posting reader, lead
scorer and email classifier; the Vue pages, stores and the capture-token
card on the Environment tab; and the userscript (nginx already redirects
its old URL to /jobs/).

The six old tables stay in the stp database: AutoMigrate never drops
anything, and dropping them is a manual step. The env variables stay in
the registry, where they already belong to the jobs service.

Docs (CLAUDE.md, DEPLOYMENT.md and the three READMEs) now describe the
site without the tracker, and DEPLOYMENT.md lists the jobs service and
./jobs-data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 17:35:18 +01:00
adamfandClaude Opus 5.5 3764ea9c0b Default to Sonnet 5.5 and make the Claude model an admin setting
Every Claude call used a hard-coded claude-haiku-4-5. The model is now
CLAUDE_MODEL, read by the Python service, defaulting to
claude-sonnet-5-5 and offered on the admin panel's Environment tab as a
choice of Haiku 4.5, Sonnet 5.5 and Opus 5.5.

The request is shaped per model. Sonnet and Opus think by default and
bill that against max_tokens, so they get low effort and 4,000 tokens of
headroom over each caller's reply ceiling; Haiku 4.5 rejects the effort
setting and keeps the plain request. A refusal is logged and reported as
the route's failed message instead of surfacing as an empty reply.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-12 15:52:33 +01:00
adamfandClaude Opus 5.5 af50e6c8ab Add a job leads inbox that finds and scores postings
Test and deploy / test (push) Successful in 1m55s
Test and deploy / deploy (push) Successful in 59s
The tracker recorded applications but could not find jobs. A new
pipeline (services/job_leads.go, job_sources.go) polls a watch list of
sources on a timer or on request, files unseen postings as leads, marks
which pass a keyword and location pre-filter, and has Claude score those
against a single search profile through a fourth internal Python route,
/internal/jobs/score.

Sources are Greenhouse, Lever and Ashby company boards (public JSON) and
Adzuna and Reed keyword searches (API keys). The two search fetchers are
written from the providers' documentation and tested only against stubs.

Leads are their own table, not a job status, and are not soft deleted:
the (source_kind, external_id) index is the dedup, so a dismissed lead
has to remain a row. A lead reaches the tracker only by promotion, which
goes through UpsertJobApplication. That upsert moves from the capture
handler into services so promotion and the fetcher can share it; the
capture endpoint's behaviour is unchanged.

/cv/leads is the page: inbox, watch list and profile form. The timer is
off unless JOB_LEADS_ENABLED=true and never runs at start-up, so a
deploy spends no Claude calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-12 15:03:46 +01:00
adamfandClaude Opus 5.5 307268fbea Put every Claude call behind one helper in the Python service
rowing.py and jobs.py repeated the same call, error mapping, fence
stripping and validation; that now lives in claude.ask_json, and the
internal routes share one wrapper and one exception handler in main.py.

Add /internal/email/classify, which takes over the email pipeline's
Claude call from the Go backend (prompt ported verbatim, plus a sentence
fencing the email off as data).

The internal-only guard is now a dependency, so a request that came
through nginx gets 404 even when its body is invalid, where it used to
get 422.

requirements-dev.txt adds pytest and httpx on top of requirements.txt so
the tests run on a host; the image still installs only requirements.txt.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-12 14:39:18 +01:00
adamfandClaude Opus 5.5 b8670246a8 Add browser job capture to the job tracker
Deploy with Docker Compose / deploy (push) Successful in 1m31s
A Violentmonkey userscript, served by the site and installed from /cv/jobs,
adds the posting open in the browser (LinkedIn, an ATS, any company page) to
the tracker. Claude reads the title, company and location off the page text.

- Three token-guarded REST routes under /api/jobs/capture (status, extract,
  upsert). They take a bearer token, JOB_CAPTURE_TOKEN, because the auth
  cookies are SameSite=Lax and never sent from another origin. An unset token
  switches the routes off.
- The upsert matches on a canonical posting URL, then (company, job title),
  so a capture and the email pipeline do not make two rows for one job.
- The Claude call is a new internal Python route, /internal/jobs/extract,
  alongside the rowing reader; the client and fence stripping they share move
  to python/app/claude.py.
- New "saved" status ranked below "applied", and a description column holding
  the posting text, shown per row on the tracker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-12 13:33:28 +01:00
adamfandClaude Opus 5.5 f8d48ba9af Move the rowing photo Claude call to the Python service
POST /rowing in the Go backend no longer calls the Anthropic SDK. It keeps
the admin gate, EXIF date, duplicate check, sanity bounds and insert, and
sends the image to a new internal Python route, POST /internal/rowing/read,
which makes the Claude call and returns the three numbers it read.

The route spends a paid call and has no auth of its own, so nginx 404s
/py/internal/ and the route refuses anything carrying the proxy headers
nginx adds. The python container now receives CLAUDE_API_KEY.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 11:46:17 +01:00
adamfandClaude Opus 5 22c6229c42 Add first test suite; fix Timer resume, scraper silent failure
Deploy with Docker Compose / deploy (push) Successful in 1m0s
Weekly Maintenance / maintenance (push) Successful in 19m9s
- backend/services/auth_test.go: token-version normalisation, the
  revocation rule, GenerateJWT/VerifyJWT claim handling. The happy path
  of AuthenticateTokenWithClaims still needs a DB driver we don't have.
- python/tests: travelodge.py's pure functions and the NDJSON event
  contract. pytest is a commented-out dev dep so the image stays slim.
- Timer.vue: the Paused screen now offers Resume, reaching pauseTimer's
  previously unreachable un-pause branch.
- travelodge.py: warn when upstream parses but yields nothing usable, so
  a field rename is distinguishable from sold-out inventory.
- CoverLetters.vue moved out of views/unused/ — it is live on /cv.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-17 02:55:18 +01:00
adamfandClaude Opus 5 25ac1cde1c Fix security issues, bugs, and convoluted code across the stack
Security:
- Token revocation. User gains a TokenVersion counter embedded in both
  tokens as a "tv" claim; AuthenticateToken rejects a token whose version
  no longer matches the row. Logout bumps it, so logging out now kills
  outstanding tokens rather than only clearing cookies. Costs one
  primary-key SELECT per authenticated request, which is the price of
  having revocation at all.
- Spotify OAuth CSRF. The fixed SPOTIFY_AUTH_STATE constant is replaced by
  a per-request one-shot nonce, verified and consumed on callback.
- Private chat attachments. Attachments on private messages are written to
  /backend/uploads/private/ and served at /uploads/private/, gated by the
  same nginx auth_request admin check used for /hasura/ and /notes/.
  Private uploads are rejected from non-admin callers.
- The icecast admin UI (/radio/admin/) is behind the admin gate; listener
  traffic is untouched.
- Store caches are mutex-guarded, so -race is clean.

Bugs:
- The email pipeline no longer drops emails permanently on transient
  failure. Failures record an attempt counter and are retried up to 3
  times; the fetch window rewinds to the oldest retryable email's
  ReceivedAt, without which a retry could never re-fetch it.
- Rowing duplicate detection distinguishes ErrRecordNotFound from a real
  DB error, so a transient failure no longer causes a duplicate insert
  plus a paid Claude call.
- DeletePost propagates its delete error instead of reporting success.
- RecentlyPlayed populates the cache it reads.
- main.go exits non-zero if r.Run fails, so a port conflict is visible.
- Python: the scan truncation flag is set on every deadline path;
  timed_out is reported by the worker rather than inferred from the clock;
  date validation uses Europe/London rather than server-local time.
- Vue: Time.vue and Radio.vue intervals are cleared on unmount; Feed.vue
  guards a missing author; Timer.vue gets an explicit state machine and
  compares total elapsed seconds; Elle.vue's comma-operator call and
  per-frame console.log are fixed.

Simplification:
- One TTLCache replaces three near-identical cache implementations, with
  the differing eviction rules as explicit parameters.
- run_scan's transport index no longer uses one object as both ordering
  record and live output; its three phases are separate functions.
- _price_hotels submits all work to a single pool, so the nested-executor
  deadlock hazard is gone by construction.
- The NDJSON event generators share one implementation.
- IMAP FETCH responses pair each line with its literal in the type, so
  callers no longer hand-skip alternate entries.
- Shared helpers for slice-of-pointers, markdown fences and auth cookies.
- Vue: useHotelSearch, createMirrorStore, useRotation, useCreateForm,
  useLinkAttrs, ListWidget and LinkTableItems replace duplicated blocks.
- nginx dev config's duplicated :80/:443 bodies share one partial.

Infra: certbot passes --deploy-hook touching a sentinel that nginx's
watcher reloads on, so renewed certs are served without a restart, and the
watcher also removes the manual restart after first issuance. db is gated
on service_healthy, autoheal is pinned, and the unused envsubst entries
are dropped.

Verified: go build/vet, npx vite build, py_compile, docker compose config
for both overlays, bash -n on all scripts, and an envsubst render of every
nginx template (no leftover placeholders, runtime vars preserved, braces
balanced).

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-16 16:12:21 +01:00
adamfandClaude Opus 5 64df70e5d2 Document codebase: comments, per-area READMEs, deployment guide
Readability pass across all four areas of the stack. Comments explain why
rather than what, concentrated at the points where behaviour is non-obvious:
concurrency, caching, auth, scraping and nginx templating.

Backend: doc comments on every exported declaration across handlers,
services, models and resolvers. Resolver commentary lives inside function
bodies so gqlgen does not strip it on regeneration; schema files use #
comments rather than description blocks so introspection output is
unchanged. Extracted the duplicated auth-cookie blocks into helpers.

Frontend: header comments on every component, store and view, including
STATUS: notes marking which of the parallel/legacy views are still live.
Documented the non-reactive animation-state pattern, the homeData hub and
the WebSocket stale-socket guard. Removed a few dead imports and named the
reconnect-backoff and poll-interval constants.

Python: module and function docstrings covering the Travelodge scraping
contract, the deadline threading, the two-executor concurrency and the
NDJSON streaming protocol.

Infra: header blocks on every compose file, nginx template, Dockerfile and
entrypoint, covering the config selection, envsubst allow-lists, rate-limit
semantics and volume persistence. Hoisted the duplicated envsubst variable
list in nginx/entrypoint.sh.

New: backend/README.md, python/README.md, DEPLOYMENT.md, .env.example,
backend/graph/doc.go. Refreshed vue/README.md. Corrected CLAUDE.md, which
stated a 24h access token where main.go sets 7 days.

No behaviour change. go build/vet, vite build, py_compile and docker
compose config all pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-16 15:57:48 +01:00
adamfandClaude Fable 5.1 f83d683180 Add cheapest-night date-range scan to the Travelodge finder
Deploy with Docker Compose / deploy (push) Successful in 52s
A second "Cheapest night" tab on /hotels scans every candidate check-in
between two dates (filtered by weekday, 1-7 nights, up to ~3 months),
keeps the N cheapest hotels per night, and prices TfL transport once per
unique hotel so the whole range fits in the streaming window.

Backend
- travelodge.py: extract _shortlist/_make_row/_price_hotels/_apply_transport
  from run_search; add a 30-minute per-(location, dates, rooms) Travelodge
  result cache, a deadline on page fetches, and run_scan (parallel date
  fetches with per-date failure isolation, one TfL lookup per hotel).
- main.py: HotelRequestBase shared by search and scan requests,
  HotelScanRequest with weekday/range validation, scan event models,
  _guarded slot wrapper, POST /hotels/scan/stream (NDJSON).
- nginx: the streaming location now matches /py/hotels/(search|scan).

Frontend
- Split CheapHotels.vue into SingleStayPanel, CheapestNightPanel,
  SharedFields, HotelRows, a shared form composable, stream/format helpers
  and hotels-shared.css; shared fields keep their values across tabs.
- Vite dev server proxies /py to the Python API.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01H5P3C1HbbEwLZEYsjwr7uV
2026-09-08 01:38:30 +01:00
adamfandClaude Fable 5.1 e445892259 Give TfL cycle lookups a single attempt
TfL can take over 15s to return 404 for destinations with no cycle route
(motorway services), and retrying that three times stalled a hotel for
almost a minute. The distance estimate covers the gap.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dphx7LL5JC8dAFYU7MMpoA
2026-09-08 00:54:33 +01:00
adamfandClaude Fable 5.1 44c08850ed Tighten TfL timeout and overlap cycle lookups
Deploy with Docker Compose / deploy (push) Successful in 34s
A hung TfL call could stall one hotel for 40s before retrying. Time out
at 15s instead, and submit the cycle-route query alongside the fare
queries so a keyed search prices each hotel in one round trip.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dphx7LL5JC8dAFYU7MMpoA
2026-09-08 00:51:18 +01:00
adamfandClaude Fable 5.1 20e958c124 Speed up cheap Travelodge finder and stream results
Deploy with Docker Compose / deploy (push) Successful in 59s
Backend: fetch Travelodge pages in parallel batches, price TfL journeys
from a worker pool throttled to the anonymous 50/min limit (500/min with
TFL_APP_KEY), cache TfL journeys for two hours, and expose a streaming
NDJSON endpoint (/hotels/search/stream) that sends the hotel list first
and one line per hotel as fares arrive. A 20-hotel search now takes
about 10 seconds instead of minutes. Every hotel also gets a cycling
time from the origin (TfL cycle routing with an app key, otherwise a
distance estimate).

Frontend: consume the stream so hotels appear immediately with a
progress bar, show three picks (best value, cheapest room, quickest
cycle) instead of one, add a rank-by toggle (stay + transport, stay
only, cycle time, travel time) and a Cycle column, and raise the hotel
cap to 40.

Nginx: match both search routes and disable proxy buffering and gzip so
the stream reaches the browser as it is produced.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dphx7LL5JC8dAFYU7MMpoA
2026-09-08 00:29:37 +01:00
adamfandClaude Fable 5.1 152f60ee32 Add Python FastAPI service, cheap hotels page, and Tailwind theme refactor
Deploy with Docker Compose / deploy (push) Successful in 1m29s
- Replace searxng and open-webui with a FastAPI `python/` service proxied
  at /py/ (Travelodge hotel search, rate-limited in nginx)
- Add CheapHotels view and CreateToggle component
- Move design tokens into Tailwind @theme in styles.css and migrate
  components/views to utility classes; CVLayout re-points tokens for light theme
- Update README, CLAUDE.md, and .gitignore accordingly

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dphx7LL5JC8dAFYU7MMpoA
2026-09-08 00:06:04 +01:00