5 Commits

Author SHA1 Message Date
0e80b93d0a docs(pgserver): Phase 7 — bootstrap example + CI gate documentation
Wraps the v1.0 PG-wire deliverable with the two pieces operators
actually look for: a runnable example PRG and an updated CI gate
list in CLAUDE.md.

* examples/pgserver_demo.prg — full bootstrap PRG demonstrating
  every HB_FUNC composed in the order a production deployment
  needs:
    PG_TLS_SELF_SIGNED → PG_ADD_ROLE × N → PG_ALLOW_IP × N →
    PG_SERVER_START( ":5432", "md5" )
  Comments cover the SHARED-DBF integration point and the SPAWN
  idiom for non-blocking server startup. Builds cleanly under
  the examples_build sweep (now 66/72; was 65/71).

* CLAUDE.md — the "어떤 파일이든 수정한 후" mandatory test list
  goes from 3 gates → 6:
    1. go test ./...
    2. FiveSql2 SQL:1999 43/43
    3. Harbour compat 56/56
    4. std.ch 17/17 (added)
    5. FRB 7/7 (added)
    6. pgserver integration 6/6 (added — psql required)
  Aligns the rule-of-thumb with reality. The five suites already
  ran on every audit-era commit; pgserver/run.sh is new in
  Phases 3-6 and now joins them.

This completes the v1.0 PostgreSQL-wire frontend. End-to-end
checklist:

  Phase 1: per-session state isolation         [93cf5c8]
  Phase 2: SimpleQuery wire MVP                [d98f5e1 7083297]
  Phase 3: DML + transactions                  [a556764]
  Phase 4: Extended Protocol (Parse/Bind/Exec) [8472928]
  Phase 5: password + MD5 auth                 [90eafcf]
  Phase 6: TLS + IP allowlist                  [3b2dd36]
  Phase 7: example + docs                      [this commit]

Open follow-ups (Phase 7.x):
  - hbrdd workarea per-thread isolation (audit Top-Risk #2):
    ≥3 concurrent connections doing in-flight INSERT/SELECT in
    their own transactions can race at the workarea layer. Fix
    is a separate workstream against hbrtl/database.go +
    hbrdd/dbf/. Documented limitation in tests/pgserver/run.sh.
  - SCRAM-SHA-256 auth (Phase 5.1).
  - pg_catalog shim for BI-tool introspection (Phase 1.1+ of the
    original audit plan).
  - Binary parameter format for NUMERIC/TIMESTAMP (Phase 4.1).

All gates green:
  go test ./...               ✓
  FiveSql2 SQL:1999 43/43     ✓
  Harbour compat 56/56        ✓
  std.ch 17/17                ✓
  FRB 7/7                     ✓
  examples 66/72              ✓ (+1 from new pgserver_demo)
  pgserver integration 6/6    ✓

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 15:20:44 +09:00
66882c30bd fix(cdx): Harbour-compatible layout — compound root, RCHB sig, leaf format
Align Five's CDX file layout with Harbour's expectations:
- Compound root header at 0, compound leaf at 1024, tags at 1536+
- "RCHB" signature at offset 20 in compound root
- IgnoreCase/collation flags at offset 503-505
- Compound leaf: LeftPtr/RightPtr = 0xFFFFFFFF, recBits=16 fixed
- Tags sorted alphabetically in compound directory B-tree
- Tag IndexOpt: TypeCompact | TypeCompound (0x60)

Status of Harbour cross-read verification:
- CHAR-only CDX tags: layout matches Harbour byte-for-byte
- Numeric tags: Harbour uses IEEE double (8-byte) key encoding,
  Five uses DBF ASCII key bytes — causes DBFCDX/1012 corruption
  when Harbour reads Five-created CDX with numeric tags
- Five reading Harbour CDX: works perfectly (existing)
- Five reading Five CDX: works perfectly

Remaining: numeric key encoding for full Harbour write-compatibility.
CLAUDE.md updated to reflect this single remaining limitation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 01:33:52 +09:00
4d5621c21a feat: CDX compound index write + {||} parsing + zero known constraints
All 3 remaining known constraints resolved. CLAUDE.md now shows zero.

1. CDX compound index WRITE support (was read-only)

   New file: hbrdd/cdx/build.go (~400 LOC)
   - CreateOrAddTag() builds Harbour-compatible CDX files
   - Bit-packed leaf pages (RecBits/DupBits/TrlBits compression)
   - Interior nodes with big-endian RecNo/ChildPage
   - Compound root directory (structural B-tree of tag names)
   - Append-safe: preserves existing tags when adding new ones
   - Linked leaf pages (LeftPtr/RightPtr for sequential scan)

   Pipeline: INDEX ON expr TAG tagname TO file
   - ast.IndexCmd gains TagName field
   - Parser captures TAG name (was discarded)
   - gengo passes TagName to OrderCreateParams
   - indexer.go routes to cdx.CreateOrAddTag when TAG specified

   Verified: 3 tags (BYNAME/BYCITY/BYAGE), OrdSetFocus by name,
   SEEK, GoTop/GoBottom, close+reopen with SET INDEX TO

2. {||} empty code block parsing in function arguments

   Parser's parseArrayOrBlock() called parseExpr() unconditionally
   after closing |, failing when body was empty ({||}).
   Fix: check for RBRACE after closing | and emit NIL literal body.
   {=>} empty hash already worked.

3. Semicolon IF...ENDIF — already worked (removed from constraints)

Tests:
  go test ./...        14 packages ALL PASS
  FiveSql2             43/43 100%
  compat_harbour       51/51

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 22:58:09 +09:00
e5d27951fd docs: update CLAUDE.md — remove resolved constraints, update metrics
9 constraints resolved (2026-04-11~13), 3 remain.
Test metrics updated: 483 RTL, 258 PRG tests, Harbour parity diff 0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 18:54:14 +09:00
486e466592 feat: FiveSql2 43/43, @byref, mutable closure, RTL 479, DateTime fix
Major changes since last commit:
- FiveSql2 SQL:1999 engine (10,458 LOC) — 43/43 ALL PASS
- 21 compiler/runtime bugs fixed (short-circuit AND/OR, FOR LOOP, etc.)
- @byref pass-by-reference via RefCell pattern
- Mutable closure capture (EnsureLocalRef + RefCell sharing)
- RTL: 400 → 479 functions (+79: file, string, datetime, hash, UTF-8)
- DateTime/Timestamp fully working (hb_DateTime, hb_Hour/Min/Sec, display)
- Reserved word guard (39 keywords blocked from function calls)
- AEval arg order fix (element before index)
- Closure capture redecl fix (unique _cap_ names per block)
- Hash/string indexing in ArrayPush/ArrayPop
- Harbour compat test suite: 51/51
- 4 docs: Porting Report, Implementation Plan, Optimization Plan, Commercialization

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 11:35:37 +09:00