mirror of
https://github.com/PR0M3TH3AN/bitgate.git
synced 2026-11-01 19:11:02 +00:00
feat: rename to BitGate and close the drop-in gap
Renames the project and makes it as easy to adopt as BitLogin, which was the stated bar and which it did not previously meet. Rename (ADR 0005): @nostr-governance/* -> @bitgate/*, governance-* elements -> bitgate-*, createGovernanceRuntime -> createBitGate. "Governance" reads as DAO voting to this audience and named a category rather than a product; BitGate names the benefit and joins the bit- family that BitVid and BitRoad compose with. Domain types keep their names — the product is BitGate, the subject matter is still governance. The migration plan is left as written; this ADR records the change rather than rewriting history. Drop-in distribution (ADR 0006): adopting BitGate meant supplying a transport, authoring a policy, and wiring every element in JavaScript. Now: - createRelayTransport(urls) — WebSocket transport with reconnection, backoff, subscription replay, and cross-relay dedupe - policy presets (social, commerce, admin-only) addressable by name; the engine still carries no thresholds of its own - <bitgate-provider> — configuration in markup, with descendants finding the runtime through a bubbling context event rather than DOM walking, which breaks across shadow boundaries - npm run build:widget — a self-contained dist/bitgate.js That last one came from running it in a browser rather than from a test. Bare specifiers resolve in Node and vitest but not in a browser, so the widget source worked everywhere except a plain static page — the one place it exists to serve. The bundle is not committed: consumers build from reviewed source. Also found by running it: the provider's ready event fires during element upgrade, before a page that defines elements after parsing can attach a listener, so it now exposes `ready` as a promise too. Four bugs fixed along the way, three found by new tests and one by the browser: admin state stayed silent when a roster change altered capabilities but no denials; the relay transport sent every subscription twice on connect; the commerce preset computed a meaningless visibility verdict at checkout and could hide a listing from its own seller; <bitgate-status> threw on an unusable decision. 759 tests; lint, typecheck, and both builds clean.
This commit is contained in:
1 parent
7f70a64d61
commit
adeba151b8
63 files changed
+2774
-401
No files matched your search
@@ -5,7 +5,7 @@
|
||||
// no thresholds, no precedence rules, no policy logic. Those live in the
|
||||
// policy definition and the engine respectively.
|
||||
|
||||
import { createApplicationAdapter } from "@nostr-governance/core";
|
||||
import { createApplicationAdapter } from "@bitgate/core";
|
||||
|
||||
/** Parameterized-replaceable kind used for commerce documents in this example. */
|
||||
export const PRODUCT_KIND = 30078;
|
||||
@@ -43,7 +43,7 @@ export const PRODUCT_KIND = 30078;
|
||||
* would not. Both are kept, because an exact-event denial must also stay
|
||||
* possible for the case where only one revision was bad.
|
||||
*
|
||||
* @type {import('@nostr-governance/core').GovernanceApplicationAdapter<Product>}
|
||||
* @type {import('@bitgate/core').GovernanceApplicationAdapter<Product>}
|
||||
*/
|
||||
export const productAdapter = createApplicationAdapter({
|
||||
applicationId: "commerce-example",
|
||||
@@ -84,7 +84,7 @@ export const productAdapter = createApplicationAdapter({
|
||||
|
||||
/**
|
||||
* Storefronts answer to the seller, the storefront address, and the exact event.
|
||||
* @type {import('@nostr-governance/core').GovernanceApplicationAdapter<Storefront>}
|
||||
* @type {import('@bitgate/core').GovernanceApplicationAdapter<Storefront>}
|
||||
*/
|
||||
export const storefrontAdapter = createApplicationAdapter({
|
||||
applicationId: "commerce-example",
|
||||
@@ -114,7 +114,7 @@ export const storefrontAdapter = createApplicationAdapter({
|
||||
* honest reviews of it, which is exactly the outcome an over-broad target list
|
||||
* would produce.
|
||||
*
|
||||
* @type {import('@nostr-governance/core').GovernanceApplicationAdapter<Review>}
|
||||
* @type {import('@bitgate/core').GovernanceApplicationAdapter<Review>}
|
||||
*/
|
||||
export const reviewAdapter = createApplicationAdapter({
|
||||
applicationId: "commerce-example",
|
||||
@@ -141,7 +141,7 @@ export const reviewAdapter = createApplicationAdapter({
|
||||
|
||||
/**
|
||||
* Sellers answer only to their own user target.
|
||||
* @type {import('@nostr-governance/core').GovernanceApplicationAdapter<{ pubkey: string }>}
|
||||
* @type {import('@bitgate/core').GovernanceApplicationAdapter<{ pubkey: string }>}
|
||||
*/
|
||||
export const sellerAdapter = createApplicationAdapter({
|
||||
applicationId: "commerce-example",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// the answer. It computes no thresholds and reimplements no precedence — which
|
||||
// is the property the extraction is meant to guarantee.
|
||||
|
||||
import { collectTargets, evaluateObject } from "@nostr-governance/core";
|
||||
import { collectTargets, evaluateObject } from "@bitgate/core";
|
||||
|
||||
import { productAdapter } from "./adapters.js";
|
||||
|
||||
@@ -20,7 +20,7 @@ import { productAdapter } from "./adapters.js";
|
||||
* listing.
|
||||
*
|
||||
* @param {Product[]} products
|
||||
* @param {import('@nostr-governance/runtime').GovernanceRuntime} runtime
|
||||
* @param {import('@bitgate/runtime').GovernanceRuntime} runtime
|
||||
* @param {string} profile
|
||||
* @returns {Array<Product & { moderation: any }>}
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ export function governProductFeed(products, runtime, profile) {
|
||||
* like censorship to sellers.
|
||||
*
|
||||
* @param {Product[]} products
|
||||
* @param {import('@nostr-governance/runtime').GovernanceRuntime} runtime
|
||||
* @param {import('@bitgate/runtime').GovernanceRuntime} runtime
|
||||
* @returns {Array<Product & { moderation: any }>}
|
||||
*/
|
||||
export function buildMarketplaceGrid(products, runtime) {
|
||||
@@ -67,7 +67,7 @@ export function buildMarketplaceGrid(products, runtime) {
|
||||
* checkout is the point where being wrong actually costs someone money.
|
||||
*
|
||||
* @param {Product} product
|
||||
* @param {import('@nostr-governance/runtime').GovernanceRuntime} runtime
|
||||
* @param {import('@bitgate/runtime').GovernanceRuntime} runtime
|
||||
* @returns {CheckoutVerdict}
|
||||
*/
|
||||
export function checkoutVerdict(product, runtime) {
|
||||
@@ -90,7 +90,7 @@ export function checkoutVerdict(product, runtime) {
|
||||
* that can answer "how many people reported me, and for what".
|
||||
*
|
||||
* @param {Product} product
|
||||
* @param {import('@nostr-governance/runtime').GovernanceRuntime} runtime
|
||||
* @param {import('@bitgate/runtime').GovernanceRuntime} runtime
|
||||
* @returns {{ visible: boolean, sellable: boolean, reasons: string[], evidence: any }}
|
||||
*/
|
||||
export function explainToSeller(product, runtime) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Commerce policy profiles.
|
||||
//
|
||||
// This example exists to prove the engine is not video-specific. Nothing here
|
||||
// touches @nostr-governance/core internals: it is built entirely from the
|
||||
// touches @bitgate/core internals: it is built entirely from the
|
||||
// public API, and the core carries none of these numbers.
|
||||
//
|
||||
// The interesting property is that one product can simultaneously be visible to
|
||||
@@ -9,7 +9,7 @@
|
||||
// blocked from checkout — four different answers from one decision, which a
|
||||
// single `hidden` boolean could not express.
|
||||
|
||||
import { createPolicyDefinition, createRoleDefinition } from "@nostr-governance/core";
|
||||
import { createPolicyDefinition, createRoleDefinition } from "@bitgate/core";
|
||||
|
||||
/**
|
||||
* Category thresholds for a marketplace.
|
||||
@@ -18,7 +18,7 @@ import { createPolicyDefinition, createRoleDefinition } from "@nostr-governance/
|
||||
* blocks checkout, because the cost of a false negative is a compromised buyer,
|
||||
* while an over-eager `misleading` threshold would just suppress lawful listings.
|
||||
*
|
||||
* @type {Record<string, import('@nostr-governance/core').CategoryThresholds>}
|
||||
* @type {Record<string, import('@bitgate/core').CategoryThresholds>}
|
||||
*/
|
||||
export const MARKETPLACE_REPORT_THRESHOLDS = {
|
||||
scam: {
|
||||
@@ -137,7 +137,7 @@ export const COMMERCE_ROLES = {
|
||||
|
||||
/**
|
||||
* Role capability map in the shape createAuthorityState expects.
|
||||
* @type {Record<string, import('@nostr-governance/core').GovernanceCapability[]>}
|
||||
* @type {Record<string, import('@bitgate/core').GovernanceCapability[]>}
|
||||
*/
|
||||
export const COMMERCE_ROLE_CAPABILITIES = Object.fromEntries(
|
||||
Object.values(COMMERCE_ROLES).map((role) => [role.name, role.capabilities]),
|
||||
|
||||
Reference in new issue
Block a user