Skip to content

Commit f9c16dc

Browse files
committed
docs: specify safe Create factory stock dispatch boundary
1 parent d9b88e1 commit f9c16dc

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎docs/FACTORY_STOCK_DISPATCH.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Factory Stock Dispatch Design
2+
3+
This document records the Create 6.0.x API boundary for turning an authorized Stock Link offer into a real, durable order shipment. It is not a claim that factory sourcing is implemented end-to-end.
4+
5+
## Verified Create API shape
6+
7+
The target Create 1.21.1 source exposes:
8+
9+
- `PackagerLinkBlockEntity.processRequest(ItemStack stack, int amount, String address, int linkIndex, MutableBoolean finalLink, int orderId, PackageOrderWithCrafts context, IdentifiedInventory ignoredHandler)`, which returns a packager/request pair or `null`.
10+
- `PackagerBlockEntity.attemptToSend(List<PackagingRequest> queuedRequests)`, which consumes item-specific `PackagingRequest` entries from the linked packager's target inventory.
11+
- `PackagingRequest.create(...)` creates the request, and the request tracks a mutable remaining count.
12+
13+
The Stock Link summary exposed by `CreateStockLinkCompat` is read-only. A summary is a discovery snapshot, not a stock reservation and not proof that any package moved.
14+
15+
## Required transaction order
16+
17+
A factory-source dispatch implementation must preserve this order:
18+
19+
1. Validate the current order, claimant, item, quantity, Stock Link binding, owner/team permissions, loaded source chunk, Create frequency, and source endpoint binding.
20+
2. Atomically reserve the order quantity in `OrderData` and persist a shipment journal row before asking Create to move items.
21+
3. Reserve the physical source quantity. The current endpoint interface only reports `availableCount`; it does not provide an atomic reservation contract yet. Do not treat a second summary read as a reservation.
22+
4. Submit an item-specific Create `PackagingRequest` through the linked Packager. Do not call `attemptToSend(null)` for order sourcing: that path performs generic inventory packing rather than a transaction-bound item request.
23+
5. Associate the transaction ID with the exact package/cargo before it can be accepted as a valid delivery. Never mutate the requested stack's components in a way that makes Create's source-stack match fail.
24+
6. Persist dispatch only after the package is verifiably held/queued with the expected item, quantity, route, and transaction marker.
25+
7. Apply order progress and payout only after an independent destination receipt matches the durable transaction.
26+
8. On restart, reconcile source reservation, Create-held/queued packages, in-flight transport, and destination receipt. An ambiguous state must remain reserved for recovery; it must not be retried as a fresh shipment.
27+
28+
## Security invariants
29+
30+
- A shared Create frequency is not an iCreate permission boundary. The root Stock Link and every source endpoint must each have an authorized persisted factory binding.
31+
- Revalidate bindings, network ID, source position, item identity, and available quantity immediately before physical reservation.
32+
- Never dispatch against an unloaded source chunk or a source whose owner/team access has changed.
33+
- Duplicate transaction IDs must reconcile to the existing journal row, not submit a second Create request.
34+
- A null/failed Create request may release a reservation only when the adapter can prove that no cargo was extracted and no package was created.
35+
- Partial package creation must retain the durable reservation until recovery can account for every extracted item.
36+
37+
## Completion gate
38+
39+
The implementation is not complete until the endpoint exposes a real reservation mechanism, request submission is wired into the order/shipment lifecycle, and tests cover shared-frequency isolation, partial dispatch, duplicate retries, and restart recovery. Dedicated-server verification must confirm actual Create package movement and marker preservation in the target modpack.

0 commit comments

Comments
 (0)