Spaces:
Running
Running
Delete DATASET_CONTRIBUTION_GUIDE.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884# Dataset Contribution and Review Guide
This guide explains the complete dataset-contribution workflow for the Sphinx AIAssistant: what a reader submits, where the data goes, how maintainers review it,when it becomes training-eligible, how withdrawal works, and how the same workflowmaps to Hugging Face, GitHub, GitLab, and Bitbucket Cloud.
Use this guide when you see **Contribute to dataset**, **Submit for review**,`Status: QUARANTINED`, or `Status: IN REVIEW` in the assistant UI.
For local ratings, generic page feedback, and one-Q&A maintainer feedback review, see [`FEEDBACK_REVIEW_GUIDE.md`](./FEEDBACK_REVIEW_GUIDE.md). For low-level storage topology, deduplication, migration, and provider API details, see [`DATASET_COLLECTION_GUIDANCE.md`](./DATASET_COLLECTION_GUIDANCE.md).
---
## 1. The short version
For human-reviewed datasets, configure:
```textCONTRIBUTION_REVIEW_MODE=provider-pr```
Then a contribution follows this lifecycle:
```textReader | | Contribute to dataset | inspect exact JSON | privacy preflight | explicit consent vPOST /v1/contribute | vPRIMARY repository review | | Hugging Face -> Pull Request | GitHub -> Pull Request | GitLab -> Merge Request | Bitbucket -> Pull Request vIN REVIEW / QUARANTINEDtrainingEligible = false | +-----------------------+ | | | maintainer merges | maintainer closes/declines v vAPPROVED / ELIGIBLE NOT ACCEPTEDcanonical branch never training-eligible | | contributor can later withdraw vWITHDRAWN```
The configured canonical branch, normally `main`, is the training-eligibilityboundary. An open review is **not** training data.
---
## 2. Four control planes that must stay separate
The assistant deliberately separates three kinds of user action:
| Control plane | Contains conversation content? | Network by default? | Training eligible? ||---|---:|---:|---:|| Share/export | only when the reader explicitly shares/exports | depends on chosen share mode | No || Maintainer feedback review | Exactly one Q&A + rating + optional note | Off until separate review-sharing permission | Never || Dataset contribution | Yes, exact reviewed content | Only after explicit contribution consent | Only after review approval |
A thumbs-up/down rating is not a dataset contribution. Sharing one Q&A with maintainers is also not a dataset contribution and remains permanently non-training feedback. A shared conversation is not a dataset contribution. Only the dedicated **Dataset contribution** tab can submit content for training review.
---
## 3. What the reader does
The shared **Feedback & contribution** workspace has separate **Feedback**, **Dataset contribution**, and **Activity** tabs. The Dataset contribution tab supports three scopes:
- **This Q&A** β one selected user/assistant exchange.- **Rated answers** β only Q&A records the reader explicitly rated.- **Whole conversation** β one ordered `recordType="conversation"` record with `messages[]`; it is not fragmented into unrelated turns.
When **Ratings and feedback** is included, Q&A contribution rows and rated assistantmessages carry the same bounded schema-v5 feedback lineage used by the Feedbackcontrol plane (`feedbackId`, `feedbackChainId`, `prevFeedbackId`,`prevFeedbackIds[]`, `editCount`). Disabling **Ratings and feedback** removes both therating signal and those lineage identifiers, avoiding a hidden cross-link.
Before submission the reader can:
1. choose the scope;2. optionally add reviewer context;3. inspect the exact JSON that will be submitted;4. run the privacy preflight;5. explicitly consent to dataset review/use;6. press **Submit for review**.
### Local inspection artifacts
The inspector has two intentionally different views. Their filenames identify boththe selected scope and the lifecycle role so a saved file remains understandablewithout opening it:
```textThis Q&A ai-contribution-single-pair-request-json-<timestamp>.json ai-contribution-single-pair-cloud-projection-jsonl-<timestamp>.jsonl
Rated answers ai-contribution-rated-answers-request-json-<timestamp>.json ai-contribution-rated-answers-cloud-projection-jsonl-<timestamp>.jsonl
Whole conversation ai-contribution-whole-conversation-request-json-<timestamp>.json ai-contribution-whole-conversation-cloud-projection-jsonl-<timestamp>.jsonl```
**Request JSON** is the exact browser request after the selected Content & privacypolicy. **Cloud projection JSONL** is a local projection of the canonical`contributions/*.jsonl` row(s); it is not proof that a cloud write already happened.Only `_ts` and `_dedup_key` remain server-owned placeholders before submission.
Contribution model evidence is deliberately attribution-only: `id`, `provider`, and`model`. Endpoint URLs, model-info links, labels, descriptions, default/custom UIstate, credentials, URL query strings, and fragments are not contribution content.The server independently repeats that minimization and sanitizes page provenance solegacy/custom clients cannot bypass the browser boundary.
A successful provider-native submission shows wording similar to:
```textSubmitted for review
Status: IN REVIEW Β· queued in the huggingface review workflow;not training-eligible unless merged into the canonical branch.
Save private receipt | Copy private withdrawal code | Check statusCopy support reference | Delete pending / withdraw training use```
In compatibility `ledger` mode it instead shows `Status: QUARANTINED` because thecontent is waiting in the lifecycle ledger for an authorized promotion operation.
---
## 4. Derived cloud merged contribution view
Individual canonical provider contribution records such as`contributions/YYYY/MM/DD/ct_<recordId>.jsonl` remain the lifecycle/write authority.For analysis, maintainers can generate one deterministic derived view withoutturning a monolithic file into the mutation authority:
```bashpython deduplicate_dataset.py \ --from-storage-config \ --contribution-cloud-merged```
This produces:
```textai-contribution-cloud-merged-jsonl-<UTC timestamp>.jsonlai-contribution-cloud-merged-jsonl-<UTC timestamp>.jsonl.manifest.json```
The view contains only current `trainingStatus="eligible"` contribution rows afterthe normal deduplication, withdrawal suppression, and feedback-lineage resolver. Itcan contain both `recordType="qa"` and `recordType="conversation"`. The manifestbinds SHA-256, byte count, total record count, Q&A/conversation counts, and theidentity fields used to trace merged rows back to authoritative records.
A previously generated merged file is explicitly ignored if it appears inside alocal/provider snapshot, preventing recursive self-ingestion. `--include-unreviewed`is rejected for this mode.
## 5. The management receipt
The reader receives a private management capability after submission. The UI keepsit available while the tab still owns the active review, and automatically restoresthe management controls when the contribution sheet is reopened. The reader can alsomove that authority outside browser state in two equivalent private forms:
- **Save private receipt** β a JSON capability file;- **Copy private withdrawal code** β a compact `aicm2.β¦` representation of the same capability.
Both are secrets. A third path, **Copy support reference**, is deliberately non-secretand exists only so a maintainer can locate the native review or stable `.jsonl` file.
Conceptually it contains:
```json{ "schemaVersion": 2, "kind": "dataset-contribution-management", "receiptId": "<opaque receipt>", "deleteToken": "<private management capability>", "reviewProvider": "huggingface", "reviewId": "7", "reviewPath": "contributions/2026/08/31/ct_<stable-review-key>.jsonl", "reviewRevision": 3, "expiresAt": 0, "consentVersion": "2.0.0"}```
Treat this file like a private capability:
- do not publish it;- do not paste it into issues, logs, or repository commits;- do not store it in documentation `conf.py`;- anyone who obtains it may be able to manage that contribution.
The server stores only the management-token hash, not the raw token.
The controls mean:
| Control | Purpose | Safe to share? ||---|---|---|| **Save private receipt** | Save the full management capability as JSON | **No** || **Copy private withdrawal code** | Save the same capability as compact text | **No** || **Recover withdrawal access** | Import a private receipt or paste a private code later | Local action only || **Check status** | Check open/closed/merged lifecycle state | No content is returned || **Copy support reference** | Copy receipt + provider review number + stable `.jsonl` path | **Yes**, it contains no withdrawal capability || **Copy maintainer removal request** | Produce ready-to-send removal wording using only the support reference | **Yes** || **Delete pending / withdraw training use** | Close/remove pending review or withdraw an approved record | Requires private capability |
### If the panel is closed
Closing and reopening the AI panel does not intentionally remove the management UI.If the tab still holds the active review capability, reopening **Contribute to dataset**rehydrates the status/withdrawal actions automatically.
If the tab/browser state is gone, open **Recover withdrawal access** and either importthe saved private JSON receipt or paste the private `aicm2.β¦` withdrawal code.
### If the private capability no longer resolves
A saved receipt/code is portable but does not extend server-side retention. Pendingledger entries can expire according to deployment policy, and an in-memory ledger canbe lost on restart. In that case use **Copy support reference** (saved earlier) or thevisible repository review/file reference when available and contact a maintainer. Areference looks like:
```textDataset contribution support referenceReceipt: <opaque receipt>Provider: huggingfaceReview: #7Record: contributions/2026/08/31/ct_<stable-review-key>.jsonlRevision: 3```
The support reference deliberately omits the private delete/withdraw token. It is safeto paste into an issue or support message; the private receipt/code is not.
---
## 6. `provider-pr` versus `ledger`
### Recommended: `provider-pr`
```textCONTRIBUTION_REVIEW_MODE=provider-pr```
The proxy opens the Primary provider's normal review object. Maintainers use theprovider UI they already know. No custom review dashboard is required.
Benefits:
- review bytes are durable in the provider rather than only in process memory;- the canonical branch remains clean until approval;- normal repository review history is available to maintainers;- merge is the explicit eligibility decision;- provider credentials stay server-side;- the browser receives safe review status, not maintainer credentials.
### Compatibility: `ledger`
```textCONTRIBUTION_REVIEW_MODE=ledger```
The historical mode keeps content in the contribution lifecycle ledger until anauthorized promotion call writes an eligible record to configured storage.
Use this mode only when you intentionally want an API/operator-driven promotionworkflow. `CONTRIBUTION_REVIEW_TOKEN` is required for the promotion endpoint.
### How to confirm the active mode
Open the proxy status endpoint:
```textGET https://your-proxy.example/```
Look for:
```json{ "training": { "contribute_ready": true, "contribution_review_mode": "provider-pr", "canonical_branch": "main" }}```
If it still says `ledger`, no provider PR/MR will be created automatically.
---
### Review continuity: one management receipt, one review thread
`provider-pr` mode treats the saved management receipt as the continuity key forone logical contribution review. This prevents a reader from creating a newprovider review every time the same conversation is submitted again from thesame tab/session authority.
| Reader action | Proxy behavior | Reviewer result ||---|---|---|| First submit | Open one native PR/MR | One new review appears || Submit again with identical reviewed bytes | Return `reviewUpdate="unchanged"` | No new PR/MR and no new commit || Conversation changed, then submit again | `PUT` the pending contribution and commit revision N+1 to the same review | Same PR/MR, latest commit is authoritative || Check status | Look up the persisted provider review ID directly | No queue scan in the normal path || Withdraw while pending | Close/decline the same review | Review cannot be merged accidentally || Review already merged/closed | Update fails closed | Reader must explicitly start a new follow-up review |
The UI changes **Submit for review** to **Update existing review** while thatreceipt remains active. It also shows the remembered review revision. Thiscontinuity is tab/session scoped because the management capability is sensitive;it is not a global browser fingerprint.
The provider implementation keeps the native review identity stable:
- Hugging Face commits revisions to `refs/pr/<number>`;- GitHub commits revisions to the existing Pull Request source branch;- GitLab commits revisions to the existing Merge Request source branch;- Bitbucket commits revisions to the existing Pull Request source branch.
The contribution file path is stable for that receipt as well. New contentreplaces the pending review file instead of creating `ct_<new-content-hash>.jsonl`for every revision. Earlier provider commits remain the review history, while thelatest revision is what a maintainer should approve.
> **Deliberate boundary:** this is capability-scoped continuity, not global content deduplication. Two independent readers can submit identical content as> two independent reviews because each must retain independent withdrawal and> management authority. The server must not silently merge those authorities> merely because the bytes match.
For large queues, the proxy stores the provider-native review ID in the receiptledger when the review is opened. Status, update, merge, and withdrawal then usedirect review lookup. Repository-wide PR/MR scanning remains only a boundedlegacy/recovery fallback for receipts created before review locators were stored.
## 7. Primary and Mirrors
`RECORD_STORAGE_TARGETS` may override the record authority with one Primary andseveral Mirrors. When that variable and legacy `TRAINING_DATASET_REPO` are bothunset, the proxy uses its bundled `DEFAULT_RECORD_STORAGE_TARGETS` projection(HF Primary + GitHub Mirror) from `DEFAULT_TARGET_REGISTRY`. The registry'sseparate `github-learn-ai` publication Primary never receives contributionrecords.Exactly one target must have:
```json"role": "primary"```
Only the **Primary** decides eligibility. Mirrors are not independent review authorities.
Example:
```json[ { "id": "hf-primary", "label": "Hugging Face Dataset", "provider": "huggingface", "role": "primary", "repo": "example-org/assistant-contributions", "branch": "main", "paths": { "feedback": "feedback", "contributions": "contributions" }, "token_env": "AI_RECORD_STORAGE_TOKEN_HF_PRIMARY", "token_type": "fine-grained", "expose_links": true }, { "id": "github-mirror", "label": "GitHub Mirror", "provider": "github", "role": "mirror", "repo": "example-org/assistant-records", "branch": "main", "paths": { "feedback": "feedback", "contributions": "contributions" }, "token_env": "AI_RECORD_STORAGE_TOKEN_GITHUB_MIRROR", "expose_links": true }]```
With this topology:
```textSubmit | vHugging Face PRIMARY | vHF Pull Request <- review authority | | merge vHF main <- eligible authority
GitHub MIRROR <- not an independent approval authority```
Do **not** expect one user submission to create a review on every mirror. Thatwould create conflicting eligibility decisions.
Current implementation also does not synchronously fan a maintainer's externalprovider-UI merge out to all Mirrors. If immediate mirror convergence is required,run an explicit post-merge reconciliation/replication process or operate with asingle Primary during the review stage.
---
## 8. Provider-specific reviewer workflow
The proxy uses a receipt-derived opaque review key such as:
```textai-contrib-<24-hex-key>Dataset contribution <24-hex-key>```
User questions, answers, names, page titles, and notes are not used in branch orreview titles.
### Hugging Face
Primary configuration:
```json{ "provider": "huggingface", "role": "primary", "repo": "example-org/assistant-contributions", "branch": "main", "token_env": "AI_RECORD_STORAGE_TOKEN_HF_PRIMARY"}```
Review location:
```textDataset repository -> Community -> Pull Requests```
The proxy creates the change using the Hub PR mechanism (`create_pr=True`). HuggingFace PRs use special repository refs rather than requiring contributor forks.
Reviewer actions:
- **Merge** -> contribution becomes eligible on the next lifecycle/status sync.- **Close** -> browser status is shown as **NOT ACCEPTED**; it remains training-ineligible.
Official references:
- https://huggingface.co/docs/hub/en/repositories-pull-requests-discussions- https://huggingface.co/docs/huggingface_hub/main/guides/community
### GitHub
Review location:
```textRepository -> Pull requests```
The proxy creates an isolated branch and opens a PR whose base is the configuredcanonical branch.
Reviewer actions:
- **Merge pull request** -> eligible.- **Close pull request** -> not accepted.
Official reference:
- https://docs.github.com/en/rest/pulls
### GitLab
Review location:
```textProject -> Merge requests```
The proxy creates a source branch and opens a merge request targeting theconfigured canonical branch.
Reviewer actions:
- **Merge** -> eligible.- **Close** -> not accepted.
For self-managed GitLab, only the GitLab target supports a validated custom`api_base`.
Official reference:
- https://docs.gitlab.com/api/merge_requests/
### Bitbucket Cloud
Review location:
```textRepository -> Pull requests```
The proxy creates a source branch and opens a pull request with the configuredcanonical branch as destination.
Reviewer actions:
- **Merge** -> eligible.- **Decline** -> not accepted.
Official reference:
- https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/
---
## 9. Scenario guide
### Scenario A β normal approval
```textReader submits -> provider review opens -> status IN REVIEW -> maintainer inspects exact contribution file -> maintainer merges -> canonical branch contains eligible record -> reader presses Check status -> status APPROVED / ELIGIBLE```
The contribution file is written to its final canonical `contributions/...` pathinside the isolated review ref. Before merge, that path is not part of `main`.
### Scenario B β maintainer rejects it
```textReader submits -> review opens -> maintainer closes/declines without merge -> trainingEligible remains false -> Check status shows NOT ACCEPTED```
No training job should read closed review refs. Dataset construction accepts onlyeligible records from the canonical dataset view by default.
### Scenario C β reader withdraws before review
The reader selects **Delete pending / withdraw training use** while the review isstill open.
The proxy:
1. checks whether the review was merged first;2. if still pending, closes/rejects the provider review;3. removes the active pending payload from the lifecycle ledger;4. returns `status="deleted"`.
This is a logical/current-view deletion guarantee, not a promise of forensicphysical erasure from provider caches, snapshots, Git object history, or backups.
### Scenario D β reader withdraws after approval
If the review was already merged, the same management capability changes meaning:
```textELIGIBLE | | contributor withdrawal vWITHDRAWING | vwithdrawal tombstone + best-effort current-view removal | vWITHDRAWN```
The dataset builder applies the withdrawal using the server-owned dedup key andexcludes withdrawn content from normal training output. Versioned repositoryhistory is not represented as globally erased.
### Scenario E β provider review creation fails
A submission can enter the local lifecycle ledger but fail to open its nativeprovider review, for example because of a missing repository permission.
The proxy returns HTTP 503 with a retry-oriented message instead of pretending areview exists. Current create-once clients can retry the same operation withoutintentionally duplicating the contribution.
Check:
- `CONTRIBUTION_REVIEW_MODE=provider-pr`;- Primary token exists;- token has write/review permissions;- repository ID and branch are correct;- repository allows PR/MR creation;- proxy logs show a bounded reason code, not secret values.
### Scenario F β Space restarts while a review is open
The provider PR/MR is durable at the provider, but the contributor managementreceipt also depends on the contribution ledger.
If startup reports:
```textbackend=memory durability=process_local shared=False```
then a restart can lose the local receipt lifecycle authority even though theprovider review still exists.
For one restart-durable instance, use SQLite on persistent storage:
```textCONTRIBUTION_LEDGER_BACKEND=sqliteCONTRIBUTION_LEDGER_SQLITE_PATH=/data/contribution-lifecycle.sqlite3CONTRIBUTION_REQUIRE_DURABLE=true```
For several replicas, use one shared Redis authority:
```textCONTRIBUTION_LEDGER_BACKEND=redisCONTRIBUTION_LEDGER_REDIS_URL=<secret Redis URL>CONTRIBUTION_LEDGER_KEY_SECRET=<strong secret>CONTRIBUTION_REQUIRE_DURABLE=trueCONTRIBUTION_REQUIRE_SHARED=true```
Redis durability/backup guarantees still depend on the Redis deployment itself.
---
## 10. Variables and Secrets
The server-side deployment owns storage. Browser `conf.py` must never containprovider write credentials.
### Variables β non-sensitive configuration
| Variable | Typical value | Why ||---|---|---|| `CONTRIBUTION_REVIEW_MODE` | `provider-pr` | Use native repository review || `RECORD_STORAGE_TARGETS` | JSON array | Primary/mirror topology and token **names** || `TRAINING_DATASET_REPO` | `org/repo` | Legacy HF-only repository identifier || `ALLOWED_MODELS` | comma-separated IDs | Exact model admission list || `HF_SPACES_MODEL_NAMESPACES` | `example-org` | Path-2 namespace routing || `ALLOWED_ORIGINS` | exact browser origins | Custom docs sites || `ALLOWED_ORIGINS_MODE` | `replace` for forks | Own the downstream CORS boundary || `HF_TOKEN_TYPE` | `fine-grained` / `read` / `write` | Non-secret token classification |
### Secrets β credentials/capabilities
| Secret | Purpose ||---|---|| `HF_TOKEN` | model inference credential || `AI_RECORD_STORAGE_TOKEN_HF_PRIMARY` | example HF repository write credential || `AI_RECORD_STORAGE_TOKEN_GITHUB_PRIMARY` | example GitHub Primary credential || `AI_RECORD_STORAGE_TOKEN_GITHUB_MIRROR` | example GitHub Mirror credential || `AI_RECORD_STORAGE_TOKEN_GITLAB_*` | GitLab target credential || `AI_RECORD_STORAGE_TOKEN_BITBUCKET_*` | Bitbucket target credential || `CONTRIBUTION_REVIEW_TOKEN` | optional API-driven merge/promotion capability || `CONTRIBUTION_LEDGER_KEY_SECRET` | shared Redis receipt pseudonymization key |
`RECORD_STORAGE_TARGETS` contains only a `token_env` name such as:
```json"token_env": "AI_RECORD_STORAGE_TOKEN_HF_PRIMARY"```
Never put the corresponding token value inside the JSON.
---
## 11. Minimal deployment recipes
### Hugging Face Primary only
Variables:
```textCONTRIBUTION_REVIEW_MODE=provider-prRECORD_STORAGE_TARGETS=[{"id":"hf-primary","label":"Hugging Face Dataset","provider":"huggingface","role":"primary","repo":"example-org/assistant-contributions","branch":"main","paths":{"feedback":"feedback","contributions":"contributions"},"token_env":"AI_RECORD_STORAGE_TOKEN_HF_PRIMARY","token_type":"fine-grained","expose_links":true}]```
Secrets:
```textAI_RECORD_STORAGE_TOKEN_HF_PRIMARY=<repo-scoped write token>```
### GitHub Primary only
Variables:
```textCONTRIBUTION_REVIEW_MODE=provider-prRECORD_STORAGE_TARGETS=[{"id":"github-primary","label":"GitHub Records","provider":"github","role":"primary","repo":"example-org/assistant-records","branch":"main","paths":{"feedback":"feedback","contributions":"contributions"},"token_env":"AI_RECORD_STORAGE_TOKEN_GITHUB_PRIMARY","expose_links":true}]```
Secrets:
```textAI_RECORD_STORAGE_TOKEN_GITHUB_PRIMARY=<repo-scoped token>```
### Hugging Face Primary + GitHub Mirror
Variables:
```textCONTRIBUTION_REVIEW_MODE=provider-prRECORD_STORAGE_TARGETS=[{"id":"hf-primary","label":"Hugging Face Dataset","provider":"huggingface","role":"primary","repo":"example-org/assistant-contributions","branch":"main","paths":{"feedback":"feedback","contributions":"contributions"},"token_env":"AI_RECORD_STORAGE_TOKEN_HF_PRIMARY","token_type":"fine-grained","expose_links":true},{"id":"github-mirror","label":"GitHub Mirror","provider":"github","role":"mirror","repo":"example-org/assistant-records","branch":"main","paths":{"feedback":"feedback","contributions":"contributions"},"token_env":"AI_RECORD_STORAGE_TOKEN_GITHUB_MIRROR","expose_links":true}]```
Secrets:
```textAI_RECORD_STORAGE_TOKEN_HF_PRIMARY=<HF repository write token>AI_RECORD_STORAGE_TOKEN_GITHUB_MIRROR=<GitHub repository token>```
The HF Primary receives the review. The GitHub Mirror does not independentlyapprove or reject it.
---
## 12. First deployment checklist
Before inviting real contributions:
- [ ] `GET /` reports `contribute_ready: true`.- [ ] `contribution_review_mode` is `provider-pr` if native review is intended.- [ ] Exactly one storage target has `role: primary`.- [ ] The Primary repository exists and the configured branch exists.- [ ] Provider tokens are Secrets, not `conf.py` values.- [ ] `RECORD_STORAGE_TARGETS` contains token env-var names, never token values.- [ ] The dataset/repository is private if submissions may contain non-public material.- [ ] A synthetic submission creates a real PR/MR on the Primary.- [ ] The contribution is absent from canonical `main` before merge.- [ ] Closing/declining the review leaves it training-ineligible.- [ ] Merging the review makes **Check status** report approved/eligible.- [ ] Pending deletion closes the open review.- [ ] Post-merge withdrawal removes the record from ordinary training output.- [ ] Receipt storage is durable enough for your deployment (`sqlite` or `redis` for production use).- [ ] `deduplicate_dataset.py` produces training output only from eligible, non-withdrawn records.
---
## 13. Troubleshooting
### `Submitted for review` appears, but no provider PR/MR exists
Check the proxy status first:
```json"contribution_review_mode": "ledger"```
If it says `ledger`, this is expected. Set:
```textCONTRIBUTION_REVIEW_MODE=provider-pr```
and restart the service.
If it already says `provider-pr`, check the Primary token/repository permissionsand server logs for `contribute.review_open_fail`.
### The review exists on HF but not on the GitHub Mirror
Expected when HF is Primary. Only the Primary owns review authority.
### The review was merged manually, but the browser still says IN REVIEW
Press **Check status**. The proxy re-reads the provider review state and ratchetsthe receipt to eligible when it observes a merge.
If the receipt ledger was lost after a restart, the saved receipt may return 404even though the PR still exists. Use durable receipt storage for production.
### The review was closed, but the internal lifecycle still says `quarantined`
Provider close/decline is represented by the safe `reviewStatus` while the pendingreceipt remains manageable until deletion/expiry. The browser intentionally rendersthis combination as **NOT ACCEPTED** and it remains `trainingEligible=false`.
### `dataset_repo` is null on `/`
When `RECORD_STORAGE_TARGETS` is active, `training.dataset_repo` is the legacysingle-HF field and may be null. Use:
```json"storage": { "configured": true, "target_count": 1, "primary_ready": true}```
as the provider-neutral readiness signal.
### Startup says receipt backend is `memory`
The workflow can function, but receipt management is process-local. A restart canmake saved management receipts unresolved. Configure SQLite or Redis before relyingon long-lived review windows.
---
## 14. Security invariants
These are architecture requirements, not optional UX preferences:
1. Provider write tokens are server-side only.2. `main` (or the configured canonical branch) is the eligibility authority.3. An open PR/MR is never training eligible.4. Mirrors never independently decide eligibility.5. Generic page feedback and local Assistant ratings cannot silently become training content.6. Dataset content requires explicit, versioned contribution consent.7. The reader sees the exact JSON before submission.8. Receipt/delete capability is separate from reviewer authority.9. Repository metadata uses opaque receipt-derived identifiers, not user content.10. Withdrawal means enforceable exclusion from normal training output; it does not promise physical erasure of all versioned history, caches, backups, or infrastructure snapshots.
---
## 15. Related documentation
- [`README.md`](./README.md) β extension overview and first setup.- [`_example_conf.py`](./_example_conf.py) β Sphinx configuration reference.- [`_hf_spaces_proxy/README.md`](./_hf_spaces_proxy/README.md) β proxy deployment and Variables/Secrets.- [`DATASET_COLLECTION_GUIDANCE.md`](./DATASET_COLLECTION_GUIDANCE.md) β deep multi-store operations, migration, deduplication, and provider details.- [`_hf_spaces_proxy/deduplicate_dataset.py`](./_hf_spaces_proxy/deduplicate_dataset.py) β canonical dataset reader/deduplicator.
## Release archive witness boundary
Dataset contribution behavior is unchanged by Run 162. Release-native evidence archivesmay be covered by the independent archive-health witness/recovery gate described in`_hf_spaces_proxy/security/RELEASE_ARCHIVE_WITNESS_GUIDE.md`; no contribution payload orgeneric page-feedback authority is widened by that release-security tooling.DATASET_CONTRIBUTION_GUIDE.mdDeleted-884