@inversealtruism/cairnx-core 0.1.36 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CONVENTION.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # CairnX Convention v1
2
2
 
3
- **Status:** v2.7 (normative; supersedes the 2026-06-10 v1.0 draft) · **Domain:** `cairnx:v1` · **Base activation:** 29 860
3
+ **Status:** v2.8 (normative; v2.8 pending activation at `V28_HEIGHT`, see §31; supersedes the 2026-06-10 v1.0 draft) · **Domain:** `cairnx:v1` · **Base activation:** 29 860
4
4
 
5
5
  **Version ladder** (each gate non-retroactive — below it, behavior + canonical hashes are byte-identical to history):
6
6
  v1.1 @ 29 960 · v1.2 @ 30 300 · v1.3 @ 31 100 · v1.4 @ 31 400 · v1.5 @ 32 000 · v1.6 @ 33 600 (§19) ·
7
7
  v1.7 @ 34 000 (§20) · v1.9 @ 36 700 (§22) · v2.0 @ 38 400 (§23) · v1.8 @ 40 000 (§21) · v2.1 @ 40 100 (§24) ·
8
8
  v2.2 @ 41 300 (§25) · v2.4 @ 46 400 (§27) · v2.5 @ 46 440 (§28) · v2.6 @ 46 480 (§29) · v2.7 @ 46 520 (§30) ·
9
- v2.3 @ 52 000 (§26).
10
- Sections §19–§30 are the normative semantics for v1.6–v2.7; §5.1 is the byte-level canonical-JSON contract that binds all of them.
9
+ v2.3 @ 52 000 (§26) · v2.8 @ `V28_HEIGHT` (§31, PENDING activation).
10
+ Sections §19–§31 are the normative semantics for v1.6–v2.8; §5.1 is the byte-level canonical-JSON contract that binds all of them.
11
11
  Activation order is by HEIGHT, not by version number (v1.8 activated after v2.0; v2.3 activates after v2.4–v2.7): a
12
12
  replayer gates each rule on its own height constant, never on "version X implies version Y is active".
13
13
 
@@ -997,3 +997,125 @@ anchor. `viaFill` names were never embargoed.
997
997
  at 46 521. Deterministic for every replayer; no name-age era bookkeeping is needed.
998
998
  - **Adoption note:** a relaxation (fresh cores accept a sale a stale core no-ops), so every replayer must
999
999
  run the v2.7 core before the tip crosses 46 520.
1000
+
1001
+ ---
1002
+
1003
+ # CairnX Convention v2.8 (fclaim: atomic open-lane settlement)
1004
+
1005
+ **Activation height: `V28_HEIGHT`** (baked at rollout; non-retroactive; each rule keys on its OWN governed
1006
+ event's height, and Lane B additionally on the offer's anchor era).
1007
+ Below it an `fclaim` record parses to a forward-compatible no-op (like `nprofile` below V19, §22), `SCORE_CLAIM`
1008
+ claims work exactly as §20/§23, and every replay hash is byte-identical.
1009
+
1010
+ ## 31. `fclaim`: the open-lane claim becomes a short-expiry proposal, the fill attests it
1011
+
1012
+ v1.7 (§20) moved the open-CSD race to a payment-free claim (`Attest score = 50`), but the resulting hold is an
1013
+ overlay-only deadline invisible to L0: a fill delayed past the hold, or a cancel reordered against the fill, can
1014
+ still burn a paid buyer (the cross-block delivery-versus-payment flaw). v2.8 closes it by making the claim a
1015
+ **short-expiry `Propose`** and the fill an **`Attest` on that proposal**, so L0's own rules (an Attest to an
1016
+ unknown proposal is block-invalid, and an Attest mined in an epoch past the proposal's `expires_epoch` is
1017
+ block-invalid) enforce the SAME hold deadline the overlay uses. Delivery and payment become one
1018
+ consensus-observable quantity.
1019
+
1020
+ **Record.** `fclaim = {v, t:"fclaim", offer}`, where `offer` is the 0x-hex id (`isHash`) of an open,
1021
+ CSD-priced, untaken offer. `FCLAIM_KEYS = {"v","t","offer"}` (exact-key set, §5.1). The expiry rides the
1022
+ carrying `Propose.expires_epoch`; there is no `expiresEpoch` in the record body (matching the `offer` /
1023
+ `OfferRecord` precedent). Parsing is height-agnostic; the resolve handler is `V28_HEIGHT`-gated, so below the
1024
+ gate a parsed fclaim is inert (nfinalize precedent, §28).
1025
+
1026
+ **The two transactions.**
1027
+ - **Claim** = `Propose(uri = the fclaim record, expires_epoch = E)`, with `E` the desired hold-end epoch. The
1028
+ network fee is the propose floor 0.25 CSD (up from the 0.05 attest floor). A client picks
1029
+ `E = min(epochOf(tip + 45), offer.expiresEpoch)` to approximate the legacy 45-block hold while never
1030
+ requesting an `E` the grant would deny.
1031
+ - **Fill** = `Attest(score = SCORE_FILL = 100)` on the **fclaim txid** (not the offer id), paying the SAME
1032
+ §4 / §19 delivery outputs (the CSD `want.value` sum plus the §19 fee and maker rebate). The fill itself
1033
+ stays at the 0.05 attest floor; only the claim rises to the 0.25 propose floor.
1034
+
1035
+ **Grant (the propose handler, at height `h >= V28_HEIGHT`).** A well-formed fclaim grants a hold iff, in order:
1036
+ the referenced offer exists AND is `open` AND untaken (`!taker`) AND CSD-priced; `E <= effExpiry(offer, h)`
1037
+ (§24 / §25, so the hold never outlives the offer); `E <= epochOf(h) + FCLAIM_MAX_EPOCH_AHEAD` (`= 2`, anti-squat,
1038
+ bounding a hold to `EPOCH_LEN*(2 + 1) - 1 = 89` blocks); `epochOf(h) <= E` (lower bound); the offer has no live
1039
+ hold (`!claimHeld`, unifying legacy and fclaim holds so one offer is never double-held); the same-offer cooldown
1040
+ has elapsed (`h >= o.claimUntilHeight + grace + CLAIM_COOLDOWN_BLOCKS` for the last holder, where `grace` is the
1041
+ prior hold's era grace per §20 / §23, i.e. 0 for a prior fclaim hold and `CLAIM_FILL_GRACE_BLOCKS` for a prior
1042
+ legacy hold; the cooldown runs from the END of the prior hold, so a straddling legacy hold and a fresh fclaim
1043
+ never disagree); and the proposer holds fewer than `MAX_ACTIVE_CLAIMS` (`= 3`) live holds. This clause order is
1044
+ normative (the from-spec oracle emits deny reasons in this order). On grant the resolver records `claimedBy = proposer`, `claimUntilHeight = (E + 1)*EPOCH_LEN`, and
1045
+ `claimTxid = fclaimTxid`.
1046
+
1047
+ **Last-write-wins (fund-safety).** All three fields are last-write-wins: a later grant on the same offer (after
1048
+ a prior hold has lapsed) RE-ASSIGNS all three unconditionally. `claimTxid` is never left stale behind an
1049
+ `if (claimTxid === undefined)` guard and is never cleared. (If a later holder's `claimTxid` were left stale,
1050
+ fill-routing (`claimTxid === proposalId`) would fail for that holder while their payment mined on the new
1051
+ fclaim, a burn.) A denied fclaim records `{granted:false}` in the internal `fclaims` map (for the money-safety
1052
+ audit) and grants no hold.
1053
+
1054
+ **Canonical surface (§5.1).** `claimTxid` is a canonical offer field (§5.1-A3, present only once granted at
1055
+ V28+, following the §20 `claimedBy` / `claimUntilHeight` precedent). The `fclaims` map is INTERNAL and is NOT
1056
+ materialized in canonical state (the §29 `recaptures` precedent). So every pre-V28 replay hash is unchanged,
1057
+ and post-V28 canonical hashes cover `claimTxid` only.
1058
+
1059
+ **Hold and grace.** `claimHeld(o, h)` keeps its form, but grace is fclaim-aware: an fclaim hold (`claimTxid`
1060
+ set) has grace 0, so the hold is exactly `[grantHeight, holdEnd]` with `holdEnd = (E + 1)*EPOCH_LEN - 1`, the
1061
+ last L0-minable height for the fill (an attest at `h > holdEnd` is in an epoch `> E` and L0-invalid). The
1062
+ resolver-local grace and the shared `claimGraceOf` selector are made `claimTxid`-aware TOGETHER so the resolver
1063
+ and every client bundle stay in lockstep.
1064
+
1065
+ **Fill routing.** A `SCORE_FILL` attest on an fclaim txid looks up the linked offer and delivers iff: the
1066
+ fclaim was `granted`; the offer is `open`; `claimTxid === fclaimTxid && claimHeld(o, h)`; and
1067
+ `attester === claimedBy`. It then runs the EXISTING §4 / §19 (whole) and §12 (partial) value-and-delivery
1068
+ machinery unchanged (same required outputs, keyed on the offer). Partial fills ride the fclaim lane and the
1069
+ hold PERSISTS across them until `holdEnd` or a whole fill. A granted fclaim's own `paidTo` is
1070
+ allowed-and-ignored (the §28 payment-free-reveal precedent). Any non-`SCORE_FILL` score on an fclaim txid is a
1071
+ no-op (no buyer early-release).
1072
+
1073
+ **Correction 1 (offer-txid fill blocked during a hold).** At `h >= V28`, an open **offer-txid** fill on an
1074
+ offer with `claimTxid !== undefined` is rejected. Without it, an updated buyer (or a stale bundle) could route
1075
+ the payment through the offer id, whose L0 deadline is the offer's far-off expiry, silently reopening the
1076
+ delayed-fill burn. One guard covers both the whole and partial offer-txid fill paths; token-priced fills never
1077
+ carry a `claimTxid`.
1078
+
1079
+ **Correction 2 (cancel-freeze at apply-time, on the cancel's own block).** §16 defers a cancel's effect to the
1080
+ block boundary. At `h >= V28`, both deferred closures (the `ocancel` Propose and the score-0 cancel Attest)
1081
+ SKIP any target with a live fclaim hold: evaluate `claimTxid !== undefined && claimHeld(o, ev.height)` LIVE on
1082
+ the offer object INSIDE the closure, keyed on the cancel's OWN block height. (A same-block higher-pos grant
1083
+ mutates that offer object, so an inside-closure read sees the hold; a value snapshotted at the `ocancel`
1084
+ apply-time target scan would not.) The freeze is scoped to `claimTxid !== undefined`, so pre-V28 legacy holds
1085
+ keep §16 behavior byte-for-byte.
1086
+
1087
+ **Lane B (taker-bound offers become uncancellable at V28).** A taker-bound (RFQ) answer is a firm quote: at
1088
+ `h >= V28`, both cancel paths reject a cancel when `o.taker !== undefined` and the offer was anchored at V28+.
1089
+ The maker exits by letting the answer expire (one epoch, about an hour). This eliminates the cancel-reorder half
1090
+ for the RFQ lane entirely.
1091
+
1092
+ **Name-offer freeze (lease-lapse safety).** A held offer that sells a **name** is also protected from
1093
+ `voidOpenNameOffers`: at `h >= V28`, a recapture or displacement does not void an offer carrying a live
1094
+ `claimTxid` hold (the same predicate as Correction 2). Without this, a name whose lease lapses mid-hold could be
1095
+ recaptured and its offer voided, stranding the buyer's L0-minable fill.
1096
+
1097
+ **`SCORE_CLAIM` sunset.** At `h >= V28` a `SCORE_CLAIM` attest is explicitly rejected (`claims are fclaim
1098
+ proposals now`) so a stale wallet's claim is diagnosable rather than silently inert. Pre-V28 live holds continue
1099
+ to honor legacy `SCORE_FILL` fills until they lapse (all within 45 blocks of the gate); the legacy lane
1100
+ self-sunsets with no height literal in the predicate.
1101
+
1102
+ **Denied-fclaim is an L0-valid fill target (the sharp edge).** L0 stores every mined Propose, and an Attest's
1103
+ existence check only reads storage, so a fill on a resolver-DENIED fclaim (for example on a taken or expired
1104
+ offer) still MINES and, because the resolver denied the hold, BURNS. A client therefore MUST re-derive the
1105
+ entire grant itself over PoW-buried offer + fclaim events before signing a fill, and MUST NOT trust fclaim
1106
+ inclusion or any resolver `granted` assertion. The `fclaims` map records the denied grant so the money-safety
1107
+ audit flags such a burn.
1108
+
1109
+ **Client policy (not consensus, does not affect canonical state).** A filler waits a value-scaled
1110
+ `requiredClaimDepth` (§20 reorg note) on BOTH the offer and the fclaim (and, for a partial tail-fill, on the
1111
+ offer's earlier fill-basis events) before signing, and refuses to broadcast a fill within `FILL_TIP_MARGIN`
1112
+ (`= 2`) blocks of `holdEnd` (a stranded no-op, never a fund risk), computed from the fclaim's actual confirmed
1113
+ height and `expires_epoch`. A clean-start SPV scan must cover
1114
+ `GAP_NEEDED = EPOCH_LEN*(FCLAIM_MAX_EPOCH_AHEAD + 1) - 1 + CLAIM_COOLDOWN_BLOCKS` (`= 104`) blocks so it can
1115
+ never false-accept a denied fclaim.
1116
+
1117
+ - **Adoption note:** at/above V28 the fill's referenced proposal changes (offer id becomes fclaim txid) and
1118
+ `SCORE_CLAIM` is rejected, so v2.8 is BOTH a relaxation (an fclaim fill a fresh core accepts, a stale core
1119
+ no-ops) AND a tightening (a stale core still grants legacy claims a fresh core rejects). Every replayer,
1120
+ resolver, and client bundle MUST run the v2.8 core before the tip crosses `V28_HEIGHT`. Below the gate every
1121
+ rule above is inert and all replay is byte-identical.