newsroom 5.2: Readeck export (ICB-147) #270

Merged
prskr merged 2 commits from ICB-147-newsroom-5-2-readeck-export into main 2026-10-14 19:04:30 +00:00
Contributor

Task 5.2 of the newsroom OpenSpec change (ICB-147). Brief: newsroom/tasks/15-readeck-export.md.

What

  • newsroom/internal/readeck: hand-rolled client (net/http + encoding/json, no new dependency) and a once-only Exporter. Package doc states this is the one user-initiated write that calls out from the serving side.
  • POST /ui/entry/{id}/export returns the re-rendered #export-control: Save button, or Saved linking to <baseURL>/bookmarks/<id>. The control sits in the reader action bar. Failure is shown inline (HTTP 200 so HTMX swaps it; a 4xx/5xx would not be swapped) and stores nothing.
  • Exports the rewritten Link, never OriginalLink, with the configured labels.
  • Idempotence: an entry with readeck_exported_at returns the stored id with zero HTTP calls. Exports are serialised by a mutex so a double-click cannot create two bookmarks before the first is recorded. The store write after a successful create uses context.WithoutCancel so a cancelled request cannot lose a bookmark that already exists.
  • Disabled: without web.WithExport(...) no control renders and the endpoint answers 501; the store is untouched.
  • 5.2 ticked in tasks.md.

Readeck API verification

Not verified live (no Readeck instance reachable from here). Verified from the upstream docs source, tag 0.23.4 (docs/api/bookmarks/routes-bookmarks.yaml, types.yaml, base.md, traits.yaml at codeberg.org/readeck/readeck):

  1. POST {base}/api/bookmarks, JSON body {"url", "title"?, "labels"?} ✅ (spec)
  2. Authorization: Bearer <token> ✅ (spec)
  3. Returns 202 and fetches the page asynchronously; the id is in the Bookmark-Id response header (client falls back to the last segment of Location) ✅ (spec). Nothing to poll.
  4. Labels are set at creation ✅ (spec)
  5. Duplicate URL behaviour is not documented in the spec; not verified. Local export state is therefore the idempotence mechanism, not a UI nicety.
    Also unverified live: the {base}/bookmarks/<id> UI URL used for the "Saved" link (derived from Readeck's web routes, not from the API spec).

Token wiring for 6.1

readeck.NewClient(baseURL, token, labels) and readeck.NewExporter(store, client); then web.Handler(lib, feeds, web.WithExport(exporter, cfg.Readeck.BaseURL)), only when cfg.Readeck != nil. Bind the token to a kong flag with an env var (e.g. READECK_TOKEN) in 6.1; NewClient rejects an empty token. The token appears in no error string or log line (tested).

Verification

  • bazel test --config=remote //newsroom/...: 20/20 pass, including //newsroom/internal/web:web_integration_test (ran for real; includes TestExportOverRealStore: two exports → one POST to the stub, DB row set; failure leaves entry unexported), //newsroom/internal/readeck:readeck_test, nogo/nilaway/golangci clean.
  • go test -cover ./newsroom/internal/readeck/: 90.5% statements (go test, not bazel coverage).
  • bazel run //:format fails with a git "dubious ownership" error; instead ran gofumpt -l (clean) and gofmt -l (clean). CI Validate still to be checked on this commit.
  • No symlinks (find . -type l empty).

Not covered / notes

  • No CSRF/origin check on the /ui/ POSTs (newsroom-cleanup 6.1 covers the new endpoint too). The export control follows the existing read/star fragment pattern for list context (cleanup 1.1); no back-link/context handling added.
  • kong wiring, health endpoints: 6.1.

🤖 Generated with Claude Code

Task 5.2 of the `newsroom` OpenSpec change (ICB-147). Brief: `newsroom/tasks/15-readeck-export.md`. ## What - `newsroom/internal/readeck`: hand-rolled client (`net/http` + `encoding/json`, no new dependency) and a once-only `Exporter`. Package doc states this is the one user-initiated write that calls out from the serving side. - `POST /ui/entry/{id}/export` returns the re-rendered `#export-control`: **Save** button, or **Saved** linking to `<baseURL>/bookmarks/<id>`. The control sits in the reader action bar. Failure is shown inline (HTTP 200 so HTMX swaps it; a 4xx/5xx would not be swapped) and stores nothing. - Exports the rewritten `Link`, never `OriginalLink`, with the configured labels. - Idempotence: an entry with `readeck_exported_at` returns the stored id with zero HTTP calls. Exports are serialised by a mutex so a double-click cannot create two bookmarks before the first is recorded. The store write after a successful create uses `context.WithoutCancel` so a cancelled request cannot lose a bookmark that already exists. - Disabled: without `web.WithExport(...)` no control renders and the endpoint answers 501; the store is untouched. - 5.2 ticked in `tasks.md`. ## Readeck API verification **Not verified live** (no Readeck instance reachable from here). Verified from the upstream docs source, tag **0.23.4** (`docs/api/bookmarks/routes-bookmarks.yaml`, `types.yaml`, `base.md`, `traits.yaml` at codeberg.org/readeck/readeck): 1. `POST {base}/api/bookmarks`, JSON body `{"url", "title"?, "labels"?}` ✅ (spec) 2. `Authorization: Bearer <token>` ✅ (spec) 3. Returns **202** and fetches the page asynchronously; the id is in the `Bookmark-Id` response header (client falls back to the last segment of `Location`) ✅ (spec). Nothing to poll. 4. Labels are set at creation ✅ (spec) 5. Duplicate URL behaviour is **not documented** in the spec; not verified. Local export state is therefore the idempotence mechanism, not a UI nicety. Also unverified live: the `{base}/bookmarks/<id>` UI URL used for the "Saved" link (derived from Readeck's web routes, not from the API spec). ## Token wiring for 6.1 `readeck.NewClient(baseURL, token, labels)` and `readeck.NewExporter(store, client)`; then `web.Handler(lib, feeds, web.WithExport(exporter, cfg.Readeck.BaseURL))`, only when `cfg.Readeck != nil`. Bind the token to a kong flag with an env var (e.g. `READECK_TOKEN`) in 6.1; `NewClient` rejects an empty token. The token appears in no error string or log line (tested). ## Verification - `bazel test --config=remote //newsroom/...`: 20/20 pass, including `//newsroom/internal/web:web_integration_test` (ran for real; includes `TestExportOverRealStore`: two exports → one POST to the stub, DB row set; failure leaves entry unexported), `//newsroom/internal/readeck:readeck_test`, nogo/nilaway/golangci clean. - `go test -cover ./newsroom/internal/readeck/`: 90.5% statements (go test, not `bazel coverage`). - `bazel run //:format` fails with a git "dubious ownership" error; instead ran `gofumpt -l` (clean) and `gofmt -l` (clean). CI `Validate` still to be checked on this commit. - No symlinks (`find . -type l` empty). ## Not covered / notes - No CSRF/origin check on the `/ui/` POSTs (newsroom-cleanup 6.1 covers the new endpoint too). The export control follows the existing read/star fragment pattern for list context (cleanup 1.1); no back-link/context handling added. - kong wiring, health endpoints: 6.1. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
newsroom: Readeck export (5.2)
All checks were successful
Validate / validate (pull_request) Successful in 3m59s
c5225c78ff
Hand-rolled Readeck client + once-only exporter, POST /ui/entry/{id}/export
and a Save/Saved control in the reader actions. Disabled (no control, 501)
without a readeck section. Token is a constructor parameter only.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Author
Contributor

Verdict: CHANGES REQUESTED (1 blocking, 3 should-fix, rest minor/nits)

PR: #270, reviewed commit c5225c78ff8881b05f91452e413e2a13e2a03443, the only commit on the branch. Review done with /code-review (high), then each finding checked by hand. Not merged.

Success condition tested

The brief newsroom/tasks/15-readeck-export.md plus the newsroom-ui spec "Readeck export is manual and idempotent" / "Readeck is optional and its token is protected". The ICB-148 plan checklist applies, and kong token binding and CSRF stay out of scope (6.1).

Steps run (in a detached worktree of c5225c7)

bazel test --config=remote --nocache_test_results --experimental_convenience_symlinks=ignore //newsroom/...
  -> Executed 20 out of 20 tests: 20 tests pass. (20 remote test actions, no cached results; includes web/storage/library/ingest integration tests)
CGO_ENABLED=0 go test -count=1 -cover ./newsroom/internal/readeck/
  -> ok ... coverage: 90.3% of statements
bazel run --experimental_convenience_symlinks=ignore //:format ; git status --short
  -> formatters ran, working tree clean (no ownership error this time)
find . -type l -not -path './.git/*'   -> (nothing)
Forgejo commit status c5225c7          -> success (Validate / validate)
git diff origin/main...HEAD -- go.mod MODULE.bazel -> empty (no new dependency)
Upstream API: codeberg readeck tag 0.23.4 docs/api/bookmarks/{routes-bookmarks,types}.yaml

Blocking

  1. The "Saved" link points to the API base URL, which in the documented setup the browser cannot reach. In layout.templ the ExportControl link is built with readeck.BookmarkURL(ex.BaseURL, id), and that BaseURL is the same readeck.baseURL the server uses to call the API (WithExport(exporter, cfg.Readeck.BaseURL) per the 6.1 notes). newsroom/config.yaml documents baseURL: http://readeck.tools.svc:8000.
    • Expected: "Saved" opens the bookmark in the user's browser. The brief says "A saved state you cannot navigate to is half a feature".
    • Actual: the link goes to http://readeck.tools.svc:8000/bookmarks/<id>, which a browser outside the cluster cannot resolve.
    • Fix, pick one: (a) add an optional public UI URL (e.g. readeck.publicURL, defaulting to baseURL) and pass that to WithExport. WithExport already takes the URL separately, so the change is mostly config. (b) If the owner wants a single URL, document that baseURL must be reachable from the browser and change the config.yaml example. If the choice is unclear, ask Steve Wozniak.

Should fix (not blocking on their own)

  1. One global mutex, held across the HTTP call, and waiting for it ignores ctx (export.go Export). Every export of every entry is serialised. If Readeck hangs, N clicks queue for up to N x 5s, and a request whose client has already gone still waits for the lock and then POSTs. The brief says "Readeck being slow must not hold an HTTP handler open". Suggested fix: lock per entry id, and/or acquire through a chan struct{} semaphore with select on ctx.Done().
  2. Race and idempotence across processes. The mutex only works inside one process, and SetReadeckExport overwrites without a condition. Deploy is replicas: 1 with RollingUpdate, so two pods overlap only briefly. If clicks hit both pods in that window, two bookmarks are created and the second id silently replaces the first. Readeck's duplicate-URL behaviour is undocumented (Linus says so too), so local state is the only guard. In this homelab it hardly matters in practice, but at least make the write conditional (... WHERE readeck_exported_at IS NULL) so the first id is kept. Otherwise record this as a known limitation.
  3. Create succeeds but the DB write fails. The user sees "Export to Readeck failed." and a Save button, so clicking again creates a duplicate bookmark. The bookmark id also appears nowhere in the error or log. At minimum, log the bookmark id in that branch and show a message that says the bookmark exists but was not recorded.

Minor / nits

  1. The failure path calls lib.GetEntry(r.Context()) a second time. If the client disconnects, that fails with context.Canceled, and fail() logs it at ERROR and writes a 500. That is log noise on every abandoned click. Return the already-loaded entry from Export together with the error instead.
  2. The Location fallback in bookmarkID takes the raw text after the last /, so a query or fragment would end up in the stored id. Upstream 0.23.4 only documents Bookmark-Id, so this is hypothetical. Use path.Base(u.Path) after url.Parse.
  3. Nit: readeck.ErrEntryNotFound duplicates library.ErrNotFound, which fail() already maps to 404.
  4. Nit (AGENTS.md): readeck_test.go exporter() and the dead-server block use t.Fatal/t.Errorf guards instead of assert.NoError plus the sanctioned "Unreachable:" panic guard. The new slog.WarnContext line uses loose key/value pairs instead of slog.Int64/slog.Any; the existing fail() does the same, so it matches local style.

Checklist results

  • Token safety: ✅ StatusError carries only the status, the transport error is unwrapped, and the response body is discarded. TestTokenNeverInLogsOrErrors covers status, missing id, a server that echoes the token, and a dead server. The inline UI messages are fixed strings.
  • Right URL: ✅ e.Link is sent. Unit and integration tests assert this, and the fixture's OriginalLink differs from Link.
  • Idempotence: ✅ an already-exported entry makes 0 HTTP calls (unit test). Twice gives one POST against real Postgres (TestExportOverRealStore). Concurrency: see 2–3.
  • Failure: ✅ non-2xx, timeout, cancel and missing id store nothing (tests). The error is shown inline with HTTP 200 so HTMX swaps it. No retry queue. Exception: see 4.
  • Outbound boundary: ✅ only POST /ui/entry/{id}/export calls Readeck, and renders only read stored state. The package doc explains why this call is allowed.
  • Timeout: ✅ context.WithTimeout(ctx, 5s) on the request ctx. The lock wait is not bounded: see 2.
  • Disabled path: ✅ no control, 501, store untouched, star still works (TestExportDisabled).
  • API shape: ✅ checked against upstream 0.23.4 OpenAPI: POST /api/bookmarks, bookmarkCreate{url (required), labels[]}, 202 with a Bookmark-Id header. Not verified: the UI path /bookmarks/<id> (the API doc only covers /api/...), duplicate-URL behaviour, and the bearer scheme name. The traits file was not opened, though the code uses the standard token form. No live instance.
  • UI: ✅ Goshtoso button for Save. Output is templ-escaped and the id is path-escaped in the link. The link target is wrong: see 1.
  • Gate: ✅ tests (no cache), format clean, nogo passes as part of the bazel build, CI green on c5225c7, 5.2 ticked, no new dependency, coverage 90.3% (>70%), no symlinks.

Not covered

  • No browser render: no screenshot, and HTMX swap behaviour was checked only through the HTML assertions in the tests.
  • No live Readeck instance, so 202/Bookmark-Id and the UI path were not exercised for real.
  • Wiring the feature into the app (kong token, WithExport from config) is out of scope (6.1) and not reviewed. Until 6.1 lands, the feature cannot be switched on in production.

Next owner: Linus Torvalds for #1 (plus #2–#4 if cheap). If the URL decision in #1 needs the owner, ask Steve Wozniak. I will re-review new commits with /code-review.

**Verdict: CHANGES REQUESTED** (1 blocking, 3 should-fix, rest minor/nits) PR: https://code.icb4dc0.de/prskr/tools/pulls/270, reviewed commit `c5225c78ff8881b05f91452e413e2a13e2a03443`, the only commit on the branch. Review done with `/code-review` (high), then each finding checked by hand. Not merged. ### Success condition tested The brief `newsroom/tasks/15-readeck-export.md` plus the newsroom-ui spec "Readeck export is manual and idempotent" / "Readeck is optional and its token is protected". The ICB-148 plan checklist applies, and kong token binding and CSRF stay out of scope (6.1). ### Steps run (in a detached worktree of c5225c7) ``` bazel test --config=remote --nocache_test_results --experimental_convenience_symlinks=ignore //newsroom/... -> Executed 20 out of 20 tests: 20 tests pass. (20 remote test actions, no cached results; includes web/storage/library/ingest integration tests) CGO_ENABLED=0 go test -count=1 -cover ./newsroom/internal/readeck/ -> ok ... coverage: 90.3% of statements bazel run --experimental_convenience_symlinks=ignore //:format ; git status --short -> formatters ran, working tree clean (no ownership error this time) find . -type l -not -path './.git/*' -> (nothing) Forgejo commit status c5225c7 -> success (Validate / validate) git diff origin/main...HEAD -- go.mod MODULE.bazel -> empty (no new dependency) Upstream API: codeberg readeck tag 0.23.4 docs/api/bookmarks/{routes-bookmarks,types}.yaml ``` ### Blocking 1. **The "Saved" link points to the API base URL, which in the documented setup the browser cannot reach.** In `layout.templ` the `ExportControl` link is built with `readeck.BookmarkURL(ex.BaseURL, id)`, and that `BaseURL` is the same `readeck.baseURL` the server uses to call the API (`WithExport(exporter, cfg.Readeck.BaseURL)` per the 6.1 notes). `newsroom/config.yaml` documents `baseURL: http://readeck.tools.svc:8000`. - Expected: "Saved" opens the bookmark in the user's browser. The brief says "A saved state you cannot navigate to is half a feature". - Actual: the link goes to `http://readeck.tools.svc:8000/bookmarks/<id>`, which a browser outside the cluster cannot resolve. - Fix, pick one: (a) add an optional public UI URL (e.g. `readeck.publicURL`, defaulting to `baseURL`) and pass that to `WithExport`. `WithExport` already takes the URL separately, so the change is mostly config. (b) If the owner wants a single URL, document that `baseURL` must be reachable from the browser and change the `config.yaml` example. If the choice is unclear, ask Steve Wozniak. ### Should fix (not blocking on their own) 2. **One global mutex, held across the HTTP call, and waiting for it ignores ctx** (`export.go` `Export`). Every export of every entry is serialised. If Readeck hangs, N clicks queue for up to N x 5s, and a request whose client has already gone still waits for the lock and then POSTs. The brief says "Readeck being slow must not hold an HTTP handler open". Suggested fix: lock per entry id, and/or acquire through a `chan struct{}` semaphore with `select` on `ctx.Done()`. 3. **Race and idempotence across processes.** The mutex only works inside one process, and `SetReadeckExport` overwrites without a condition. Deploy is `replicas: 1` with `RollingUpdate`, so two pods overlap only briefly. If clicks hit both pods in that window, two bookmarks are created and the second id silently replaces the first. Readeck's duplicate-URL behaviour is undocumented (Linus says so too), so local state is the only guard. In this homelab it hardly matters in practice, but at least make the write conditional (`... WHERE readeck_exported_at IS NULL`) so the first id is kept. Otherwise record this as a known limitation. 4. **Create succeeds but the DB write fails.** The user sees "Export to Readeck failed." and a Save button, so clicking again creates a duplicate bookmark. The bookmark id also appears nowhere in the error or log. At minimum, log the bookmark id in that branch and show a message that says the bookmark exists but was not recorded. ### Minor / nits 5. The failure path calls `lib.GetEntry(r.Context())` a second time. If the client disconnects, that fails with `context.Canceled`, and `fail()` logs it at ERROR and writes a 500. That is log noise on every abandoned click. Return the already-loaded entry from `Export` together with the error instead. 6. The `Location` fallback in `bookmarkID` takes the raw text after the last `/`, so a query or fragment would end up in the stored id. Upstream 0.23.4 only documents `Bookmark-Id`, so this is hypothetical. Use `path.Base(u.Path)` after `url.Parse`. 7. Nit: `readeck.ErrEntryNotFound` duplicates `library.ErrNotFound`, which `fail()` already maps to 404. 8. Nit (AGENTS.md): `readeck_test.go` `exporter()` and the dead-server block use `t.Fatal`/`t.Errorf` guards instead of `assert.NoError` plus the sanctioned "Unreachable:" panic guard. The new `slog.WarnContext` line uses loose key/value pairs instead of `slog.Int64`/`slog.Any`; the existing `fail()` does the same, so it matches local style. ### Checklist results - Token safety: ✅ `StatusError` carries only the status, the transport error is unwrapped, and the response body is discarded. `TestTokenNeverInLogsOrErrors` covers status, missing id, a server that echoes the token, and a dead server. The inline UI messages are fixed strings. - Right URL: ✅ `e.Link` is sent. Unit and integration tests assert this, and the fixture's `OriginalLink` differs from `Link`. - Idempotence: ✅ an already-exported entry makes 0 HTTP calls (unit test). Twice gives one POST against real Postgres (`TestExportOverRealStore`). Concurrency: see 2–3. - Failure: ✅ non-2xx, timeout, cancel and missing id store nothing (tests). The error is shown inline with HTTP 200 so HTMX swaps it. No retry queue. Exception: see 4. - Outbound boundary: ✅ only `POST /ui/entry/{id}/export` calls Readeck, and renders only read stored state. The package doc explains why this call is allowed. - Timeout: ✅ `context.WithTimeout(ctx, 5s)` on the request ctx. The lock wait is not bounded: see 2. - Disabled path: ✅ no control, 501, store untouched, star still works (`TestExportDisabled`). - API shape: ✅ checked against upstream 0.23.4 OpenAPI: `POST /api/bookmarks`, `bookmarkCreate{url (required), labels[]}`, `202` with a `Bookmark-Id` header. **Not verified:** the UI path `/bookmarks/<id>` (the API doc only covers `/api/...`), duplicate-URL behaviour, and the bearer scheme name. The traits file was not opened, though the code uses the standard token form. No live instance. - UI: ✅ Goshtoso `button` for Save. Output is templ-escaped and the id is path-escaped in the link. The link target is wrong: see 1. - Gate: ✅ tests (no cache), format clean, nogo passes as part of the bazel build, CI green on c5225c7, 5.2 ticked, no new dependency, coverage 90.3% (>70%), no symlinks. ### Not covered - No browser render: no screenshot, and HTMX swap behaviour was checked only through the HTML assertions in the tests. - No live Readeck instance, so 202/`Bookmark-Id` and the UI path were not exercised for real. - Wiring the feature into the app (kong token, `WithExport` from config) is out of scope (6.1) and not reviewed. Until 6.1 lands, the feature cannot be switched on in production. **Next owner:** Linus Torvalds for #1 (plus #2–#4 if cheap). If the URL decision in #1 needs the owner, ask Steve Wozniak. I will re-review new commits with `/code-review`.
newsroom: address Readeck export review (public URL, per-entry lock, first export wins)
All checks were successful
Validate / validate (pull_request) Successful in 5m32s
Validate / validate (push) Successful in 2m20s
8ba37ec49a
- optional readeck.publicURL (default baseURL) for the Saved link
- per-entry lock that honours ctx instead of a global mutex
- SetReadeckExport only writes while readeck_exported_at IS NULL
- log and report the bookmark id when recording the export fails

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Author
Contributor

Verdict: PASS — re-review of PR #270 at 8ba37ec (fixes on top of c5225c7). All blocking and should-fix items from the first review are resolved. Nothing blocks the merge.

Success condition tested: the four items from my first verdict are fixed without regressions: (1) the "Saved" link can point at a browser-reachable Readeck URL; (2) the export lock is per entry and the wait honours ctx; (3) the first recorded bookmark id wins; (4) if the DB write fails after Create, the bookmark id is not lost silently. The original 5.2 acceptance criteria still hold: tests green including integration, CI Validate green, no new dependency, no symlinks, PR open and unmerged.

Steps run (this commit, worktree ICB-147-newsroom-5-2-readeck-export):

  1. git diff c5225c7 8ba37ec — 10 files changed, all scoped to the four findings. No scope creep.
  2. bazel test --config=remote --experimental_convenience_symlinks=ignore --nocache_test_results //newsroom/... → Executed 20 out of 20 tests: 20 tests pass. This includes storage_integration_test (real Postgres via remote podman), web_integration_test, readeck_test, and write_dbgen_test. The integration targets are not tagged manual, so the wildcard covers them.
  3. CGO_ENABLED=1 go test -race -count=20 -run Export ./newsroom/internal/readeck/ → ok. Neither fix comment mentions a race-detector run, so I ran this for the new lock code.
  4. Temporary probe test, deleted afterwards (tree clean): entry 1 is held inside the HTTP call while entry 2 is exported with a 1s deadline. Entry 2 completes; after release, a re-export of entry 1 short-circuits (2 HTTP calls total). go test -race -count=5 → 5/5 PASS.
  5. Forgejo API: commit status 8ba37ec → Validate / validate (pull_request) success; PR #270 open, merged=false, head 8ba37ec, base main.
  6. find . -type l -not -path './.git/*' → empty.

Findings vs. first review:

# Expected Actual
1 Blocking Saved link uses a browser URL ✅ optional readeck.publicURL (absolute-URL validated), UIURL() falls back to baseURL; config tests cover both the invalid case and the default; config.yaml documents both. 6.1 must pass cfg.Readeck.UIURL() to WithExport.
2 Per-entry lock, ctx-aware ✅ channel-per-id lock. TestExportWaitForSameEntryHonoursContext plus my probe show the same entry is serialised and a different entry is not blocked. Race detector is clean.
3 First export wins ✅ WHERE id = $1 AND readeck_exported_at IS NULL in both the query and the generated code. The storage integration test writes a second id and asserts the original id and time survive the re-upsert. The hand-edited sqlc output is confirmed equal to real generator output by write_dbgen_test passing.
4 Bookmark id not lost ✅ slog.ErrorContext logs entry + bookmark id; the error wraps it; tested (TestExportRecordFailureNamesBookmark). The log has no token.

Minor (non-blocking, follow-up at the owner's discretion):

  • m1. If another process wins the race, SetReadeckExport (:exec) updates 0 rows silently. Export then returns its own losing bookmark id as success, so that Readeck bookmark is orphaned and the UI shows a link that differs from the stored one until reload. This only happens with more than one replica; within one process the per-entry lock prevents it. Fix if wanted: :execrows, then re-read the entry when 0 rows are updated.
  • m2. Nitpick: in case 4 the UI shows the generic "Export to Readeck failed.", which invites a retry that creates a duplicate. The id is in the server log, so this is acceptable.
  • m3. Nitpick: a lock wait that hits a request deadline is shown as "Readeck did not answer in time." Browser requests carry no deadline, so this is practically unreachable.
  • The minor items from the first verdict that Linus Torvalds did not take on are still open. None of them block.

Not covered: no live Readeck instance, so the API shape (Bookmark-Id header, /bookmarks/<id> UI path) is still verified only from the upstream docs at 0.23.4, as in the first review. The cross-process race (m1) was analysed but not reproduced. bazel run //:format and bazel coverage were not rerun; CI Validate covers format/lint. App wiring (kong, token env) is task 6.1, out of scope.

Next owner: no fixes are needed from Linus Torvalds. PR #270 is ready to merge; that is the owner's decision via Steve Wozniak. I have not merged anything.

**Verdict: PASS** — re-review of PR #270 at `8ba37ec` (fixes on top of `c5225c7`). All blocking and should-fix items from the first review are resolved. Nothing blocks the merge. **Success condition tested:** the four items from my first verdict are fixed without regressions: (1) the "Saved" link can point at a browser-reachable Readeck URL; (2) the export lock is per entry and the wait honours ctx; (3) the first recorded bookmark id wins; (4) if the DB write fails after Create, the bookmark id is not lost silently. The original 5.2 acceptance criteria still hold: tests green including integration, CI `Validate` green, no new dependency, no symlinks, PR open and unmerged. **Steps run** (this commit, worktree `ICB-147-newsroom-5-2-readeck-export`): 1. `git diff c5225c7 8ba37ec` — 10 files changed, all scoped to the four findings. No scope creep. 2. `bazel test --config=remote --experimental_convenience_symlinks=ignore --nocache_test_results //newsroom/...` → `Executed 20 out of 20 tests: 20 tests pass.` This includes `storage_integration_test` (real Postgres via remote podman), `web_integration_test`, `readeck_test`, and `write_dbgen_test`. The integration targets are not tagged `manual`, so the wildcard covers them. 3. `CGO_ENABLED=1 go test -race -count=20 -run Export ./newsroom/internal/readeck/` → `ok`. Neither fix comment mentions a race-detector run, so I ran this for the new lock code. 4. Temporary probe test, deleted afterwards (tree clean): entry 1 is held inside the HTTP call while entry 2 is exported with a 1s deadline. Entry 2 completes; after release, a re-export of entry 1 short-circuits (2 HTTP calls total). `go test -race -count=5` → 5/5 PASS. 5. Forgejo API: commit status `8ba37ec` → `Validate / validate (pull_request) success`; PR #270 `open`, `merged=false`, head `8ba37ec`, base `main`. 6. `find . -type l -not -path './.git/*'` → empty. **Findings vs. first review:** | # | Expected | Actual | |---|---|---| | 1 Blocking | Saved link uses a browser URL | ✅ optional `readeck.publicURL` (absolute-URL validated), `UIURL()` falls back to `baseURL`; config tests cover both the invalid case and the default; `config.yaml` documents both. 6.1 must pass `cfg.Readeck.UIURL()` to `WithExport`. | | 2 | Per-entry lock, ctx-aware | ✅ channel-per-id lock. `TestExportWaitForSameEntryHonoursContext` plus my probe show the same entry is serialised and a different entry is not blocked. Race detector is clean. | | 3 | First export wins | ✅ `WHERE id = $1 AND readeck_exported_at IS NULL` in both the query and the generated code. The storage integration test writes a second id and asserts the original id and time survive the re-upsert. **The hand-edited sqlc output is confirmed equal to real generator output by `write_dbgen_test` passing.** | | 4 | Bookmark id not lost | ✅ `slog.ErrorContext` logs entry + bookmark id; the error wraps it; tested (`TestExportRecordFailureNamesBookmark`). The log has no token. | **Minor (non-blocking, follow-up at the owner's discretion):** - m1. If another *process* wins the race, `SetReadeckExport` (`:exec`) updates 0 rows silently. `Export` then returns its own losing bookmark id as success, so that Readeck bookmark is orphaned and the UI shows a link that differs from the stored one until reload. This only happens with more than one replica; within one process the per-entry lock prevents it. Fix if wanted: `:execrows`, then re-read the entry when 0 rows are updated. - m2. Nitpick: in case 4 the UI shows the generic "Export to Readeck failed.", which invites a retry that creates a duplicate. The id is in the server log, so this is acceptable. - m3. Nitpick: a lock wait that hits a request deadline is shown as "Readeck did not answer in time." Browser requests carry no deadline, so this is practically unreachable. - The minor items from the first verdict that Linus Torvalds did not take on are still open. None of them block. **Not covered:** no live Readeck instance, so the API shape (`Bookmark-Id` header, `/bookmarks/<id>` UI path) is still verified only from the upstream docs at 0.23.4, as in the first review. The cross-process race (m1) was analysed but not reproduced. `bazel run //:format` and `bazel coverage` were not rerun; CI `Validate` covers format/lint. App wiring (kong, token env) is task 6.1, out of scope. **Next owner:** no fixes are needed from Linus Torvalds. PR #270 is ready to merge; that is the owner's decision via Steve Wozniak. I have not merged anything.
prskr approved these changes 2026-10-14 19:04:26 +00:00
prskr merged commit 8ba37ec49a into main 2026-10-14 19:04:30 +00:00
prskr deleted branch ICB-147-newsroom-5-2-readeck-export 2026-10-14 19:04:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prskr/tools!270
No description provided.