Skip to content

Commit 4e043a9

Browse files
V37 Gate 5: Source selector context policy
Implement the package-owned ConversationSourceSelector contract, deterministic source-safe artifact, generator, checker, protocol exports, and tests. Add the Conversations source selector helper and UI panel with policy, rights, settlement, disclosure, denial, and retry preview coverage, then wire docs, scripts, workflows, and uapi tests.
1 parent 9e4bf06 commit 4e043a9

24 files changed

Lines changed: 3961 additions & 11 deletions

.bitcode/v37-conversation-source-selector.json

Lines changed: 2164 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/bitcode-canon-quality.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ jobs:
118118
if [ -f scripts/check-v37-gate4-conversation-writing-workspace.mjs ]; then
119119
node scripts/check-v37-gate4-conversation-writing-workspace.mjs --skip-branch-check
120120
fi
121+
if [ -f scripts/check-v37-gate5-conversation-source-selector.mjs ]; then
122+
node scripts/check-v37-gate5-conversation-source-selector.mjs --skip-branch-check
123+
fi
121124
fi
122125
else
123126
echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2

.github/workflows/bitcode-gate-quality.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ jobs:
247247
if [ -f scripts/check-v37-gate4-conversation-writing-workspace.mjs ]; then
248248
node scripts/check-v37-gate4-conversation-writing-workspace.mjs --skip-branch-check
249249
fi
250+
if [ -f scripts/check-v37-gate5-conversation-source-selector.mjs ]; then
251+
node scripts/check-v37-gate5-conversation-source-selector.mjs --skip-branch-check
252+
fi
250253
fi
251254
else
252255
echo "Unexpected BITCODE_SPEC.txt pointer: $POINTER" >&2
@@ -336,6 +339,7 @@ jobs:
336339
tests/api/conversationSessionRouteHistoryContract.test.ts \
337340
tests/api/conversationStreamEventContract.test.ts \
338341
tests/conversationStreamPipelineLog.test.tsx \
342+
tests/conversationSourceSelector.test.tsx \
339343
tests/conversationWritingWorkspace.test.tsx \
340344
tests/auxillariesExternalsPane.test.tsx \
341345
tests/profileStep.test.tsx \

BITCODE_SPEC_V37.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
## Status
44

55
- Version: `V37`
6-
- V37 state: draft implementation; Gate 4 closes ConversationWritingWorkspace fullscreen writing mode and composer workspace over active V36 Exchange canon
6+
- V37 state: draft implementation; Gate 5 closes ConversationSourceSelector source selection and context policy over active V36 Exchange canon
77
- Current canonical/latest target: `V36`
88
- Prior canonical anchor: `BITCODE_SPEC_V36.md`
99
- Prior generated proof appendix: `BITCODE_SPEC_V36_PROVEN.md`
10-
- Generated structured artifact inventory: draft `.bitcode/v37-spec-family-report.json`, `.bitcode/v37-canonical-input-report.json`, `.bitcode/v37-canon-posture-drift-report.json`, `.bitcode/v37-conversation-session-route-history.json`, `.bitcode/v37-conversation-stream-event-contract.json`, and `.bitcode/v37-conversation-writing-workspace.json`
11-
- Source parity state: V37 source parity includes Gate 1 spec family, roadmap, docs, workflow, and checker posture, Gate 2 package-owned ConversationSession route-history contracts, Gate 3 package-owned ConversationStreamEvent stream UI/event contracts, and Gate 4 package-owned ConversationWritingWorkspace fullscreen writing contracts
10+
- Generated structured artifact inventory: draft `.bitcode/v37-spec-family-report.json`, `.bitcode/v37-canonical-input-report.json`, `.bitcode/v37-canon-posture-drift-report.json`, `.bitcode/v37-conversation-session-route-history.json`, `.bitcode/v37-conversation-stream-event-contract.json`, `.bitcode/v37-conversation-writing-workspace.json`, and `.bitcode/v37-conversation-source-selector.json`
11+
- Source parity state: V37 source parity includes Gate 1 spec family, roadmap, docs, workflow, and checker posture, Gate 2 package-owned ConversationSession route-history contracts, Gate 3 package-owned ConversationStreamEvent stream UI/event contracts, Gate 4 package-owned ConversationWritingWorkspace fullscreen writing contracts, and Gate 5 package-owned ConversationSourceSelector source/context policy contracts
1212
- Active canonical pointer during draft opening: `BITCODE_SPEC.txt` -> `V36`
1313
- Notes companion: `BITCODE_SPEC_V37_NOTES.md`
1414
- Delta companion: `BITCODE_SPEC_V37_DELTA.md`
@@ -33,7 +33,7 @@ V37 adds Website Conversations product contracts over inherited V36 canon:
3333
- `ConversationMessage`: user, assistant, system, tool, and handoff message records with source-safe disclosure classification, redaction posture, retry state, and telemetry event ids.
3434
- `ConversationStreamEvent`: readable streaming rows for model deltas, tool calls, retrieval summaries, proof roots, retry states, completion decisions, and error rows.
3535
- `ConversationWritingWorkspace`: fullscreen writing mode for drafting Read Requests, Need feedback, AssetPack review notes, and Terminal handoff summaries without source leakage.
36-
- `ConversationSourceSelector`: repository, branch, commit, deposit, BTD range, AssetPack preview, and document source selectors governed by policy, rights, and disclosure posture.
36+
- `ConversationSourceSelector`: repository, branch, commit, deposit, BTD range, AssetPack preview, document, and prior conversation source selectors governed by policy, rights, and disclosure posture.
3737
- `ConversationTerminalHandoff`: source-safe handoff from conversation context into `/terminal` transactions for Depositing, Reading, Finding Fits, Exchange, settlement, and delivery workflows.
3838

3939
V37 does not replace the V28 ChatGPT App, V33 interface contracts, V35 telemetry/docs, or V36 Exchange law.
@@ -132,6 +132,32 @@ package tests, UI tests, docs, workflow wiring, source safety, mode/action
132132
coverage, route-local draft keys, keyboard behavior, responsive fullscreen
133133
layout, recovery states, proof roots, and source-safe handoff summaries.
134134

135+
## V37 Gate 5 ConversationSourceSelector context-policy canon
136+
137+
Gate 5 implements `ConversationSourceSelector` as the package-owned source
138+
selection and context-policy contract for Website Conversations. It owns
139+
repository, branch, commit, deposit, BTD range, AssetPack preview, document,
140+
and prior conversation selectors. It emits
141+
`.bitcode/v37-conversation-source-selector.json` with
142+
`source-safe-conversation-source-selector-metadata`, deterministic row roots,
143+
deterministic detail roots, selector kind ids, governance ids, preview states,
144+
required field ids, proof roots, event ids, source evidence roots, and
145+
source-safe disclosure limits.
146+
147+
Conversation source selection is route-local context metadata. It can select
148+
source-safe references, preview allowed/denied/retry posture, and explain the
149+
account, organization, wallet, rights, settlement, disclosure, and policy
150+
dimensions that govern the selector. It does not reveal protected repository
151+
source, unpaid AssetPack source, private BTD material, provider tokens, wallet
152+
private material, settlement private payloads, raw protected prompts, raw
153+
protected model responses, or global ledger authority claims. Full AssetPack
154+
or BTD source visibility remains governed by rights transfer and settlement.
155+
156+
`check:v37-gate5` validates package source, generated artifact freshness,
157+
package tests, UI tests, docs, workflow wiring, selector kind coverage,
158+
governance coverage, allowed/denied/retry preview states, rights and
159+
settlement posture, proof roots, event ids, and source-safe preview metadata.
160+
135161
## Inherited V36 Exchange canon
136162

137163
The promoted V36 sections below remain inherited canonical law for Exchange.
@@ -809,13 +835,15 @@ V36 inherits operator quality, visual/accessibility/performance posture, project
809835
| `.bitcode/v37-conversation-session-route-history.json` | Gate 2 | source-safe | ConversationSession route-local history contracts |
810836
| `.bitcode/v37-conversation-stream-event-contract.json` | Gate 3 | source-safe | ConversationStreamEvent stream UI/event contracts |
811837
| `.bitcode/v37-conversation-writing-workspace.json` | Gate 4 | source-safe | ConversationWritingWorkspace fullscreen composer contracts |
838+
| `.bitcode/v37-conversation-source-selector.json` | Gate 5 | source-safe | ConversationSourceSelector source/context policy contracts |
812839

813840
### V37 specifying generated artifacts
814841

815842
Gate 1 requires `.bitcode/v37-spec-family-report.json`, `.bitcode/v37-canonical-input-report.json`, and `.bitcode/v37-canon-posture-drift-report.json` readiness.
816843
Gate 2 adds `.bitcode/v37-conversation-session-route-history.json` from the package-owned ConversationSession route-history builder with package tests, route tests, workflow checks, and source-safety checks.
817844
Gate 3 adds `.bitcode/v37-conversation-stream-event-contract.json` from the package-owned ConversationStreamEvent builder with package tests, route/UI tests, workflow checks, and source-safety checks.
818845
Gate 4 adds `.bitcode/v37-conversation-writing-workspace.json` from the package-owned ConversationWritingWorkspace builder with package tests, fullscreen workspace UI tests, workflow checks, and source-safety checks.
846+
Gate 5 adds `.bitcode/v37-conversation-source-selector.json` from the package-owned ConversationSourceSelector builder with package tests, source selector UI tests, workflow checks, and source-safety checks.
819847
Later V37 gates add Conversations generated artifacts only when their package-owned builders, route checks, stream tests, telemetry checks, and source-safety tests exist.
820848

821849
### Shared generated-artifact fields

BITCODE_SPEC_V37_DELTA.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ Closure acceptance:
128128
- selector previews are source-safe and explain denial/retry states;
129129
- `pnpm run check:v37-gate5` validates selector contracts, rights checks, route tests, UI tests, docs, telemetry, and workflow wiring.
130130

131+
Gate 5 closure adds package-backed `ConversationSourceSelector` source,
132+
`.bitcode/v37-conversation-source-selector.json`,
133+
`source-safe-conversation-source-selector-metadata`, repository, branch,
134+
commit, deposit, BTD range, AssetPack preview, document, and prior
135+
conversation selector kinds, account, organization, wallet, rights,
136+
settlement, disclosure, and policy governance dimensions, allowed, denied, and
137+
retry-required preview states, source-safe selector UI binding, package tests,
138+
UI tests, workflow wiring, and `check:v37-gate5`.
139+
131140
### Gate 6: Conversation To Terminal Transaction Handoff
132141

133142
Gate 6 connects conversation intent to Terminal execution.

BITCODE_SPEC_V37_NOTES.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ messages are redacted source-safe metadata only and must not expose protected
8686
source, provider tokens, private wallet material, unpaid AssetPack source,
8787
settlement private payloads, or global ledger authority claims.
8888

89+
## Gate 5 implementation notes
90+
91+
ConversationSourceSelector contracts are source-safe context-policy
92+
contracts, not source disclosure or rights transfer. Gate 5 adds
93+
`.bitcode/v37-conversation-source-selector.json`,
94+
`buildConversationSourceSelector`, the route-facing source selector helper,
95+
the source selector component, package tests, UI tests, and
96+
`check:v37-gate5`.
97+
The required selector kinds are repository, branch, commit, deposit, BTD
98+
range, AssetPack preview, document, and prior conversation. The required
99+
governance dimensions are account, organization, wallet, rights, settlement,
100+
disclosure, and policy. The preview states are allowed, denied, and
101+
retry-required, and every preview is source-safe metadata only. Full protected
102+
source, unpaid AssetPack source, private BTD material, wallet private material,
103+
provider tokens, protected prompts/responses, settlement private payloads, and
104+
global ledger authority claims remain outside Conversations.
105+
89106
## V37 gate plan
90107

91108
- Gate 1: V37 Conversations Roadmap And Spec Opening

BITCODE_SPEC_V37_PARITY_MATRIX.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ No `_legacy/` source is active source truth.
8686
| Conversation session and route history | Gate 2 | `ConversationSession`, `.bitcode/v37-conversation-session-route-history.json`, package source, route contracts, tests, and `check:v37-gate2` | closed | Route-local identity, route-local history, restore, branch, retry, redaction, stream, and proof roots are typed and source-safe. |
8787
| Conversation stream events | Gate 3 | `ConversationStreamEvent`, `.bitcode/v37-conversation-stream-event-contract.json`, route-attached SSE metadata, stream UI tests, telemetry hooks, and `check:v37-gate3` | closed | Model deltas, tool calls, retrieval summaries, completion decisions, retry/error states, proof roots, collapsed readable status, expanded metadata, and disclosure posture are source-safe. |
8888
| Writing workspace | Gate 4 | `ConversationWritingWorkspace`, `.bitcode/v37-conversation-writing-workspace.json`, fullscreen workspace UI tests, accessibility proof, and `check:v37-gate4` | closed | Read Request, Need feedback, AssetPack review notes, and Terminal handoff writing flows are accessible, restorable, and source-safe. |
89-
| Source selectors | Gate 5 | future `ConversationSourceSelector`, policy tests, rights checks, and `check:v37-gate5` | pending | Repository, branch, commit, deposit, BTD range, AssetPack preview, document, and prior conversation selectors are policy-gated. |
89+
| Source selectors | Gate 5 | `ConversationSourceSelector`, `.bitcode/v37-conversation-source-selector.json`, policy tests, rights checks, source selector UI tests, and `check:v37-gate5` | closed | Repository, branch, commit, deposit, BTD range, AssetPack preview, document, and prior conversation selectors are policy-gated. |
9090
| Terminal handoff | Gate 6 | future `ConversationTerminalHandoff`, Terminal integration tests, and `check:v37-gate6` | pending | Conversations can hand source-safe transaction intent to Terminal without becoming a parallel ledger/wallet authority. |
9191
| Persistence privacy redaction | Gate 7 | future storage contracts, privacy tests, redaction tests, and `check:v37-gate7` | pending | Retention, export, delete, replay, incident repair, protected prompt/model response redaction, and disclosure classes are enforced. |
9292
| Telemetry proof hooks docs | Gate 8 | future telemetry taxonomy, docs, dashboards, runbooks, generated proof hooks, and `check:v37-gate8` | pending | Conversation sessions, messages, streams, tools, selectors, handoffs, retries, errors, and completions are observable and source-safe. |
@@ -110,6 +110,8 @@ No `_legacy/` source is active source truth.
110110
| ConversationStreamEvent event coverage | `source-safe-conversation-stream-event-metadata` covers model deltas, tool calls, retrieval summaries, proof roots, retry states, completion decisions, and error rows | closed |
111111
| ConversationWritingWorkspace artifact | `ConversationWritingWorkspace` source emits `.bitcode/v37-conversation-writing-workspace.json` and `check:v37-gate4` validates it | closed |
112112
| ConversationWritingWorkspace coverage | `source-safe-conversation-writing-workspace-metadata` covers Read Request, Need feedback, AssetPack review note, Terminal handoff summary, save, restore, summarize, handoff, keyboard behavior, responsive layout, recovery state, proof roots, and event ids | closed |
113+
| ConversationSourceSelector artifact | `ConversationSourceSelector` source emits `.bitcode/v37-conversation-source-selector.json` and `check:v37-gate5` validates it | closed |
114+
| ConversationSourceSelector coverage | `source-safe-conversation-source-selector-metadata` covers repository, branch, commit, deposit, BTD range, AssetPack preview, document, prior conversation, account, organization, wallet, rights, settlement, disclosure, policy, allowed, denied, retry-required, proof roots, and event ids | closed |
113115
| Disclosure boundary | Conversations expose source-safe stream, selector, proof, handoff, and policy metadata, not protected source, secrets, wallet private material, or unpaid AssetPack contents | drafted |
114116
| Terminal handoff boundary | Terminal remains the transaction cockpit and ledger/wallet authority; Conversations prepare and hand off source-safe intent | drafted |
115117
| Privacy posture | Conversation persistence, export, delete, retention, replay, and repair paths preserve disclosure classes and redaction policy | drafted |
@@ -149,6 +151,19 @@ No `_legacy/` source is active source truth.
149151
| Emitted summaries are source-safe | `uapi/app/conversations/conversation-writing-workspace.ts` redacts source blocks, token-shaped values, secret fields, private keys, and JWT-shaped values before preview or handoff | closed |
150152
| Workspace UI is accessible and wired | `uapi/app/conversations/components/ConversationWritingWorkspace.tsx`, `uapi/app/conversations/components/ConversationsOverlay.tsx`, `uapi/tests/conversationWritingWorkspace.test.tsx`, `scripts/check-v37-gate4-conversation-writing-workspace.mjs`, `.github/workflows/bitcode-gate-quality.yml` | closed |
151153

154+
## V37 Gate 5 Parity
155+
156+
| Requirement | Source evidence | Current V37 judgment |
157+
| --- | --- | --- |
158+
| `ConversationSourceSelector` context policy is package-owned | `packages/protocol/src/canonical/conversation-source-selector.js`, `packages/protocol/src/index.js`, `packages/protocol/src/index.d.ts` | closed |
159+
| Generated source selector artifact exists | `.bitcode/v37-conversation-source-selector.json`, `scripts/generate-v37-conversation-source-selector.mjs`, `pnpm run check:v37-conversation-source-selector` | closed |
160+
| Required selector kinds are covered | repository, branch, commit, deposit, BTD range, AssetPack preview, document, and prior conversation | closed |
161+
| Governance dimensions are covered | account, organization, wallet, rights, settlement, disclosure, and policy posture | closed |
162+
| Preview states are explainable | allowed, denied, and retry-required previews include source-safe reason/retry metadata | closed |
163+
| Source selector UI is wired | `uapi/app/conversations/conversation-source-selector.ts`, `uapi/app/conversations/components/ConversationSourceSelector.tsx`, `uapi/app/conversations/components/ConversationsOverlay.tsx`, and `uapi/tests/conversationSourceSelector.test.tsx` | closed |
164+
| Selector previews are source-safe | protected source, unpaid AssetPack source, private BTD material, provider tokens, wallet private material, settlement private payloads, protected prompts/responses, and global ledger authority claims are forbidden | closed |
165+
| Workflow, package, and UI tests are wired | `packages/protocol/test/conversation-source-selector.test.js`, `scripts/check-v37-gate5-conversation-source-selector.mjs`, `.github/workflows/bitcode-gate-quality.yml`, and `.github/workflows/bitcode-canon-quality.yml` | closed |
166+
152167
## Inherited V36 implementation matrix
153168

154169
| Area | Gate | Source evidence | Judgment | Closure requirement |

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,14 @@ Gate 10 is the promotion-readiness gate. V37 Gate 1 is wired through
207207
`pnpm run check:v37-conversation-session-route-history`; V37 Gate 3 is wired
208208
through `pnpm run check:v37-gate3`; and V37 Gate 4 is wired through
209209
`pnpm run check:v37-gate4` and
210-
`pnpm run check:v37-conversation-writing-workspace`. Later V37 gates add
211-
Conversations generated artifacts before `check:v37-gate10` and the V37
212-
promotion workflow exist.
210+
`pnpm run check:v37-conversation-writing-workspace`. V37 Gate 5 is wired
211+
through `pnpm run check:v37-gate5` and
212+
`pnpm run check:v37-conversation-source-selector`, covering source-safe
213+
repository, branch, commit, deposit, BTD range, AssetPack preview, document,
214+
and prior conversation selectors with account, organization, wallet, rights,
215+
settlement, disclosure, and policy posture. Later V37 gates add Conversations
216+
generated artifacts before `check:v37-gate10` and the V37 promotion workflow
217+
exist.
213218
The promoted V35 closure remains reproducible through `pnpm run check:v35-gate10`
214219
and [v35-canon-promotion.yml](.github/workflows/v35-canon-promotion.yml).
215220
The application CI workflow uses the root pnpm workspace install, runs uapi

0 commit comments

Comments
 (0)