Skip to content

factlet-ai/reference-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Factlet Protocol — reference SDK

Reference implementations of the Factlet Protocol v0.1. Other implementations validate against these.

Status

Implementation Status Tests Path
Python ✅ Working v0.1.0 13 passing python/
TypeScript ⚠️ Planned for v0.1.1 (not yet implemented) typescript/

Python ships first to lock the contract via tests; TypeScript ports byte-identical behavior next. We chose this over simultaneous development to avoid diverging implementations during the protocol's pre-v1.0 phase.

Quick start (Python)

cd python/
pip install -e .
python -c "from factlet import load_factbook, factsignal; \
  fb = load_factbook('../../registry/examples/payments/factbook.yaml'); \
  print(factsignal('how do refunds work?', fb))"

Public API

The five protocol primitives, exposed as callable functions:

  • load_factbook(path)Factbook — parses YAML/JSON Factbook from disk
  • retrieve(query, factbook)list[Factlet] — relevance-ordered factlets (§4)
  • factsignal(query, factbook)int — coverage bars 0-5 (§6)
  • on_low_factsignal(query, factbook, threshold, callback)(score, retrieved) — runtime warning hook (§7)
  • render_for_claude(factlets) / render_for_gpt(factlets)str — vendor-flavored rendering (§8)

See python/README.md for full usage and python/tests/test_basic.py for behavior under each scenario.

Algorithm contracts vs choices

Per SPEC.md §4 and §6, implementations choose their own retrieval and scoring algorithms. The reference SDK uses:

  • Retrieval: token-overlap weighted by confidence. Simple, fast, deterministic.
  • FactSignal: maps (retrieved factlet count) × (top-result confidence) to bars 0-5.

Production implementations (e.g. Kernora's Nora) layer embedding-based retrieval and LLM-based scoring on top of the same protocol contract.

Contribute

See CONTRIBUTING.md. Behavioral changes require corresponding test additions; spec divergence is a bug.

License

MIT — see LICENSE.

About

Reference Python + TypeScript implementations of the Factlet Protocol.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages