Commit Graph
100 Commits
Author SHA1 Message Date
angel e0735854ce stubbed CLAUDE.md and AGENTS.md 2026-08-20 00:24:04 -06:00
angel 16a3551d08 updated readme 2026-08-20 00:24:04 -06:00
angelandClaude Sonnet 5 f9f9dfa25b reports: add test coverage for GetListingCountsOverTime/Report
mock.shop_amazon_listing_counts is a recursive view that computes a
running inventory count: starting from the listing's base count in
mock.shop_amazon_listings, it walks mock.raw_shop_events in order,
applying each event as a delta (sale/refund) or an absolute reset
(inventory-reset), per mock.shop_amazon_listing_event_sequence's
interpretation of each row's JSON payload. This is the first test to
exercise that view directly rather than just the Go code around it.

Fixture uses the real SaveNewMockSale/SaveNewMockRefund/
SaveNewMockInventoryReset methods - the same entry points the
simulate-sale/refund/inventory UI uses - rather than hand-rolling the
JSON payload shape, so the test tracks the real payload contract.

Covers the full running-count sequence (base -> sale -> refund ->
reset), the unknown-listing ErrNotFound case, and
GetListingCountsReport's MaxCount/MinCount over that sequence.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XEDaCB7C2NEBgyvqEtZuxY
2026-08-20 00:24:04 -06:00
angelandClaude Sonnet 5 d05732d60c reports: add test coverage for GetRawShopEvents
Covers the happy path (ordering by event_timestamp DESC/event_id ASC,
Platform/ShopID fields, RawPayload round-tripping through jsonb), the
empty-shop case, and the unknown-shop ErrNotFound case (via the
accts.GetMockShop check GetRawShopEvents does before querying).

setupAmazonMockShop creates a real account + Amazon mock shop via the
same Store methods the app uses (CreateAccount, CreateMockShop) and
registers cleanup in FK-safe order.

GetListingCountsOverTime/GetListingCountsReport coverage is a separate,
larger task (needs a listing plus count-changing history feeding a DB
view) - not done here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XEDaCB7C2NEBgyvqEtZuxY
2026-08-20 00:24:04 -06:00
angelandClaude Sonnet 5 57136cfc8b amazon: reconnect the LISTEN connection on failure instead of dying
A dropped connection, a Postgres restart, or any other error on the
dedicated LISTEN connection previously propagated all the way out of
ProcessEvents, and main.go's top-level shutdown logic treats that
error channel firing the same as a fatal server error - taking down
the entire application over a hiccup on one background connection that
has nothing to do with serving HTTP traffic. This matters more with
eleven other platforms already sharing the same trigger+notify shape
in the migrations with no Go processor yet.

Adds (*Mocks).reconnectOrStop: on a real failure (not an ordinary
shutdown), logs a warning and re-establishes LISTEN after a backoff
that starts at 1s, caps at 30s, doubles on repeated immediate
failures, and resets once a reconnect actually succeeds.
ProcessEvents' select no longer returns on a LISTEN error - it loops
back in with fresh channels instead.

Verified against a genuinely killed connection (pg_terminate_backend,
targeting the backend via pg_stat_activity matched on its LISTEN
query text), not a simulated one - both in a manual check and in the
new TestProcessEvents_ReconnectsAfterListenConnectionDrops test.

Closes out all four insights from the domains/amazon design review.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XEDaCB7C2NEBgyvqEtZuxY
2026-08-20 00:24:04 -06:00
angelandClaude Sonnet 5 af46cd1270 amazon: make the poll fallback interval configurable and observable
ProcessEvents' safety-net poll was a bare time.Minute literal inline in
its select statement - no way to verify the fallback path works without
waiting 60+ seconds in a test, no way to tune the cadence without a code
change, and no way to tell afterward whether a given loop iteration was
triggered by a real NOTIFY or by the poll timer.

Adds Mocks.pollInterval (default time.Minute) and a WithPollInterval(d)
builder, mirroring WithNotifyRetryAfter's existing pattern - deploy-time
configurable via construction, not a live/API-adjustable knob, and not
wired through .env, matching how notifyRetryAfter already works.

Adds a Debug log line on each of the two meaningful wake-up branches so
which path fired is now observable.

New test proves the poll branch actually works without waiting or
touching the shared DB trigger (which would be unsafe against the real
dev DB): it reuses the retry mechanism from the previous commit so a
second dispatch can only come from the poll timer, since nothing else
ever notifies again for the rest of the test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XEDaCB7C2NEBgyvqEtZuxY
2026-08-20 00:24:04 -06:00
angelandClaude Sonnet 5 1fd75ea675 amazon: replace fire-and-forget listener notifications with ack-based retry
Dispatching an event to the listener previously happened from an
un-awaited goroutine, with only a log line on failure - once
processed_at was set, a dropped or failed notification was permanently
and silently lost, with no way to tell it had happened.

Replaces the processed/processed_successfully booleans with a
notified_at/processed_at pair (migration 000031): the dispatcher sets
notified_at and hands the event to MockEventListener.Notify, which now
also receives an ack callback the listener calls whenever it's truly
done, synchronously or arbitrarily later. Anything still "notified" but
unacked past notifyRetryAfter (a tunable field, not a stored
per-row timestamp) gets notified again on the dispatcher's normal
poll/reactive loop - no new retry mechanism needed. ack is idempotent,
since a late ack from an earlier attempt and one from a retry can both
eventually fire for the same event.

Dispatch is deferred until after the transaction that recorded
notified_at has actually committed, so ack's independent write can't
race a still-open transaction it implicitly depends on being visible.

The real SSE listener (server/sse/db_event_publisher.go) acks inline,
since its work is synchronous.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XEDaCB7C2NEBgyvqEtZuxY
2026-08-20 00:24:04 -06:00
angelandClaude Sonnet 5 e063fb66d4 amazon: add a Ready() signal for ProcessEvents' LISTEN registration
Tests (and any other caller) previously had no way to know when the
Postgres LISTEN behind the reactive event-processing loop had actually
registered, forcing a guessed sleep before relying on it. Mocks now
exposes Ready() <-chan struct{}, closed once listenForNotifications
successfully issues LISTEN. Purely additive - ProcessEvents' signature
is unchanged.

Updates the integration tests to wait on Ready() instead of a flat
sleep, which also cut TestProcessEvents_ReactsToNotification's runtime
from ~0.25s to ~0.06s with no flakes across repeated runs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XEDaCB7C2NEBgyvqEtZuxY
2026-08-20 00:24:04 -06:00
angel 4d43b7e039 store api research 2026-08-20 00:24:04 -06:00
angel 9c9b33e34f Claude-assisted improvements (untested)
- dev auth flow (side-step OAuth)
- db event processing integration tests
- dev scripts (eg Makefile)
- db / test db migration setup scripts.
2026-08-20 00:24:04 -06:00
angel fb2f4255f4 prototyped svg reports
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Tests / Go tests (push) Failing after 15s
2026-08-20 00:23:54 -06:00
angel 55a3694d89 amazon events published as server side event 2026-08-20 00:23:54 -06:00
angel 40afd176e7 mock amazon event processing stubbed 2026-08-20 00:23:54 -06:00
angel 9f86b8e95c bad logs
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Tests / Go tests (push) Successful in 20s
2026-08-20 00:23:41 -06:00
angel fa3db63ad2 protoype: list raw events on mock mode reports page 2026-08-20 00:23:41 -06:00
angel 0e0422545b mock events saved to db 2026-08-20 00:23:41 -06:00
angel e4e2bd992b mock events db schema 2026-08-20 00:23:41 -06:00
angel 20bbbe33ca regenerated diagrams 2026-08-20 00:23:41 -06:00
angel 496310c93a fixed mock mode button; shortened simulation tabs 2026-08-20 00:23:41 -06:00
angel 25615fabc6 MockMode: made global in templates; increase bort of navbar in mock mode 2026-08-20 00:23:41 -06:00
angel f30d4a3140 stubbed simulations page content: set inventory 2026-08-20 00:23:41 -06:00
angel 793ca05fd4 stubbed simulations page content: refund 2026-08-20 00:23:41 -06:00
angel 9971ff3266 stubbed simulations page content: sale 2026-08-20 00:23:41 -06:00
angel 46a5d0ee55 initial gitea test workflow
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
Tests / Go tests (push) Successful in 17s
2026-08-20 00:23:17 -06:00
angel 3c9ce65335 demo action
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
2026-08-19 23:16:45 -06:00
angel 8ea8192853 stubbed page: simulations 2026-02-27 16:39:54 -07:00
angel 370e50a174 fix: unable to save mock sync group being edited 2026-02-26 23:49:48 -07:00
angel ee5557cca1 mock mode: removed subnav - keep navbar in sync with mock mode 2026-02-26 23:44:11 -07:00
angel d34810555a cleaned up api routes 2026-02-26 23:03:38 -07:00
angel c6b8a9a00d mock mode: database queries implemented and checkbox on account page built 2026-02-26 22:54:58 -07:00
angel 85817a4adb mock sync group editing: edit, save, and delete listings 2026-02-25 22:41:36 -07:00
angel ae031411b8 updated favicon 2026-02-25 22:30:31 -07:00
angel 4352062227 mock sync group editing: made tables columns more consistent; initialize database rows upon editing 2026-02-20 23:04:18 -07:00
angel 5ec4fe67b0 auth: expose more auth info in gin context to support future login redirect capability 2026-02-18 22:28:03 -07:00
angel a3ae872e9d updated mock sync group accordions: editing state; cancel editing 2026-02-17 19:35:12 -07:00
angel 7ef4638daa added Edit Group button to mock sync group accordion 2026-02-17 18:29:34 -07:00
angel d04a57beec moved mock syn group list item to component 2026-02-17 17:11:08 -07:00
angel 34a7cf42a7 hide new sync group table tooltip 2026-02-17 16:53:10 -07:00
angel b8f703cda4 accordion: make smooth animation toggleable 2026-02-15 13:39:31 -07:00
angel c0966ceeb4 fixed mock sync group table styles 2026-02-14 20:07:18 -07:00
angel b53fb18737 eliminated bad hx-swap-oob on mock inventory page 2026-02-14 19:02:50 -07:00
angel aefcfea0f9 replaced remaining details elements with accordion component 2026-02-14 01:43:30 -07:00
angel 6838d13c7a updated templater library; added accordion component 2026-02-14 01:29:28 -07:00
angel 95ef64ce18 ability to delete mock sync groups 2026-02-10 18:05:30 -07:00
angel 0944703d2a removed intermediate /internal directory 2026-02-09 13:40:31 -07:00
angel b155280081 mock shop sync group listing draft page 2026-02-08 12:31:10 -07:00
angel e3b2dd3377 move shops to new page; live vs mock navbar 2026-02-06 16:37:55 -07:00
angel 548f72d9a4 improved mock shop listing style 2026-02-05 18:29:32 -07:00
angel 0ffde6e83d mock shop page: can set count 2026-02-05 18:24:47 -07:00
angel 0e36012e6d mock shop page: can delete listings 2026-02-05 17:18:56 -07:00
angel e7f39d69b3 mock shop page: store listing search in query 2026-02-05 12:00:12 -07:00
angel 24ebf2742f mock shop page: case-insensitive search 2026-02-05 11:07:07 -07:00
angel 0924d0edb1 mock shop page: search listings 2026-02-05 11:02:29 -07:00
angel 02893511ba mock shop page: order listings 2026-02-05 10:33:39 -07:00
angel 925e2b9db8 mock shop page allows updating of listings 2026-02-05 10:17:19 -07:00
angel d187fbc0f4 mock shop page now more mobile friendly 2026-02-04 23:44:08 -07:00
angel c61f291dba stubbed updating of saved mock listing 2026-02-04 23:33:04 -07:00
angel 813fbb11b1 saved mock listing 2026-02-04 22:48:57 -07:00
angel a8dda86882 stubbed mock shop creation route 2026-02-03 08:28:07 -07:00
angel e74854bf6e ability to mock stores stubbed 2026-01-30 00:55:17 -07:00
angel b1593e8202 reorganized account page component templates more 2026-01-29 21:39:51 -07:00
angel 2b7e200e43 reorganized account page component templates 2026-01-29 21:30:58 -07:00
angel b5ac158ae1 used reusable button component 2026-01-29 20:54:24 -07:00
angel 2e57c7237f deleted unused file 2026-01-29 20:52:04 -07:00
angel 2eaa0fcf3a stubbed mock shop creation forms 2026-01-29 20:49:28 -07:00
angel 12ba219ef9 tooltip component 2026-01-29 18:52:54 -07:00
angel 9ae8745b12 account page: popover instructions prototype 2026-01-28 20:43:12 -07:00
angel 8f38f141e5 account page: fixed platform reordering bugs 2026-01-28 02:14:27 -07:00
angel a50c0ef18d account page: can now reorder entries under shops sections by drag and drop 2026-01-26 13:51:40 -07:00
angel a2d8993e0e updated accounts page: transition the store details when opening 2026-01-25 02:06:54 -07:00
angel 2b1cc7af75 updated accounts page: display user info and list shops 2026-01-25 01:23:52 -07:00
angel 1c305cd494 basic account creation flow created 2026-01-24 16:45:38 -07:00
angel 7d37fae332 fixed sync group draft listing component 2026-01-24 14:24:34 -07:00
angel 70eeead0c2 old comment 2026-01-24 14:21:54 -07:00
angel 50325e7cf7 replaced sync-group api redirect response with 200s and 201s 2026-01-24 14:21:39 -07:00
angel eacbea473c fix account paths comments 2026-01-24 14:14:44 -07:00
angel 8438c26d88 moved middleware auth to auth package 2026-01-24 14:10:34 -07:00
angel a6267ac189 moved middleware event publisher to sse package 2026-01-24 14:06:19 -07:00
angel 720c3fb4e0 moved templates package into ui dir 2026-01-24 13:37:11 -07:00
angel d8c7427eb2 cleaned up unused middleware 2026-01-24 13:29:32 -07:00
angel e0597b31e8 organized api packages into a unified constructor 2026-01-24 13:12:54 -07:00
angel d6d0bf1b4c cleaned up webhooks package 2026-01-24 12:47:54 -07:00
angel ff231897df server better organized 2026-01-24 12:41:32 -07:00
angel 7154494016 var rename 2026-01-24 12:22:32 -07:00
angel 52b4d18236 auth clean up and redirect fixes 2026-01-24 12:20:11 -07:00
angel e4069e18e2 moved auth into middleware 2026-01-23 23:34:22 -07:00
angel 649595718c new response middleware functions to simplify middleware 2026-01-23 22:16:11 -07:00
angel 3fd533091c gin error handler 2026-01-23 21:33:36 -07:00
angel b9464adada fix create account link; more dev data 2026-01-23 20:13:41 -07:00
angel 1509d39373 profile popover in footer 2026-01-23 04:24:24 -07:00
angel a44a727c92 stop draft sync group table from scrolling when updated 2026-01-23 02:46:09 -07:00
angel 3d70d08dac split oauth_tokens.claims column up; improved fonts; allow multiple sse connections per user; make navbar and use friendly 2026-01-23 02:31:34 -07:00
angel 38aa3796b9 mock shops more spelled out 2026-01-22 15:14:44 -07:00
angel b182685ec3 mock store tables stubbed in db schema 2026-01-21 20:15:44 -07:00
angel 321bc6fc00 regenerate diagrams and styles 2026-01-21 19:21:17 -07:00
angel d44c4a3228 removed Draft 2 comment 2026-01-21 00:44:31 -07:00
angel c4348d6d3d updated draft sync group table buttons upon table change 2026-01-21 00:40:33 -07:00
angel de18de49e9 update sync group draft table shop listing options based on selected shops 2026-01-20 23:25:03 -07:00
angel 4f2ae26d58 filter ss events by account 2026-01-20 21:11:02 -07:00
angel 1130366bf5 sse support 2026-01-20 20:48:19 -07:00