Skip to content

Let the person who knows the industry run it, from 20% to 80% - #5

Merged
ralyodio merged 3 commits into
mainfrom
worktree-knowledge-influencers
Sep 6, 2026
Merged

Let the person who knows the industry run it, from 20% to 80%#5
ralyodio merged 3 commits into
mainfrom
worktree-knowledge-influencers

Conversation

@ralyodio

@ralyodio ralyodio commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Phase 1 of the Knowledge Influencer PRD: a person who knows an industry claims a niche, supervises the agents building for it, and earns a rising share of what it makes — 20% at the start, 80% at the top.

What is here

  • Migration 0007niches, niche_members, niche_claims, opportunities, contribution_tiers (seeded 20→80), contribution_events, contribution_scores, tier_history, knowledge_audit_logs.
  • packages/knowledge — the domain, pure: no database, no HTTP. Tier resolution, share arithmetic in basis points, the scoring engine, and the Phase 2/3/4 contracts (domainEvent, machineRevenueEvent, attributableNetMinor, allocate).
  • packages/db/src/knowledge.js — every statement the programme runs, exported as @nichedb/db/knowledge.
  • Pages/opportunities, /opportunities/<slug> with the claim form, /<niche>, /<niche>/skill.md, /<niche>/manifest.json, /@<handle>, /dashboard/niches, /admin/knowledge.
  • API — the public and authenticated /api/v1 surface from §22, including POST /api/v1/niches/<slug>/contributions.
  • Docsdocs/knowledge-influencers.md, docs/revenue-share.md, docs/x402-attribution.md, docs/architecture.md, plus a README section.

What is deliberately not here

No payment or x402 infrastructure. The gateway already in production is untouched; the only change to pricing.js is adding /opportunities to openPaths, for the same reason /sell is there. The revenue ledger's arithmetic is written and tested — only the tables and the wiring are missing.

Decisions worth reviewing

Stack. The PRD assumes Next.js 16 + TypeScript + shadcn + Turso. This repo is Bun + Hono JSX + plain JavaScript + Postgres, so per §32 the work conforms to the repo. Nothing was rebuilt that already existed.

Reuse. @profullstack/partners already runs the other 20–80 programme here (paying people whose writing is in the index for what crawlers take). Its commissionLadder is additive over property and niche counts and cannot express score thresholds, so the tier table is its own thing — but both cap at 80% and the two ledgers are kept apart on purpose, because conflating a commission on somebody else's traffic with a share of a business you help run makes both impossible to audit. docs/revenue-share.md sets out the distinction.

Migration numbering. 0006 is left for the partners branch still in flight, so the two cannot land as the same number and leave the order ambiguous.

Routing. The niche page is at the site root as the PRD asks. It cannot shadow a real page: the route registers after every other one, and a niche may not take a reserved slug — refused on creation, with a shape check in the database under it. Verified live against every existing route.

/@handle is answered by the same handler because Hono does not match a parameter behind a literal prefix inside a segment; /@:handle silently never fires. Found by testing, not by reading.

Seeding. Thirteen niches are opened from this deployment's own collections rather than invented industries, and every one is unscored. An opportunity score nobody has measured is left null and the page prints "not scored yet".

Anti-gaming

Impact over volume, in five enforced places: evidence or nothing; a claim on money needs an outside reference and is never auto-verified; duplicates book once against a unique index; repeating a type pays half, then a quarter, then nothing; trust is earned per niche. A test asserts that ten thousand submissions of the cheapest type reaches a score under 200 — a specialist, not the top rung.

A reversal marks the row and leaves its points alone. An earlier draft also wrote a compensating negative row, which subtracted the same points twice and collapsed a legitimate score of 23 to 0. Caught by running the full flow against a real Postgres; there is now a test for it.

Verification

  • bun test — 87 pass, 0 fail (36 engine, 18 schema against in-process Postgres, plus the existing suite). Needs no server.
  • bun run lint — clean; the two remaining CSS warnings and the biome.json deprecation are pre-existing on main.
  • Booted against Postgres 18 and Redis 8 and driven end to end: claim → approve → contribute → duplicate refused → verify → tier promotion → reversal → tier demotion, with tier history and audit rows checked at each step.

No new environment variables.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W9NGGLDvNayi6uWheSXDGF

@ralyodio
ralyodio marked this pull request as ready for review September 6, 2026 06:31
ralyodio and others added 3 commits September 6, 2026 06:33
Every collection here is also a market somebody knows better than we do. This
is the seller side of that knowledge: a person claims a niche, supervises the
agents building for it, and earns a rising share of what it makes.

Phase 1 of the PRD: niches, opportunities, claims, membership, contribution
events, scoring, the seven-rung ladder, tier history, the public pages and the
admin queue. No payment or x402 infrastructure is added — the gateway already
in production is untouched, and the contracts the later phases arrive through
are defined and tested in packages/knowledge/src/events.js.

Impact over volume is the whole design. Score comes only from contributions
somebody verified: a submission with nothing checkable attached waits, a claim
on money needs an outside reference and is never auto-verified, a duplicate
books once against a unique index, and repeating a type pays half, then a
quarter, then nothing. Ten thousand submissions of the cheapest thing there is
reaches a score under 200, and there is a test that asserts it.

Money is integer minor units and integer basis points throughout, capped at
8000. A tier change never rewrites a settled allocation, which is what
tier_history is for. Reversal marks the row and leaves its points alone: a
status that excludes a row and a compensating negative row would subtract the
same points twice and take honest work down with the fraud.

The niche page is served from the site root, as the PRD asks. Two things stop
it shadowing a real page: the route is registered after every other one, and a
niche may not take a slug the site already uses, refused on creation and backed
by a shape check in the database. /@handle is answered by the same handler,
because Hono does not match a parameter behind a literal prefix inside a
segment and /@:handle never fires.

Migration is numbered 0007 with 0006 left for the partners branch still in
flight. Thirteen niches are opened from this deployment's own collections,
unscored: an opportunity score nobody has measured is left null and the page
says so rather than printing a number it cannot defend.

No new environment variables.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W9NGGLDvNayi6uWheSXDGF
The Dockerfile lists every workspace package.json by hand, so a new one that
is not in the list fails the build at bun install. packages/knowledge was
missing.

Verified by building the image and booting it against Postgres 18 and Redis 8:
migrations apply, the niches seed, and the pages serve.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W9NGGLDvNayi6uWheSXDGF
/sell is in the gateway's openPaths because charging a crawler to read our own
recruiting page would be an odd way to run a marketplace. /opportunities is the
same page for the other side of the marketplace and belongs there too.

Both spellings, because the gateway prefix-matches only entries ending in a
slash.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W9NGGLDvNayi6uWheSXDGF
@ralyodio
ralyodio force-pushed the worktree-knowledge-influencers branch from 39aed00 to 039dc30 Compare September 6, 2026 06:35
@ralyodio
ralyodio merged commit 7b1d138 into main Sep 6, 2026
3 checks passed
@ralyodio
ralyodio deleted the worktree-knowledge-influencers branch September 6, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant