writeonce/tests/corpus/run/pricing-set-price-insert/fixture.wo
shoney.arickathil 30ef8d8533 feat: insert executes (iteration 9, Task 3) -- DB_STUB retires for insert
- compiler: `insert Class { ... }` is a typed Ast.Insert in statement
  AND expression position, sharing the ctor literal's field grammar;
  typechecked with the ctor's omittable rule; result = the row id (Int)
- owner pass: the engine copies at the row API, so an insert BORROWS
  its field values -- no transfer, no E304; node is trap-capable and
  carries a live-mask drop entry like DbStub did
- emit: builtin 61 window = class-id const + one slot per DECLARED
  field in declaration order; omitted defaults emitted, omitted ?scalar
  gets WO_NIL_SCALAR, other omitted optionals the zero word; fresh
  argument values reaped after (the push/set copy semantics)
- runtime: database/src/db.c executes via the choke-point row API;
  rt.db/rt.wal opaque handles on wo_rt; WO_DATA=<dir> = replay
  <dir>/shard-0.wal at boot + commit-before-ack per statement (the
  builtin's return IS the ack until iteration 8 ticks); failed commit
  un-applies the row and traps WO_T_IO; loader validates the class-id
  slot (variable window documented in wob.h + format doc)
- the promised diff: trap/pricing-set-price-db-stub is now
  run/pricing-set-price-insert printing engine-allocated ids;
  durability smoke prints 1,2 then 3,4 across two WO_DATA runs
- old "bare insert is an Ident" unit test rewritten to the new
  contract; runner's loader mirror accepts id 61; goldens re-blessed
- gates: oop-accept ALL CRITERIA MET, oop-e2e 71/0, woc-test 566/0,
  wovm-test green, log-watcher 7/0

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-15 11:15:06 +02:00

23 lines
716 B
Text

-- Pricing-demo corpus, iteration 9 Task 3: the fixture that used to prove
-- `insert` PARSES BUT TRAPS (DB_STUB, "engine not linked") now proves it
-- EXECUTES -- the plan's promised diff. `insert` is a typed statement AND
-- expression: it validates fields like a constructor literal and returns
-- the new row's id, allocated by the engine (shard 0 of 1: 1, 2, ...).
-- RAM-only here (no WO_DATA): the corpus never touches disk.
class Price {
amount: Int
}
class Product {
prices: multi Price
fn set_price(amount: Int) -> Int {
return insert Price { amount: amount }
}
}
fn main() {
let prod = Product { prices: multi_new() }
print_int(prod.set_price(4999))
print_int(prod.set_price(5999))
}