Ignore:
Timestamp:
09/16/26 23:37:15 (13 days ago)
Author:
Stefan <trsunovstefan@…>
Branches:
main
Children:
8b447ef
Parents:
df05838
Message:

add reserved_quantity and modify the phases, add v_03.png and v_03.xml for P1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • docs/P4-Prototype/PrototypeImplementation.md

    rdf05838 r9577c79  
    4646   `INSERT … ON CONFLICT DO UPDATE` upsert possible, so the weighted-average entry price is
    4747   recomputed by the database in one statement instead of by a read-modify-write in application
    48    code.
     48   code. `CHECK (reserved_quantity >= 0 AND reserved_quantity <= quantity)` is the same idea
     49   applied to the sell path: an inconsistent reservation is impossible at the database level, not
     50   just something `trade.go` is careful about.
     51 * '''Selling reserves before it removes.''' A sell order locks the holding row, reserves the
     52   quantity being sold, then settles by removing it — see
     53   [UseCase0005Implementation](UseCase0005Implementation.md). Two sell orders placed at the same
     54   instant for more than the available quantity are serialised correctly by `SELECT ... FOR
     55   UPDATE`, not just by luck of everything happening in one CLI process; this is demonstrated
     56   there with two concurrent processes.
    4957 * '''No identifiers are ever typed.''' Markets are listed with their prices before any choice is
    5058   made, and everything else is selected by symbol.
    … …  
    6371 * There is no connection pooling configuration and no explicit isolation level; both are P8
    6472   topics.
    65 == AI usage ==
    66 
    67 AI was used in this phase and is logged in full, per the course rule for P1 onward.
    68 
    69  * '''Phase log:'''
    70    [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCaseModelAIUsage.md UseCaseModelAIUsage.md]
    71    – service used, what the AI produced, and what I decided myself.
    72  * '''Full conversation transcript:'''
    73    [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md ERModelAIUsage.md]
    74    – the same conversation produced the P1–P4 artefacts, so the complete prompt/response log is
    75    kept in one place. Direct links:
    76    [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-1--2026-04-21 Session 1 – 2026-04-21],
    77    [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-2--2026-08-06--2026-08-07 Session 2 – 2026-08-06/07].
    78 
    79 '''Service:''' Claude Code (Anthropic), https://claude.com/claude-code – Claude subscription,
    80 model Claude Opus 4.7 (1M context).
    81 
    82 '''In short:''' the AI proposed the actor taxonomy and drafted the seven use cases with their SQL
    83 in session 1. In session 2 the use-case model itself was '''not''' changed – the only work was
    84 re-executing every scenario, including the failure paths, against a live PostgreSQL 16 database.
     73 * Reservation only ever lives inside one transaction, because only market orders (which settle
     74   immediately) exist. A real limit-order matcher would leave `holdings.reserved_quantity` set
     75   and `orders.status = 'open'` between two separate commits, and would need a way to cancel an
     76   order to release the reservation — neither is implemented, since nothing in the prototype
     77   produces an order that stays open.
    8578
    8679== AI usage ==
    … …  
    9689   kept in one place. Direct links:
    9790   [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-1--2026-04-21 Session 1 – 2026-04-21],
    98    [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-2--2026-08-06--2026-08-07 Session 2 – 2026-08-06/07].
     91   [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-2--2026-08-06--2026-08-07 Session 2 – 2026-08-06/07],
     92   [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-3--2026-09-16 Session 3 – 2026-09-16].
    9993
    10094'''Service:''' Claude Code (Anthropic), https://claude.com/claude-code – Claude subscription,
    101 model Claude Opus 4.7 (1M context).
     95model Claude Opus 4.7 (1M context) in sessions 1–2, Claude Sonnet 5 in session 3.
    10296
    10397'''In short:''' session 1 rewrote the existing Chi/HTTP backend as the CLI prototype covering
    … …  
    106100infinite loop at end of input, and an error check in the wrong order that misreported database
    107101failures as "Insufficient holding" – and replaced the read-modify-write holding update with a
    108 single `INSERT … ON CONFLICT DO UPDATE`.
     102single `INSERT … ON CONFLICT DO UPDATE`. Session 3 added `holdings.reserved_quantity` and changed
     103`trade.go`'s sell path to reserve crypto before removing it, closing a gap where two sell orders
     104could be granted the same units; see
     105[PrototypeImplementationAIUsage](PrototypeImplementationAIUsage.md#session-3--2026-09-16).
Note: See TracChangeset for help on using the changeset viewer.