Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

finknit

The FinField knitweb domain plugin — weave signed financial facts into the pulse P2P fabric and vote on what is factually correct.

Two consensus regimes

Matched to the nature of the number:

  • Exact facts (audited filing values). Every honest node that reads the same filing mints the byte-identical CID, so correctness is a yes/no question about one record. It is settled by a personhood-gated binary vank poll on the fact's knit-CID: open_fact_poll defines the poll, each peer casts with cast_ballot(web, voter_priv, ticket, scope, knit_cid, correct=...) (their own pairwise key plus the pulse personhood ticket — one person, one vote; re-vote with a higher seq), and fact_verdict tallies deterministically (True / False / None on tie).
  • Continuous quantities (crypto prices, cross-venue closes, model signals). Different honest observers legitimately report different numbers, so there is no single CID to vote yes/no on. Floats never enter records — each observer publishes their own scaled-integer observation fact, and float_consensus takes the vank-style weighted median (integer weights, lower middle wins on an even split, so every node computes the same winner). The result is a finfield-consensus fact whose derived_from lists every counted observation CID.

Knit your own data in

Anyone runs the same code with their own key: instantiate FinFieldKnitweb(your_priv), weave the facts you scraped or derived (emit / weave_factset — every record is invariant-checked and signed by you), and vote on other people's facts through pulse polls. Records relayed from peers decode back into FinFacts with from_record (invariant-checked on the way in). The field converges on truth by tally, not by trusting any single publisher.

Install

pip install "finknit @ git+https://github.com/FinField/knit"   # pulls finfacts
# optional — P2P weaving + polls need the pulse runtime and vank:
pip install "knitweb @ git+https://github.com/knitweb/pulse"
pip install "knitweb-vank @ git+https://github.com/Knitweb/vank"

The pure-math layer (weighted_median, float_consensus) is stdlib-only and works without either optional install.

Vote on what is factually correct

examples/vote_demo.py is the end-to-end proof: a publisher weaves a real FinFact (AAPL FY2024 revenue, straight from the 10-K accession), an authority opens a correct/incorrect poll on its knit-CID, and three independent voters — each with their own pairwise key and a PersonhoodTicket minted by the real pulse personhood gate — cast gated, signed ballots. The tally is deterministic (one person one vote via nullifier dedupe; a re-vote with a higher seq supersedes), and any peer re-tallies the identical verdict from a web_snapshot()/import_web() round-trip.

# with knitweb + knitweb-vank pip-installed (or sibling checkouts on PYTHONPATH):
python3 examples/vote_demo.py
# from a source layout, e.g.:
PYTHONPATH=/path/to/pulse/src:/path/to/vank/src python3 examples/vote_demo.py

Trimmed output (fully deterministic — run it twice, byte-identical):

[1] publisher weaves the fact (signed, invariant-checked)
    fact     us-gaap:RevenueFromContractWithCustomerExcludingAssessedTax FY2024 = 391035000000 USD
    source   sec-companyfacts accession 0000320193-24-000123
    knit-cid bafyreidfcaxtpcysjvkpk6xoloakzcufwsmuivqioblojcurqije4jpdsu
[2] authority opens the correct/incorrect poll on the fact CID
    window   [1000, 2000)  quorum 2  options 2 (0=incorrect, 1=correct)
[3] three voters, each with their own key + gate-minted PersonhoodTicket
    voter-1 ... correct=True  seq=0   voter-2 ... correct=True  seq=0
    voter-3 ... correct=False seq=0
    interim verdict (2 yes / 1 no): True
    voter-3 re-votes correct=True  seq=1 -> ... (highest seq wins)
[4] deterministic tally from the woven web
    ballots woven 4 | persons counted 3  (one person one vote: nullifier dedupe)
    results  incorrect=0  correct=3
    verdict: True  -- the fact is confirmed correct
[5] auditability: any peer re-tallies from a snapshot round-trip
    state_root e10092d7b095bacb2ebf4a87fbf65c2e1ce798b1867084573f42c62dca56b8be
    import_web(snapshot) -> verdict True (identical), state_root identical: True

Example: three observers, one consensus close

from finfacts.model import FinFact, Period, Source
from finknit.vote import float_consensus

day = Period(end="2026-07-03")
obs = [
    FinFact(entity_id="ticker:BTC CRYPTO", concept="finfield:close",
            value=1089934, scale=2, unit="USD", period=day,   # 10899.34
            source=Source(kind="coingecko-market", ref="observer-a")),
    FinFact(entity_id="ticker:BTC CRYPTO", concept="finfield:close",
            value=10900, scale=0, unit="USD", period=day,     # 10900
            source=Source(kind="coingecko-market", ref="observer-b")),
    FinFact(entity_id="ticker:BTC CRYPTO", concept="finfield:close",
            value=108991, scale=1, unit="USD", period=day,    # 10899.1
            source=Source(kind="coingecko-market", ref="observer-c")),
]
fact = float_consensus(obs, weights={"observer-a": 2, "observer-b": 1, "observer-c": 1})
print(fact.decimal, fact.cid)         # weighted median at the finest scale
print(fact.derived_from)              # CIDs of every counted observation

Part of the FinField field: facts · scrapers · agents · signals · crypto

About

FinField knitweb domain plugin — knit your own financial facts P2P and vote on truth: pulse polls for exact facts, vank consensus for floats

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages