Read, write, validate, sign and verify Pebble Stream Open Spreadsheet Format (PSOSF) archives from Clojure, Java, JavaScript, Python and C, and check the PebbleScript directives inside them.
PSOSF is a plain-text form of a spreadsheet: one CSV file per worksheet, plus a manifest, bundled in a ZIP archive. These libraries let people, tools and AI agents work with PSOSF archives safely, without Excel and without Pebble Stream. There is one implementation, written in Clojure and compiled for each platform, so every language applies exactly the same rules.
Specification: the PSOSF specification, also in this repository as docs/pebble-stream-open-spreadsheet-format.md. PSOSF is pronounced as its letters, P-S-O-S-F, or informally "soff". PSOSF archives have the IANA-registered media type application/vnd.pebblestream.psosf+zip and the extension .psosf.
Licensed under the Apache License 2.0. Source: github.com/GeorgetownSoftwareHouse/pebble-stream-psosf.
| Language | Package |
|---|---|
| Clojure | com.pebblestream/psosf {:mvn/version "0.1.1"} in deps.edn (Maven Central and Clojars) |
| Java | com.pebblestream:psosf:0.1.1 from Maven Central, with Maven or Gradle and no extra repository |
| C# and .NET | dotnet add package PebbleStream.Psosf from NuGet |
| JavaScript and TypeScript | npm install @pebblestream/psosf |
| Python | pip install pebblestream-psosf, or a wheel from the latest release |
| C | libpsosf for your platform from the latest release |
Every release also attaches all of these files to its GitHub Release, with a SHA256SUMS file to verify them. Clojure users can depend on the repository directly too, with {:git/tag "v0.1.1" :git/sha "..."}.
psosf:=A1+3; text that a spreadsheet application could evaluate gets a leading apostrophe. Unescaped fields are rejected with a precise fix, never repaired.psosf.model builds, traverses and edits archives as plain Clojure data. Every function is pure, so archives compose with -> and ordinary sequence functions:
(require '[psosf.core :as psosf]
'[psosf.model :as m])
(def ledger
(-> (m/archive "Account Balances" {:namespace "com.example.ledger"})
(m/add-sheet
(-> (m/sheet "Accounts")
(m/add-column {:header "id" :type "text"})
(m/add-column {:header "amount" :type "number"
:annotation ["pebblestream:not-blank" "Balance in US dollars."]})
(m/add-column {:header "negative" :type "boolean"
:annotation ["pebblestream:fail"]})
(m/add-row ["1" "435" (m/formula "=B2<0")])))))
(psosf/write-file "account-balances.psosf" ledger)
;; Traverse
(m/headers (m/find-sheet ledger "Accounts")) ;=> ["id" "amount" "negative"]
(m/directives (m/find-sheet ledger "Accounts")) ;=> ({:column "amount" :text "pebblestream:not-blank"} ...)
(m/formulas (m/find-sheet ledger "Accounts")) ;=> ({:row 0 :column "negative" :text "=B2<0"})
(m/row-values (m/find-sheet ledger "Accounts")) ;=> ({"id" "1" "amount" "435" "negative" "=B2<0"})
Escaping is handled when the archive is written: text such as =total or @SUM(A1) is protected automatically, and formulas get their psosf: prefix. psosf.api and its JSON shapes are only needed by adapters for other languages.
The same library, compiled from ClojureScript, is published to npm with TypeScript types:
npm install @pebblestream/psosf
import { classifyZip, unzip, read, write, zip } from "@pebblestream/psosf";
const result = classifyZip(bytes, { "allowed-functions": ["SUM", "IF"] });
// { level: "compatible", errors: [], warnings: [], "compatibility-errors": [], archive: {...} }
| Level | Meaning |
|---|---|
:invalid | Not a well-formed PSOSF archive. :errors says why, with file, line, column and a fix. |
:valid | Well-formed PSOSF: safe to open directly and convertible to Excel. :compatibility-errors says why it is not Pebble Stream compatible. |
:compatible | Pebble Stream compatible: also passes every Pebble Stream compatibility check that can be made without compiling: formulas use only supported functions, nothing refers to another workbook or process, and every directive name is known and available. |
Valid is about the open format, which any tool can write; compatible is about Pebble Stream. :compatible is as far as an archive can be judged without the Pebble Stream compiler service, which has the final say.
This library never compiles or executes a spreadsheet. Formulas are treated as text: escaped and scanned for the functions they call and the references they make, never parsed into an expression tree or evaluated. PebbleScript directives are checked by name only. Converting to and from Excel is left to tools that have access to Excel, such as Pebble Stream Zen.
(require '[psosf.core :as psosf])
;; From a file (JVM)
(psosf/classify-file "account-balances.psosf" {:allowed-functions #{"SUM" "IF"}})
;; => {:level :compatible, :archive {...}, :errors [], :warnings [], :compatibility-errors []}
;; From an entries map {path text} (JVM or ClojureScript)
(psosf/classify {"manifest.json" "..." "Accounts.csv" "..."})
;; Read, change, write
(let [{:keys [archive]} (psosf/read-entries entries)]
(psosf/write-entries (assoc-in archive [:manifest "description"] "Updated.")))
psosf.api is the cross-language contract: every function takes and returns JSON-shaped data (string keys, no keywords), and classify-json, read-json and write-json take and return JSON text. Every language adapter is a thin layer over it, so an archive is classified the same way in every language.
schema/psosf-api-v1.schema.json defines, as JSON Schema, every request and result shape a binding accepts and returns. The conformance suite is a set of language-neutral cases, each an archive with its expected classification, that every binding runs; a binding conforms when it passes them all. Both run in this repository's own tests, on the JVM and in JavaScript.
The compatibility check tests every formula against the spreadsheet functions Pebble Stream supports: the 135 functions on the supported functions list, built into the library as psosf.allow-list/functions. Each records the first Pebble Stream runtime version that supports it, so (psosf.allow-list/functions-for "1.4.0") gives the list for an older runtime. Pass :allowed-functions to classify to check against a different list; an empty one reports :allow-list-not-configured.
Everything is portable .cljc except reading and writing the ZIP container and the cryptography. The JVM uses its standard library for both; .NET uses System.IO.Compression and BouncyCastle; JavaScript uses fflate and WebCrypto. The Clojure library has no dependencies beyond Clojure itself.
| Area | Status |
|---|---|
| Archive reading and writing, limits | Done |
| Field escaping, worksheets, manifest, tests folder | Done |
| Structural validation and the three levels | Done |
Signature verification and signing (psosf.sign, bb verify) | Done, on the JVM and in JavaScript |
Building, traversing and editing (psosf.model) | Done |
| PebbleScript text ⇄ JSON Notation | Planned |
| npm package (JavaScript, TypeScript), Node and browsers | Done; browser tests run in CI |
Native library (libpsosf, C interface) | Built and tested in CI on five platforms |
| Python package | Done, on the native library |
| .NET library (C#, F#, VB) | Done, on ClojureCLR; tested in CI on Linux, macOS and Windows |
| Maven Central | Published by the release workflow, signed |
| Janet, Rust bindings | Planned, on the native library |
The library is on Maven Central, so Maven and Gradle find it with no extra repository:
<dependency>
<groupId>com.pebblestream</groupId>
<artifactId>psosf</artifactId>
<version>0.1.1</version>
</dependency>
implementation "com.pebblestream:psosf:0.1.1"
The jar includes a Java class, com.pebblestream.psosf.Psosf, covering everything: classifying, reading and writing, signing (in one step or two), verifying, generating keys, diffing, summarizing and patching. Entries go in as a Map<String, String>, results come back as ordinary Map<String, Object> and List<Object> values, failures throw Psosf.PsosfException, and Java code never handles Clojure types:
import com.pebblestream.psosf.Psosf;
import java.util.Map;
Map<String, Object> result = Psosf.classifyFile("ledger.psosf");
String level = (String) result.get("level"); // invalid, valid or compatible
Map<String, String> entries = Psosf.readFile("ledger.psosf").entries();
Map<String, String> keys = Psosf.generateKey();
Psosf.SigningDetails who = new Psosf.SigningDetails("acme/agents/ledger-bot/2026-11", "author", "agent", "ledger-bot");
Map<String, String> signed = Psosf.sign(entries, keys.get("private-key"), who);
Map<String, Object> changes = Psosf.diffFiles("before.psosf", "after.psosf");
System.out.println(Psosf.summarize(changes).get("details")); // what changed, to what, and where
The ...Json methods (classifyJson, diffJson and the rest) take and return JSON text instead, for callers already working in JSON. The Javadoc is published with the jar on Maven Central.
psosf.sign verifies and creates the signatures defined in the PSOSF specification. A signed archive's signatures.json holds the SHA-256 of every other file and Ed25519 signatures over them, so any change to the archive's content invalidates every signature, and each signature records who signed and in what role (author or approver).
bb verify ledger.psosf --keys keys.json
(require '[psosf.sign :as sign])
(sign/verify-entries entries {:resolve-key lookup :received-at "2026-11-30T00:00:00Z"})
;; => {:status :verified, :digests {:match true ...}, :signatures [{:role "author" :valid true ...}] ...}
(sign/sign-entries entries {:private-key k :key-id "..." :role "approver"
:signer {"kind" "human" "id" "a.mensah@acme.example"}
:signed-at "2026-11-30T09:15:00Z"})
Keys are found through :resolve-key, a function from a key id to a key record:
{
"key-id": "acme/users/a.mensah@acme.example/2026-11",
"public-key": "<Base64 of the raw 32-byte Ed25519 public key>",
"owner": { "kind": "human", "id": "a.mensah@acme.example" },
"registered-at": "2026-11-02T14:00:00Z",
"revoked-at": null
}
This is the raw form WebCrypto exports, and the form the Zen service returns for a key id. custody records who holds the private key: "device" (the signer's own machine, the default) or "service" (the Zen service, signing for the signed-in user). A signature is valid only when the files are exactly those signed, the key is known, the signer is the key's owner, and the key had not been revoked when the archive was received; with :approver-custody #{"device"}, an approver's key must also be held on the approver's own device. A failed check never removes a signature.
In JavaScript, the npm package signs and verifies with WebCrypto, so a private key can stay non-extractable:
import { sign, verify, exportPublicKey } from "@pebblestream/psosf";
const keys = await crypto.subtle.generateKey({ name: "Ed25519" }, false, ["sign", "verify"]);
const publicKey = await exportPublicKey(keys.publicKey); // register this with the Zen service
const signed = await sign(entries, { privateKey: keys.privateKey, keyId, role: "author",
signer: { kind: "human", id: "a.mensah@acme.example" } });
const result = await verify(signed, keyRecords, { approverCustody: ["device"] });
For a key the library should never hold (the Zen service's key store, a hardware key, an organization's own key service), sign in two steps: signing-message returns the exact text to sign, the caller signs its UTF-8 bytes with Ed25519 however it holds the key, and attach-signature adds the result (checking it first when given the public key). The same two functions exist in JavaScript (signingMessage, attachSignature), Python and C.
The signature conformance cases are signed on the JVM and verified on the JVM, in JavaScript (Node and browsers), and through the native library in Python; archives signed in JavaScript verify on the JVM; and every platform must produce the same signing message, byte for byte, as conformance/signatures/signing-message.json.
psosf.diff compares two archives the way a spreadsheet sees them, not as lines of text. Columns are matched by header, so adding a column doesn't make every row look changed. Rows are aligned, so an inserted row is one change rather than a change to every row below it. Formulas are compared relative to their own cell, as Excel sees them: a formula that only shifted with its row or column is unchanged.
A diff is plain, versioned data: store it, send it, review it. Three functions use it:
| Function | Result |
|---|---|
(diff a b) | The diff: every change, with cells in their exact PSOSF field form |
(summary d) | One paragraph for people |
(details d) | Markdown for people: which formulas, data, directives and columns changed, to what, and where, by cell address. Input worksheets (no formulas, nothing producing their rows) give the affected row numbers instead of every value |
(report d) | One compact line per change |
(patch a d) | b, reproduced from a; refuses when a isn't the archive the diff was made from |
$ bb diff before.psosf after.psosf
# Changes
1 manifest field changed (name). In "Accounts", 1 column added, 1 directive changed, 3 rows changed (2 formulas), 1 row added and 1 row removed.
## Archive
- The name changed from `Conformance` to `Account Balances`.
## Worksheet "Accounts"
8 rows before, 8 after.
### Formulas
- D6 (negative; row 5 before): `=C5<0` changed to `=C6<=0`.
- D7 (negative; row 6 before): the formula `=C6<0` was replaced by the value `TRUE`.
### Data
- C3 (amount): `200` changed to `250`.
- Row 4 was inserted: id `new`, type `corporate`, amount `999`, negative `=C4<0`, region `west`.
- Row 7 of the earlier version was deleted: id `6`, type `individual`, amount `600`, negative `=C7<0`.
### Directives
- Removed the directive `pebblestream:not-blank` from column B (type).
### Columns
- Column E (region) was added, of type text, with E2 `east`.
$ bb diff before.psosf after.psosf --summary
1 manifest field changed (name). In "Accounts", 1 column added, 1 directive changed, 3 rows changed (2 formulas), 1 row added and 1 row removed.
$ bb diff before.psosf after.psosf --compact # one line per change
$ bb diff before.psosf after.psosf --json > changes.json
$ bb summarize changes.json
$ bb patch before.psosf changes.json after-again.psosf
The same functions are in every language: diff, diffZip, summarize and patch in JavaScript; diff, diff_files, summarize and patch in Python; and the JSON functions in Java and C. Rows are numbered as in Excel, with the header as row 1.
The Nightly fuzzing badge at the top of this page shows the result of the latest nightly run, and the Fuzzing badge how many generated inputs it checked; each run's page breaks the total down. The Conformance badge counts the conformance and signature cases the latest build on main passed. Both count badges are published by the workflows to the badges branch and rendered by shields.io.
The readers are fuzzed with property tests (test/psosf/fuzz_test.cljc) that run on the JVM and in JavaScript: writing then reading returns the original for CSV, fields and JSON; no field the writer emits begins with a trigger character; malformed and mutated input, including corrupted ZIP bytes, is rejected with an error and never crashes, hangs or exhausts the stack; and a mutated archive that passes classification writes back to one that classifies the same way. Every test run includes a brief pass. A nightly job runs 200,000 cases per property on the JVM, 50,000 in JavaScript, and 30 minutes of coverage-guided fuzzing with Jazzer, replaying every past failure in fuzz/corpus/ first. It also fuzzes differentially: the JVM classifies 5,000 generated and mutated archives, corrupted ZIP files and the corpus, and .NET and the native library (behind Python and C) must agree on every one, level and finding alike. .NET has its own ZIP reader, number parsing and regular-expression engine, so this is where platforms would diverge. Any failing input becomes a conformance case once fixed. The first run found a stack overflow on deeply nested JSON, now refused beyond 256 levels.
PebbleStream.Psosf runs the same Clojure implementation on .NET, through ClojureCLR, and passes the same conformance cases. Entries are dictionaries, results are System.Text.Json nodes, and a request the library can't carry out throws PsosfException:
using PebbleStream.Psosf;
var result = Psosf.ClassifyFile("ledger.psosf");
Console.WriteLine(result["level"]); // invalid, valid or compatible
var (entries, errors) = Psosf.ReadFile("ledger.psosf");
var (privateKey, publicKey) = Psosf.GenerateKey();
var details = new SigningDetails("acme/agents/ledger-bot/2026-11", "author", new Signer("agent", "ledger-bot"));
var signedEntries = Psosf.Sign(entries, privateKey, details);
var changes = Psosf.DiffFiles("before.psosf", "after.psosf");
Console.WriteLine(Psosf.Summarize(changes).Details); // what changed, to what, and where
Ed25519 comes from BouncyCastle, since .NET has none of its own. The PebbleScript directive checks are not yet in the .NET library.
libpsosf is the library compiled with GraalVM native-image into a shared library with a C interface (native/psosf.h): each function takes and returns JSON, so it applies exactly the same rules as the JVM and JavaScript libraries. The Python package (pip install pebblestream-psosf) wraps it:
import psosf
psosf.classify_file("ledger.psosf", allowed_functions=["SUM"])["level"]
private_key, public_key = psosf.generate_key()
signed = psosf.sign(entries, private_key, key_id=key_id, role="author", signer={"kind": "agent", "id": "bot"})
psosf.verify(signed, keys=[...])["status"]
Janet, Rust and any language with a C interface can call the same library. CI builds it for Linux (x64, ARM64), macOS (x64, ARM64) and Windows (x64), runs a C smoke test and the Python conformance tests against each build, and produces a Python wheel per platform.
pebblestream.directives.check checks an archive against everything Pebble Stream can verify without compiling it, and reports every problem in one list, with the worksheet, the column, the directive and, where one is known, a fix:
join with outer-join, header arguments against actual headers (units included), formulas in transformed columns, cycles between worksheets, ignore on a connected worksheet, blank in allowed-values, and replacements for deprecated directives.$ bb check distributions.psosf --allow SUM,IF
distributions.psosf: FAILED (the format is Pebble Stream compatible, but its PebbleScript or worksheets break the rules below)
Errors (2)
✗ worksheet "Totals", column "Fund ID": "NII" is not a header of the source worksheets. Header arguments must match exactly, including units.
Fix: Did you mean "NII ($)"?
✗ worksheet "Totals", column "NII ($)": cell 'Totals'!B2 has a formula, but its column is generated by directives.
Fix: Remove the formula: the directive fills this column. Give a generated column a header no directive fills.
The report is text for people by default. With --json it's JSON, for scripts and AI agents, holding the same findings with their codes. Either way, the exit code is 0 when the archive passed, 1 when it did not, and 2 on a usage error, so a script or CI job can act on it directly. The JSON for the same archive:
{
"compatibility-errors": [],
"errors": [
{
"argument": "NII",
"code": "unknown-header",
"column": "Fund ID",
"fix": "Did you mean \"NII ($)\"?",
"message": "\"NII\" is not a header of the source worksheets. Header arguments must match exactly, including units.",
"sheet": "Totals"
},
{
"code": "formula-in-transformed-column",
"column": "NII ($)",
"fix": "Remove the formula: the directive fills this column. Give a generated column a header no directive fills.",
"message": "cell 'Totals'!B2 has a formula, but its column is generated by directives.",
"sheet": "Totals"
},
{
"code": "blank-in-allowed-values",
"column": "NII ($)",
"fix": "Remove \"blank\". To require a value, use pebblestream:not-blank.",
"message": "pebblestream:allowed-values has no keyword for an empty cell.",
"sheet": "ClassNII"
}
],
"level": "compatible",
"passed": false,
"warnings": []
}
passed is true when the archive is well-formed, breaks no rule, and has no compatibility errors other than a missing allow-list. Warnings, such as a deprecated directive or the deprecated colon form, do not fail the check.
(require '[pebblestream.directives.check :as check])
(check/check-entries entries {"allowed-functions" ["SUM" "IF"]}) ; JSON-shaped report
(check/check-json "{\"entries\": {...}, \"options\": {...}}") ; JSON text in and out
(check/check-archive archive) ; a psosf.core archive, Clojure data
The same check, compiled from the same ClojureScript, is published as its own npm package, for Node and the browser:
npm install @pebblestream/psosf-directives
import { checkZip, check, parseLine } from "@pebblestream/psosf-directives";
const report = checkZip(bytes, { "allowed-functions": ["SUM", "IF"] }); // the same report as bb check
parseLine('pebblestream:sort("Last", "Date":desc)');
// { directive: "sort", syntax: "paren", args: ["Last", { column: "Date", order: "desc" }], warnings: [] }
It is a separate package from @pebblestream/psosf because it includes the directive registry and Malli, which make it larger; applications that only read and write archives don't need them.
An agent writing or editing a spreadsheet can use the check as its feedback loop:
psosf.model (or as PSOSF files).bb check, or call check-json.passed is false, fix each error. Every error names its sheet and column, argument when a header argument is wrong, and usually a fix, such as Did you mean "NII ($)"?.passed is true, then submit the archive to Pebble Stream, whose compiler has the final say.code values are stable identifiers, safe to match on; message and fix are written for people and may change.
com.pebblestream/psosf-directives is a separate artifact holding the PebbleScript directive registry (a Malli schema of every directive's signature, exclusions, execution order and status) and the directive string parser. The core library does not depend on it.
pebble-stream-psosf/
├── src/psosf/ the psosf library (.cljc, plus js.cljs for npm)
├── src/java/ the Java entry point, compiled into the jar
├── test/ JVM and ClojureScript tests, and the test runners
├── directives/
│ ├── src/pebblestream/ the directive registry, parsers and the check
│ └── test/ their tests
├── dotnet/ the .NET library (PebbleStream.Psosf) and its tests
├── native/ libpsosf: C entry points, psosf.h, build script, C smoke test
├── python/ the Python package and its tests
├── npm/
│ ├── psosf/ the @pebblestream/psosf package: package.json, index.d.ts, README
│ └── psosf-directives/ the @pebblestream/psosf-directives package
├── conformance/ language-neutral cases every binding must pass
├── schema/ the JSON Schema of the API contract, version 1
├── docs/ the PSOSF specification and the PebbleScript Reference
├── build.clj jar builds (tools.build)
├── shadow-cljs.edn the npm builds
├── package.json the npm workspace for development (private, never published)
├── bb.edn development tasks
└── VERSION the release version, shared by every artifact
Requires a JDK (11 or later), the Clojure CLI, babashka and Node.js.
| Command | Does |
|---|---|
bb test | Every test suite: JVM, directives, and both ClojureScript suites |
bb jar | Both jars, in target/ |
bb install | Both jars into the local Maven repository |
bb npm | Both npm packages, in npm/psosf/dist/ and npm/psosf-directives/dist/ |
bb build | All tests, then all builds |
bb check FILE.psosf [--json] | Check an archive for errors: a report for people, or JSON for scripts and agents |
bb verify FILE.psosf --keys KEYS.json | Verify a signed archive and print the result as JSON |
bb test:browser | The conformance and signature tests in Chromium, Firefox and WebKit |
bb native | Build libpsosf with GraalVM native-image into target/native/ |
bb test:python | The Python tests, against libpsosf (PSOSF_LIBRARY=...) |
bb diff A.psosf B.psosf | Compare two archives: the details, or --summary, --compact or --json for the diff itself |
bb summarize CHANGES.json | Summarize a saved diff |
bb patch A.psosf CHANGES.json OUT.psosf | Apply a saved diff |
bb fuzz [n] | Fuzz the readers with n generated inputs per property (default 20,000) |
bb clean | Remove build output |
bb conformance:generate | Regenerate the conformance cases |
To publish the npm packages after bb npm, from the repository root: npm publish --workspace npm/psosf --access public, then the same for npm/psosf-directives. Scoped packages are private on npm unless published with --access public.
To make a release, run ./create-release.sh <version>; see RELEASING.md.
The version lives in VERSION; bb jar and bb npm refuse to build if any package.json disagrees.
Can you improve this documentation? These fine people already did:
Bediako George & ClaudeEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |