<feed xmlns='http://www.w3.org/2005/Atom'>
<title>guess-market/service/src/main, branch 3.0</title>
<subtitle>definitely not polymarket
</subtitle>
<id>https://git.sartin.in/guess-market/atom?h=3.0</id>
<link rel='self' href='https://git.sartin.in/guess-market/atom?h=3.0'/>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/'/>
<updated>2026-10-09T12:32:33Z</updated>
<entry>
<title>catalog: make Loader a stream-based strategy</title>
<updated>2026-10-09T12:32:33Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-10-09T12:32:09Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=9c1a10712a724b448de9e066ff76f97059c86b40'/>
<id>urn:sha1:9c1a10712a724b448de9e066ff76f97059c86b40</id>
<content type='text'>

Loader was tied to the disk: load(Path) did its own file checks and
opening, so the v3 loader, which reads HTTP uploads, could not
implement it, and the server had to hand its catalog a stub loader
that refused everything.

Reduce Loader to a single strategy method, load(InputStream, source,
owner). The v1, v2 and v3 loaders are now interchangeable
implementations, picked by wiring: v1 for the console, v2 for the
desktop, v3 for the server. The owner is the uploading user; v1 and v2
ignore it because their files name their own Market Makers.

Opening a file by path is now LocalCatalogContext.loadEvents' job,
with the same INVALID_PATH, FILE_NOT_FOUND and NOT_XML errors as
before. The server catalog uses the v3 loader directly. A path load
there passes no uploader, which v3 refuses, so nothing reaches the
server's market except an upload.

Drop Loader.seed, which every loader implemented by throwing and
nothing called.


</content>
</entry>
<entry>
<title>account: let users deposit cash into their account</title>
<updated>2026-10-09T07:19:12Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-10-09T07:18:41Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=246c1ab5ffce1a1bb3c0534868b29f6e4c862a62'/>
<id>urn:sha1:246c1ab5ffce1a1bb3c0534868b29f6e4c862a62</id>
<content type='text'>

Exercise 3 replaces the fixed initial cash of Exercise 2 with accounts
that users top up themselves. Add AccountContext.deposit, which credits
a DEPOSIT entry through LedgerContext so it carries a timestamp and a
running balance like every other ledger movement, and return the
updated account.

The amount crosses the api boundary as a string, like all money values.
Reject anything that is not a positive number with at most two decimal
places instead of rounding it, so a user is never credited a different
amount than they asked for. A deposit can bring a negative account back
above zero, which lifts the block.


</content>
</entry>
<entry>
<title>catalog: add cumulative v3 XML loader and event mapper</title>
<updated>2026-10-08T13:45:30Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-10-08T13:45:02Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=95eb4ff500defc4e34d043bbc096593ffcadecea'/>
<id>urn:sha1:95eb4ff500defc4e34d043bbc096593ffcadecea</id>
<content type='text'>

Exercise 3 uploads arrive over HTTP and must never be written to the
server's disk, so load Schema v3 straight from an InputStream. Each
valid file is appended to the market rather than replacing it, and the
uploading user becomes the Market Maker of every event in it.

With no id in v3, the mapper keys events by their trimmed name, so the
repository's case-insensitive lookup finds them by name. Display ids
continue from the current market size.

The whole file is validated and mapped before anything is added, so a
rejected upload leaves the market as it was. Loading is synchronized
so two concurrent uploads cannot both pass the name-collision check.
DTDs and external entities are disabled on the parser, since the input
is untrusted and an XXE payload could otherwise read server files.

Check the loader against the course's Exercise 3 sample files, kept
with their schema under test-data/ex-3/.


</content>
</entry>
<entry>
<title>catalog: add v3 XML validator for cumulative uploads</title>
<updated>2026-10-08T08:24:45Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-10-08T08:24:18Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=930eb953e8cb598a99002cb41f3b8f57d05f1fa7'/>
<id>urn:sha1:930eb953e8cb598a99002cb41f3b8f57d05f1fa7</id>
<content type='text'>

Schema v3 drops event ids and users, and uploads now add to a live
market instead of replacing it. Validate a v3 document against the
Exercise 1 rules (commission 0-90%, positive b and d, non-negative
initial inventory, a known trading method), require exactly two
options per event, and treat the event name as its identity: reject
names that repeat within the file or collide with an event already in
the repository, ignoring case and surrounding whitespace.

The validator works on the unmarshalled object graph only and never
touches the repository beyond reading it, so a rejected upload leaves
the market untouched.


</content>
</entry>
<entry>
<title>service: add sell orders, event lifecycle and order book matching</title>
<updated>2026-09-07T13:03:14Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-09-07T13:03:14Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=8d7cecd9cf9fb2b0b45607b8efd7ca8f19a89fc6'/>
<id>urn:sha1:8d7cecd9cf9fb2b0b45607b8efd7ca8f19a89fc6</id>
<content type='text'>
Carry the order side from the context through risk, the trading
mechanisms, fulfillment and settlement, so users can sell shares as
well as buy them.

The order book now matches priced limit orders from named users, rests
any unfilled remainder, and prevents self-trades. In a binary market
with minting enabled, a buy can also match a bid on the other option
to mint a new YES/NO pair, and a sell can match an ask there to merge
a pair back into the pool. LMSR gains a sell that refunds the cost
difference from the pool.

Add createEvent and openEvent to the catalog. Events start as DRAFT and
only take the market maker's subsidy when they are opened, which fails
if the market maker can't cover it. Add LocalAccountContext to expose
user ledgers.

Tighten the risk checks: reject orders from blocked accounts, on events
that aren't ACTIVE, and at prices outside (0, d). Sells need enough
unreserved shares; buys need enough balance to cover commission and
cash already committed to resting bids.

Settlement now cancels resting orders, pays out on shares still held
rather than shares ever bought, sends order book commission to the
market maker, and returns unused LMSR subsidy. Events also track
per-user cash flow, so the event detail can list participants with
their holdings, fees and P&amp;L next to the order books.
</content>
</entry>
<entry>
<title>service: add ex-2 XML loader and carry order side through matching</title>
<updated>2026-09-06T12:42:59Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-09-06T12:42:59Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=1cf436ccd3efd45d67749102363b9a7f0d242c54'/>
<id>urn:sha1:1cf436ccd3efd45d67749102363b9a7f0d242c54</id>
<content type='text'>
Ex-2 documents declare users and their market-maker assignments next
to the events, and the loader has to reject files that are
schema-valid but logically inconsistent, which the v1 loader has no
notion of.

Add XMLLoaderV2, which checks the extension, unmarshals the document,
runs it through XMLValidatorV2 and only then replaces the event and
user repositories, so a rejected file leaves the previous catalog
intact. The validator enforces unique positive event ids, non-empty
names and descriptions, commission within 0..90 with a known type, at
least two distinct options, a positive LMSR b or order-book d with
non-negative initial inventory, unique user names, positive initial
cash, and exactly one existing event per market-maker reference. Let
EventMapperV2 take the resolved market maker's name so it lands on the
domain event.

Give Order a side and the placing user, and Trade the seller, so an
order book can match a buyer against a seller. Keep the previous
constructors, defaulting to a BUY with no user or seller, so existing
LMSR call sites stay unchanged. Route LocalMatchingEngine through the
mechanism's placeOrder with side, user and limit price instead of
buy(), and have cancelOrder take the order to cancel.

Also add an isBlocked query to User and Ledger for accounts that went
negative.
</content>
</entry>
<entry>
<title>ex-2: add invalid-input fixtures and wire ui-desktop to the service</title>
<updated>2026-09-06T07:36:54Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-09-06T07:36:54Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=508898f52c16cc737bc7d08b8ee4c29fab8d1146'/>
<id>urn:sha1:508898f52c16cc737bc7d08b8ee4c29fab8d1146</id>
<content type='text'>
The ex-2 loader has to reject documents that are schema-valid but
logically broken, and so far only error-2.xml and error-3.xml exercised
that path. Add one fixture per validation rule under
test-data/ex-2/invalid, each a copy of small.xml with a single defect
described in a leading comment: a non-.xml extension, a duplicate event
id, commission outside 0..90 on either side, a duplicate user name,
zero or negative initial cash, a market maker referencing an unknown
event, and an event with no market maker or with two.

Teach LedgerMapper to map individual LedgerEntry records to
LedgerEntryDTO, renaming id to seq and time to at and rendering the
timestamp through InstantOptions.humanize, so callers can show a ledger
history rather than only the account summary.

Make ui-desktop depend on api and service in the build tooling and in
its Eclipse classpath, since the desktop UI now talks to the service
layer directly, and put lib/openjfx on java.library.path for the test
run so tests touching JavaFX can load its native libraries.
</content>
</entry>
<entry>
<title>catalog: add generated v3 JAXB binding and ex-2 test data</title>
<updated>2026-09-06T06:21:37Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-09-06T06:21:37Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=da82f3b492c3cd36f2e8723632a63a6cc1f4e39b'/>
<id>urn:sha1:da82f3b492c3cd36f2e8723632a63a6cc1f4e39b</id>
<content type='text'>
The ex-2 schema describes a nested Guess-Market/GM-events document in
which every event carries its pricing mechanism inline, as either a
GM-LMSR element holding the liquidity parameter b or a GM-order-book
element holding the allow-mint, initial and d attributes, instead of
naming a mechanism and passing its parameters separately.

Add the xjc-generated classes for that schema under catalog.model.v3,
along with the fixtures the loader will be tested against: small.xml
with two events, one per mechanism, multiple.xml with four, and two
negative cases -- error-2.xml, where a market maker is funded with
zero initial cash, and error-3.xml, where a market maker points at
event id 12, which no event declares -- so the cross-reference and
funding checks have something to reject.

The binding covers the GM-events subtree only. The GM-users half of
the document and the per-event id element are not bound yet, so
nothing reads these classes so far.
</content>
</entry>
<entry>
<title>model: relocate market DTOs out of the flat api package</title>
<updated>2026-08-23T14:05:29Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-08-23T14:05:29Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=843820ea9f357220d69f3795f3289ee41eed355c'/>
<id>urn:sha1:843820ea9f357220d69f3795f3289ee41eed355c</id>
<content type='text'>
Move AccountDTO/MarketDTO/MarketStateDTO/PurchaseReceiptDTO/TradeRowDTO
out of the catch-all api package into model.market (and LedgerDTO into
model.ledger), matching the existing model.event convention so DTOs
live next to the domain they describe rather than in the interface
package. Relocate LedgerMapper from mapper.v2 to infrastructure.adapter
to match the module's established package layout, and update all call
sites and imports accordingly.

Also register the ui-desktop module in the build tooling: add it to
MODULES, add openjfx to the shipped runtime libs, and generalize
package.sh so each executable module (ui-console, ui-desktop) gets its
own Main-Class/Class-Path manifest and run script instead of
special-casing ui-console. Fold long Class-Path manifest lines at 72
bytes per the JAR spec, since adding ui-desktop's dependencies pushed
the line past the limit.
</content>
</entry>
<entry>
<title>Add MapStruct LedgerMapper and wire annotation processing into build.sh</title>
<updated>2026-08-20T14:39:50Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-08-20T14:39:50Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=fbfd2e275e9d645e4ec8a1874bc57d98b1c38300'/>
<id>urn:sha1:fbfd2e275e9d645e4ec8a1874bc57d98b1c38300</id>
<content type='text'>
build.sh now passes -processorpath/-s so MapStruct's generated impl
compiles alongside hand-written sources.
</content>
</entry>
</feed>
