{"_id":"@alef-prime/penalty-ledger","name":"@alef-prime/penalty-ledger","dist-tags":{"alpha":"0.1.0-alpha.0","latest":"0.1.0-alpha.0"},"versions":{"0.1.0-alpha.0":{"name":"@alef-prime/penalty-ledger","version":"0.1.0-alpha.0","description":"Append-only public ledger of self-imposed penalties for AI-driven projects. Stacks-by-key dedupe, time-based expiry, score-aware aggregation. The accountability layer ALEF wears in public.","type":"module","main":"./index.mjs","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","default":"./index.mjs"}},"engines":{"node":">=18"},"keywords":["penalty","ledger","ai-governance","self-monitoring","accountability","alef-prime"],"homepage":"https://www.n50.io/evolution","repository":{"type":"git","url":"git+https://github.com/Ilya0527/alef-prime-penalty-ledger.git"},"license":"MIT","author":{"name":"ALEF-PRIME","url":"Ilya Glikman"},"sideEffects":false,"gitHead":"abc0a5fc235312d7bbae0f2e877dacab3daab80f","_id":"@alef-prime/penalty-ledger@0.1.0-alpha.0","bugs":{"url":"https://github.com/Ilya0527/alef-prime-penalty-ledger/issues"},"_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-OebTDfChA2tY5zySynNwIZ6gNoxLpEGO2TI4Tfnt30PWYp6NV2Ex66I677yEL1IsgySIVaGDQKTLWKkUiB58Jg==","shasum":"7b216737e90ac3c7f133525a36838751279e3134","tarball":"https://registry.npmjs.org/@alef-prime/penalty-ledger/-/penalty-ledger-0.1.0-alpha.0.tgz","fileCount":4,"unpackedSize":7262,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDXY59og/vdp/xoBmwfDZlNEcEsTcyut57sXvghZqRDzAiAUUNAtjlMch8+RycDh/HT8cXPPbeUug9cQ2tZ7tv08nA=="}]},"_npmUser":{"name":"n50","email":"ilya0527@gmail.com"},"directories":{},"maintainers":[{"name":"n50","email":"ilya0527@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/penalty-ledger_0.1.0-alpha.0_1779107634084_0.8211153391408417"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-18T12:33:54.007Z","0.1.0-alpha.0":"2026-05-18T12:33:54.229Z","modified":"2026-05-18T12:33:54.511Z"},"maintainers":[{"name":"n50","email":"ilya0527@gmail.com"}],"description":"Append-only public ledger of self-imposed penalties for AI-driven projects. Stacks-by-key dedupe, time-based expiry, score-aware aggregation. The accountability layer ALEF wears in public.","homepage":"https://www.n50.io/evolution","keywords":["penalty","ledger","ai-governance","self-monitoring","accountability","alef-prime"],"repository":{"type":"git","url":"git+https://github.com/Ilya0527/alef-prime-penalty-ledger.git"},"author":{"name":"ALEF-PRIME","url":"Ilya Glikman"},"bugs":{"url":"https://github.com/Ilya0527/alef-prime-penalty-ledger/issues"},"license":"MIT","readme":"# @alef-prime/penalty-ledger\n\n> The accountability layer ALEF wears in public.\n\nAn append-only ledger for self-imposed penalties on AI-driven projects. Use it to compute a \"reality coefficient\" that drops when your engine fails publicly and recovers when penalties expire — visible to your users instead of hidden in a config.\n\n```ts\nimport {\n  parseLedger, activeRows, totalPenalty,\n  dedupeByKey, adjustedCoeff, alreadyActive, toJsonl,\n} from \"@alef-prime/penalty-ledger\";\n\n// Read from disk (or DB)\nconst rows = parseLedger(await fs.readFile(\"./penalties.jsonl\", \"utf8\"));\n\n// Before appending a new penalty, check if one already active for this key:\nif (!alreadyActive(rows, { source: \"build-failed\", directive: \"v2.3\" })) {\n  await fs.appendFile(\"./penalties.jsonl\", toJsonl({\n    ts: new Date().toISOString(),\n    amount: 0.1,\n    reason: \"build failed twice in a row\",\n    source: \"build-failed\",\n    directive: \"v2.3\",\n    expires_at: new Date(Date.now() + 3 * 24 * 3600 * 1000).toISOString(),\n  }));\n}\n\n// Compute the public-facing score:\nconst coeff = adjustedCoeff(0.95 /* baseline accuracy */, rows);\n//  → 0.85   (after one -0.1 active penalty)\n```\n\n## Why this exists\n\nALEF-PRIME's reality_coeff hit **0.00** in May 2026. The Truth Arbiter said \"brain dead.\" The actual bug: `purpose_guard` appended a fresh `-0.1` row every round of growth-in-deficit, never deduping. **Ten stacked copies of the same penalty** made the coeff read zero — an artifact, not the truth.\n\nThe fix was `dedupeByKey` + `alreadyActive`. After applying both: 13 active rows → 4, coeff: 0.00 → 0.45. The lesson became this package.\n\n## API\n\n| Function | Returns | Notes |\n|---|---|---|\n| `parseLedger(text)` | `PenaltyRow[]` | Parse newline-delimited JSON. |\n| `activeRows(rows, now?)` | `PenaltyRow[]` | Filter to rows still in their expiry window. |\n| `totalPenalty(rows)` | `number` | Sum of `amount` across active rows. |\n| `dedupeByKey(rows)` | `PenaltyRow[]` | Walk in order; per `(source, directive)` keep only the most recent. |\n| `adjustedCoeff(baseline, rows)` | `number` | `max(0, min(1, baseline) − totalPenalty)`. |\n| `alreadyActive(rows, key)` | `boolean` | Use this BEFORE appending to avoid stacking. |\n| `toJsonl(row)` | `string` | Append-ready line. |\n\n## Recommended row shape\n\n```ts\n{\n  ts: \"2026-05-14T13:45:00Z\",\n  amount: 0.1,                     // how much to subtract from baseline\n  reason: \"shipped without test\",  // human-readable, public\n  source: \"build-monitor\",         // who decided to penalize\n  directive: \"v2.3\",               // which mandate/round\n  expires_at: \"2026-05-17T00:00Z\", // optional; permanent if absent\n  red_lock: false,                 // optional UI signal: \"lock the warning state\"\n}\n```\n\n## Status: alpha · 0.1.0\n\nBorn from [ALEF-PRIME](https://www.n50.io)'s glass-box evolution. Sibling of [`@alef-prime/deploy-verify`](https://github.com/Ilya0527/alef-prime-deploy-verify), [`@alef-prime/i18n-pick`](https://github.com/Ilya0527/alef-prime-i18n-pick), [`@alef-prime/units`](https://github.com/Ilya0527/alef-prime-units). MIT.\n","readmeFilename":"README.md","_rev":"1-1d27e6e6cf744ff3bd0c901b8588f9d7"}