<feed xmlns='http://www.w3.org/2005/Atom'>
<title>guess-market/service/src/test, 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>tests: cover the ex-2 loader, order book trading and desktop state</title>
<updated>2026-09-10T08:55:50Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-09-10T08:55:50Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=1a8b75f96f0c6855581be3a38069f09eca37d1f5'/>
<id>urn:sha1:1a8b75f96f0c6855581be3a38069f09eca37d1f5</id>
<content type='text'>
Add tests for the behaviour introduced in the last few commits, so
later changes to matching, settlement or the UI state can't quietly
break it.

On the service side, Ex2LoaderTest loads the ex-2 fixtures and checks
that every invalid file is rejected for its own reason, including
events with no market maker or two of them, and v1 files. The order
book tests cover buys and sells that match or rest in the ladder,
self-trade prevention, cash and shares reserved by resting orders,
price bounds, risk rejections, and resolution cancelling resting
orders and paying the holders. A simulation checks that LMSR
settlement conserves money.

LedgerMapperTest used to pin the unmapped seq and at fields to their
defaults. Now that the mapper fills them from the entry id and time,
assert the real values and add a case for a null time.

On the desktop side, AppStateTest drives the real ServiceEngine through
loading, event creation, LMSR and order book trading, and checks that
the observable state updates. Smaller tests check chart timestamps,
money and probability formatting, and that every animation settles on
its final frame, which is what the UI shows when animations are off.
</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>
<entry>
<title>Move CommissionTiming and MechanismType into model.event package</title>
<updated>2026-08-20T09:09:20Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-08-20T09:09:20Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=0fc488c3f9e29f5e9f1092f8081714c9e820f178'/>
<id>urn:sha1:0fc488c3f9e29f5e9f1092f8081714c9e820f178</id>
<content type='text'>
Groups them with the other event-domain enums instead of the general
api package, and updates all call sites accordingly.
</content>
</entry>
<entry>
<title>Break down purchase receipts by cost/commission, harden XML validation and state I/O</title>
<updated>2026-08-18T15:19:50Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-08-18T15:19:50Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=755d2265054e5140e82d322681566c3034583c95'/>
<id>urn:sha1:755d2265054e5140e82d322681566c3034583c95</id>
<content type='text'>
Adds a full pre-load validation pass for GM XML seeds (ids, names,
options, commission, LMSR liquidity), replaces IO.print with
System.out, and surfaces detailed error messages across load/save
commands instead of generic failures.
</content>
</entry>
<entry>
<title>Split DTOs into api/model, extract order matching into service/matching</title>
<updated>2026-08-16T18:50:15Z</updated>
<author>
<name>Kostya</name>
<email>mail@sartin.in</email>
</author>
<published>2026-08-16T18:50:15Z</published>
<link rel='alternate' type='text/html' href='https://git.sartin.in/guess-market/commit/?id=eed9265be711432f40247f149c07f9e33511192a'/>
<id>urn:sha1:eed9265be711432f40247f149c07f9e33511192a</id>
<content type='text'>
Moves Event/Ledger DTOs out of the flat api package into
api/model/{event,ledger}, and moves LocalCatalogContext and order
matching logic into dedicated service/catalog and service/matching
packages, replacing TradingOperation/TradingOperationImpl.
</content>
</entry>
</feed>
