Skip to content

Contributions, contributor pages, fetch work and the CLI workerP3/r2 engine - #80

Draft
andreimarinescu wants to merge 121 commits into
mainfrom
p3/r2-engine
Draft

andreimarinescu wants to merge 121 commits into
mainfrom
p3/r2-engine

Conversation

@andreimarinescu

Copy link
Copy Markdown
Collaborator

What changes

Article contributions

  • A contributing service principal holds the articles:contribute scope.
  • The contribution PUT has its own rules: it must be published with no sensitivity class, the expected version is required, a lower tier is refused, and the title and slug are fixed.
  • It stamps attribution: origin, contributors and version_contributor. Community records keep 20 versions.
  • POST /v1/articles/{id}/revert restores a kept version as a new one.
  • Articles list filters: status=pending and tier=.
  • /v1/contents reports a document's source, and for an attested one verified_by.

Public article pages

  • Contributor attribution, with a generic name for a banned or unresolved contributor.
  • The CC BY-SA 4.0 line.
  • New pages: /wiki/style (and .md), /wiki/terms and /wiki/wanted.
  • A safe Markdown form at /wiki/<slug>.md.
  • /llms.txt, with its Caddy route.
  • A "My contributions" view in the app, backed by GET /api/contributions.

Fetch work

  • New internal/work package: a pool fed by blocked pages, pushed pages and the frontier; leases; attestations grouped by agreement, with the quorum requiring distinct accounts and networks; a server re-fetch after the quorum window; moderation under a daily ceiling; and indexing of the verified text.
  • Engine routes: /v1/work/{claim,submit,push,settled} under the work:broker scope, plus /admin/work-purge, /admin/work-void and cosift work purge|void.
  • Switches: the config work block, COSIFT_WORK_ENABLED and COSIFT_WORK_FRONTIER.
  • The community app brokers the work through POST /api/work/claim and /api/work/submit: bearer token only, a join check, daily fetch credits for new content, counters and the ceiling alert.
  • App switches: COSIFT_COMMUNITY_WORK, COSIFT_COMMUNITY_FETCH_DAILY_CAP and COSIFT_ENV.

CLI worker

  • cosift contribute -worker [-max-pages] [-duration] [-concurrency].
  • It fetches like a browser through the public-only dialer, re-checks every redirect hop, and extracts exactly as the server's fetch does.
  • PDFs are parsed in a child process.
  • It is bounded and stops cleanly on SIGINT, with progress printed as JSON lines.
  • -index-locally now shares the same fetch and extraction.

Community app

  • A per-account daily share of the content checks (COSIFT_COMMUNITY_MODERATIONS_PER_ACCOUNT, default 100), so one account cannot use the whole day's allowance.
  • A clawback is applied even while the account is suspended or unverified, and is never given up on.
  • Dispatch takes accounts in rotation.

Docs

  • ENV.md, COMMUNITY.md, HANDOVER.md, API.md, AGENT-SETUP.md, SHARED-ACCOUNTS.md, README.md and the cosift skill now describe the above.

Every new path is off until its switch is set.

Tests

  • gofmt and vet are clean.
  • go test -race ./... passes, 25 of 25 packages.
  • All 5 release targets build.
  • The web tests pass (49).
  • The Caddyfile validates under Caddy 2.11.3.
  • Every commit builds and vets on its own.
  • No dependency changes.

…ion on version rows, reserved contributor slugs
…ad, and the contributors on a tombstone answer
…ugh the /v1 listener, and the corpus counts they leave alone
A banned, unknown or malformed contributor shows as a community member, and a failing source is never cached.
…d mask

One batched read per 30 ids; a document with any member outside the mask is refused.
… line

Community articles read "Agent submitted · Contributed by @A, @b"; banned, unknown and local-mode contributors read "a community member".
Free like the page and cached with it. Raw HTML, inline links and reference definitions become text, handles are escaped, and the licence line closes the file.
… at /wiki/style.md

The embedded text must hash to the pinned value or the pages do not start. The slugs style, terms and wanted are reserved.
Six sections with their pinned ids, a table of contents and the takedown contact address. New refuses terms that lack a section.
…title injection, article URLs and ledger rows
… and COSIFT_WORK_FRONTIER flags

An unset key takes its default, a configured 0 stays 0, and a key outside its range is an error naming it.
…e work pool, at most 100 not offered in the last day
…ion with the app's worker and net, and a 2 MiB cap for that path
… a browser-header fetchAndExtract that equals it
…refused locally when the server would refuse it
…and pin the award vector groups to them

The pinned hash was the stale copy's own, so a drift could never fail it. The award vectors are a subset of the shared groups: the test now compares them with the pinned copy.
…es to skipped

A suspended or unverified account used to leave its clawback unresolved until it was skipped after a week, and the credits came back once the account was restored. A debit needs no verified email, so it now uses the linked community user directly; with no link it keeps waiting for the account and stays pending. Positive awards resolve and expire as before.
…checks

The engine's daily ceiling on content checks is shared by every submission, so a single account could spend all of it and hold everyone else's submissions and cited-source pushes until 00:00 UTC. Each community user now has a per-UTC-day count of content checks (COSIFT_COMMUNITY_MODERATIONS_PER_ACCOUNT, 1 to 10000, default 100), kept in the community database so a restart does not reset it. A user who has reached the share has the rest of their pending submissions requeued to the next 00:00 UTC without spending an attempt, while other users' submissions keep dispatching.
@andreimarinescu
andreimarinescu marked this pull request as draft October 16, 2026 15:44
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