Commit Graph

2 Commits

Author SHA1 Message Date
ed956a1504 revert: drop AP_RPUTS single-arg patch and fn_HGet renames
Both workarounds existed because Five was missing two features that
just landed upstream:

  Five 7629f95 (variadic PValue) makes FUNCTION foo(...) / PValue()
  actually return the caller's variadic args instead of the caller's
  first LOCAL slot. AP_RPUTS / AP_ECHO can go back to their `( ... )`
  signature now.

  Five f3e0ffe (file-local STATIC FUNCTION) gives each .prg its own
  namespace for `STATIC FUNCTION name`, so the seven duplicate
  `STATIC FUNCTION fn_HGet` definitions across labdb's api/*.prg
  files no longer collide. The sed-renamed unique names can revert
  to the upstream definitions.

Files

  app/bridge/bridge_request.prg     ← cp from fivenode/native/
  app/api/{device-status,record-detail,records-list,session-detail,
           session-stats,sessions-list,session-export}.prg
                                    ← cp from fivenode/labdb/api/

fivenode-upstream is now byte-identical to fivenode_go's app/ copy
of those files. No more "// fivenode_go patch" comments, no more
file-prefix renames.

Verified end-to-end against the same live postgres@16 cluster:
  /api/admin-stats.prg    -> {"active_sessions":1,"devices":2,...}
  /api/sessions-list.prg  -> 2 rows w/ full session data
  /api/admin-devices.prg  -> 2 devices w/ api_key, created_at
  /api/hello.prg          -> hello (unchanged)
  /                       -> 200 text/html (static)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 17:36:14 +09:00
c72c2ff58d feat(bridge): port bridge_*.prg + wire HTTP↔bridge dispatcher
Pulls bridge_context.prg, bridge_request.prg, bridge_session.prg, and
bridge_cookie.prg from upstream fivenode into app/bridge/ so the
mod_harbour AP_* surface (AP_METHOD, AP_BODY, AP_ARGS, AP_USERIP,
AP_RPUTS, AP_JSONRESPONSE, AP_SETCONTENTTYPE, ctx_get, ctx_set, ...)
runs unchanged on top of fivenode_go's Go RTL.

bridge_main.prg deliberately omitted — its REQUEST sweep pulls in
TDrMySQL / hbct / hbcurl symbols fivenode_go neither has nor needs.
fivenode_go runs ahead-of-time with the Five compiler, so the
REQUEST trick that keeps fnb-runtime symbols alive isn't required.

One upstream patch was unavoidable: AP_RPUTS / AP_ECHO were variadic
(`( ... )`) and used PValue() to walk caller args. Five's PValue
returns the caller's LOCAL slot (not the actual variadic args, which
aren't copied into locals when declared params is 0), so the body
came back as "1" instead of the JSON payload. Collapsed both to a
single-argument form; every call site in fivenode_go already passes
exactly one value. Patched-out spots are marked with a TODO so we
can revert once Five gains real variadic PValue support.

app/bridge_server.prg ties it all together: starts httpserver on
:8090 with BRIDGEDISPATCH as the handler, hand-translates the Go
request hash into the ctx fields the AP_* layer reads, dispatches by
URL path (hard-coded /api/hello and /api/echo for now — file-name
dispatch lands in 1a.4), and assembles the response from the buffered
AP_* output + ctx_get("status") + ctx_get("headers_out").

Verified end-to-end:
  GET  /api/hello                       -> 200 JSON, method/ip echoed
  POST /api/echo?lang=ko (16-byte body) -> 200 JSON, body_parsed,
                                           query, user-agent
  GET  /api/nope                        -> 404 JSON

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 10:54:12 +09:00