@mossbear/protocol 0.1.0-alpha.48 → 0.1.0-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundleSlug.d.ts +24 -0
- package/dist/bundleSlug.d.ts.map +1 -1
- package/dist/bundleSlug.js +33 -0
- package/dist/bundleSlug.js.map +1 -1
- package/dist/bundleSlug.test.js +32 -1
- package/dist/bundleSlug.test.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +206 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +180 -1
- package/dist/schemas.js.map +1 -1
- package/dist/whatSyncs.d.ts +74 -0
- package/dist/whatSyncs.d.ts.map +1 -0
- package/dist/whatSyncs.js +216 -0
- package/dist/whatSyncs.js.map +1 -0
- package/dist/whatSyncs.test.d.ts +2 -0
- package/dist/whatSyncs.test.d.ts.map +1 -0
- package/dist/whatSyncs.test.js +104 -0
- package/dist/whatSyncs.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The what-syncs disclosure: everything that leaves a user's machine, everything
|
|
3
|
+
* that does not, and the rules for the one content class in between.
|
|
4
|
+
*
|
|
5
|
+
* One source, two surfaces. The dashboard's privacy panel renders this through
|
|
6
|
+
* its localisation layer, and `mossbear what-syncs` prints it at the terminal —
|
|
7
|
+
* a terminal-only user never opens the dashboard, so a disclosure that lived
|
|
8
|
+
* only there was invisible to exactly the reader most likely to ask. Both read
|
|
9
|
+
* the tables below rather than carrying their own copy, so they cannot disagree
|
|
10
|
+
* about what is sent.
|
|
11
|
+
*
|
|
12
|
+
* The lists are a manifest cross-checked against the actual CLI→server wire
|
|
13
|
+
* schema (`DashboardSyncRequestSchema`) so they cannot silently drift from
|
|
14
|
+
* reality:
|
|
15
|
+
* - {@link SyncedPayloadKey} is derived from the exported `DashboardSyncRequest`
|
|
16
|
+
* type, so a new top-level sync array becomes a compile error until the
|
|
17
|
+
* manifest (a `Record` keyed by every wire key) documents it.
|
|
18
|
+
* - {@link missingSyncDisclosureKeys} is a runtime belt-and-suspenders guard
|
|
19
|
+
* asserted by the unit test.
|
|
20
|
+
*
|
|
21
|
+
* Field lists are exhaustive per the `Dashboard*Schema` definitions in
|
|
22
|
+
* `schemas.ts` — under-disclosing on a trust surface would be worse than showing
|
|
23
|
+
* an internal identifier.
|
|
24
|
+
*
|
|
25
|
+
* Plain data on purpose: no React, no localisation, no terminal. Each surface
|
|
26
|
+
* owns its own rendering of these strings.
|
|
27
|
+
*/
|
|
28
|
+
import { DashboardSyncRequestSchema } from './schemas.js';
|
|
29
|
+
/** The wire keys actually present on the schema at runtime. */
|
|
30
|
+
export const SYNCED_PAYLOAD_KEYS = Object.keys(DashboardSyncRequestSchema.entries).sort();
|
|
31
|
+
/**
|
|
32
|
+
* Every field that leaves the machine, per sync-payload category, with the
|
|
33
|
+
* sentence a reader sees for it. Keyed as a `Record<SyncedPayloadKey, ...>` so
|
|
34
|
+
* adding a wire key to the protocol fails to compile until it's documented
|
|
35
|
+
* here. Nested fields (e.g. token usage) are shown with dotted paths to stay
|
|
36
|
+
* honest about structure.
|
|
37
|
+
*/
|
|
38
|
+
const SYNCED = {
|
|
39
|
+
actions: {
|
|
40
|
+
label: 'Verdicts, action summaries & redacted transcript excerpts',
|
|
41
|
+
fields: [
|
|
42
|
+
'id',
|
|
43
|
+
'runId',
|
|
44
|
+
'sessionId',
|
|
45
|
+
'actionType',
|
|
46
|
+
'summary',
|
|
47
|
+
'filePaths',
|
|
48
|
+
'verdict',
|
|
49
|
+
'gradingTier',
|
|
50
|
+
'guideIds',
|
|
51
|
+
'violatedGuideId',
|
|
52
|
+
'evalReasoning',
|
|
53
|
+
'metadata',
|
|
54
|
+
// Transcript evidence: the user turn and the adjacent assistant prose,
|
|
55
|
+
// both prose-redacted on the machine before upload, with code blocks
|
|
56
|
+
// removed structurally and tool-result bodies never included (the
|
|
57
|
+
// transcript-content-classes design, founder call 2026-08-13).
|
|
58
|
+
//
|
|
59
|
+
// Listed here in the same change that put the field on the wire,
|
|
60
|
+
// because the drift guard in the unit test requires exactly that — and
|
|
61
|
+
// it is right to: a wire field that exists before its disclosure does
|
|
62
|
+
// is how a trust surface goes stale.
|
|
63
|
+
'narration',
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
guideSuggestions: {
|
|
67
|
+
label: 'Guide suggestions',
|
|
68
|
+
fields: ['id', 'content', 'reasoning', 'triggerType', 'sourceActionIds', 'status'],
|
|
69
|
+
},
|
|
70
|
+
feedbackCandidates: {
|
|
71
|
+
label: 'Feedback signals',
|
|
72
|
+
fields: ['id', 'signal', 'signalType', 'confidence', 'occurrences', 'status'],
|
|
73
|
+
},
|
|
74
|
+
runUsage: {
|
|
75
|
+
label: 'Token counts & run usage',
|
|
76
|
+
fields: [
|
|
77
|
+
'runId',
|
|
78
|
+
'sessionId',
|
|
79
|
+
'usage.model',
|
|
80
|
+
'usage.provider',
|
|
81
|
+
'usage.inputTokens',
|
|
82
|
+
'usage.outputTokens',
|
|
83
|
+
'usage.cacheReadTokens',
|
|
84
|
+
'usage.cacheWriteTokens',
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
skillUsage: {
|
|
88
|
+
label: 'Skill load-overhead token counts',
|
|
89
|
+
fields: [
|
|
90
|
+
'runId',
|
|
91
|
+
'sessionId',
|
|
92
|
+
'usage.skillName',
|
|
93
|
+
'usage.model',
|
|
94
|
+
'usage.inputTokens',
|
|
95
|
+
'usage.cacheWriteTokens',
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
// A scalar rather than a list of records: the version of the CLI making the
|
|
99
|
+
// request. Disclosed as its own category because it is the one thing that
|
|
100
|
+
// leaves the machine on every sync regardless of what else is in the batch.
|
|
101
|
+
cliVersion: {
|
|
102
|
+
label: 'The CLI version making the sync request',
|
|
103
|
+
fields: ['cliVersion'],
|
|
104
|
+
},
|
|
105
|
+
// Agent session identifiers the `SessionEnd` hook reports as finished, so the
|
|
106
|
+
// server can close those runs and grade them. Ids only — the same session ids
|
|
107
|
+
// already disclosed under `actions` and `runUsage`, carrying no content of
|
|
108
|
+
// their own. Listed anyway: this surface's contract is that everything on the
|
|
109
|
+
// wire appears here, and a category that "carries nothing interesting" is
|
|
110
|
+
// exactly the kind of judgement call that erodes it.
|
|
111
|
+
completedSessionIds: {
|
|
112
|
+
label: 'Which agent sessions have finished',
|
|
113
|
+
fields: ['sessionId'],
|
|
114
|
+
},
|
|
115
|
+
// Which rule files the synced repo has on disk, so grading only counts
|
|
116
|
+
// guidance the agent was actually given. Paths and hashes — never contents:
|
|
117
|
+
// the files themselves are uploaded only by `mossbear link`, and this adds
|
|
118
|
+
// no new content class. `repoId` is a one-way digest that lets the dashboard
|
|
119
|
+
// tell two of your checkouts apart without learning either path.
|
|
120
|
+
ruleManifest: {
|
|
121
|
+
label: 'Which rule files this repo has on disk (paths and hashes, never contents)',
|
|
122
|
+
fields: ['repoId', 'files.path', 'files.format', 'files.contentHash', 'truncated'],
|
|
123
|
+
},
|
|
124
|
+
// Where the checkout stood when a run closed, so a commit can be traced back
|
|
125
|
+
// to the session that produced it. A sha and a ref name — no file contents,
|
|
126
|
+
// no diff, no commit message, and nothing about any commit other than the
|
|
127
|
+
// head. Sent only on the sync that closes a run, and absent entirely for a
|
|
128
|
+
// session that ran outside a git repo.
|
|
129
|
+
commitAnchor: {
|
|
130
|
+
label: 'The commit and branch your session ended on (never the code itself)',
|
|
131
|
+
fields: ['headSha', 'branch'],
|
|
132
|
+
},
|
|
133
|
+
// What the agent said it did, in its own closing message — the prose of the
|
|
134
|
+
// session's final assistant turn, so a later grade can check the claim
|
|
135
|
+
// against the actions actually recorded. The same content class as
|
|
136
|
+
// `actions.narration` and the same promise: code blocks removed structurally,
|
|
137
|
+
// the remainder prose-redacted on this machine, and truncated — never a
|
|
138
|
+
// tool result, a diff or a file body.
|
|
139
|
+
//
|
|
140
|
+
// Sent only on the sync that closes a run, and absent entirely when the
|
|
141
|
+
// repo has narration switched off, when there is no transcript to read, or
|
|
142
|
+
// when the session ended without the agent speaking.
|
|
143
|
+
//
|
|
144
|
+
// Listed bare, like every other category. These paths read relative to the
|
|
145
|
+
// category, and a dot means nesting *inside* it — `files.path` under
|
|
146
|
+
// `ruleManifest`, `usage.model` under `runUsage`. `RunSelfReportSchema` is
|
|
147
|
+
// `{ sessionId, text }`, so that is what is listed.
|
|
148
|
+
selfReport: {
|
|
149
|
+
label: "Your agent's closing summary of what it did, redacted the same way as the excerpts above",
|
|
150
|
+
fields: ['sessionId', 'text'],
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
/** What leaves the machine, in display order. */
|
|
154
|
+
export const SYNCED_CATEGORIES = Object.keys(SYNCED).map((key) => ({ key, ...SYNCED[key] }));
|
|
155
|
+
/** What stays on the device, in display order. */
|
|
156
|
+
export const LOCAL_ONLY_ITEMS = [
|
|
157
|
+
{
|
|
158
|
+
key: 'transcripts',
|
|
159
|
+
label: 'Raw conversation transcripts (read on your machine; only the redacted excerpts described above are sent)',
|
|
160
|
+
},
|
|
161
|
+
{ key: 'fileContents', label: 'File contents' },
|
|
162
|
+
{ key: 'diffs', label: 'Code diffs' },
|
|
163
|
+
{ key: 'shellCommands', label: 'Shell commands you run' },
|
|
164
|
+
{ key: 'verdictQueue', label: 'The local verdict queue' },
|
|
165
|
+
];
|
|
166
|
+
export const LOCAL_ONLY_KEYS = LOCAL_ONLY_ITEMS.map((item) => item.key);
|
|
167
|
+
/**
|
|
168
|
+
* The three rules for what is taken from a transcript, in full. These are the
|
|
169
|
+
* whole of the promise: a fourth content class would need a fourth rule here
|
|
170
|
+
* before it could ship.
|
|
171
|
+
*/
|
|
172
|
+
export const TRANSCRIPT_RULES = [
|
|
173
|
+
{
|
|
174
|
+
title: 'What you asked for, and what the agent said it would do',
|
|
175
|
+
body: "Your message, and the sentence or two of the agent's reply next to each action. Both are scanned on your machine for keys, tokens, passwords, credentials in URLs and email addresses, which are replaced before anything is sent.",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
title: 'Code blocks are removed, not scanned',
|
|
179
|
+
body: 'Any code block in a message is taken out whole, by its structure, before the scan above even runs — replaced by a note of its language and how many lines it was. Nothing looks at the code and decides it is safe.',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
title: 'Command output and file contents are never sent',
|
|
183
|
+
body: 'What a command printed, what a file contained, what a search returned — none of it travels, at any size. Only whether the step succeeded.',
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
/**
|
|
187
|
+
* The framing sentences around the three lists, so the two surfaces introduce
|
|
188
|
+
* them in the same words. Product-name sentences carry the name spelled out;
|
|
189
|
+
* the dashboard substitutes its own constant when it renders them.
|
|
190
|
+
*/
|
|
191
|
+
export const WHAT_SYNCS_COPY = {
|
|
192
|
+
intro: 'Mossbear grades your sessions in the cloud, from evidence prepared on your machine. Your code does not leave your device. Some of what you and the agent said does — redacted first, and only the parts described below.',
|
|
193
|
+
synced: {
|
|
194
|
+
title: 'Leaves your machine',
|
|
195
|
+
lead: 'Synced to your account so the dashboard can show your alignment.',
|
|
196
|
+
},
|
|
197
|
+
transcript: {
|
|
198
|
+
title: 'What we take from your transcript',
|
|
199
|
+
lead: 'A grader that cannot see why you asked for something cannot tell a good session from a bad one. So a little of the conversation travels with each action — and the rules are these, in full:',
|
|
200
|
+
caveats: 'Two honest caveats. Redaction is a pattern match, so it is a safety net and not a guarantee — which is why whole code blocks are removed rather than trusted to it. And what does arrive is readable by our servers, because grading it requires reading it; it is encrypted in storage and in transit, not end-to-end. You can switch this off for a repository by running mossbear narration off in it, and the rest of Mossbear works exactly as before.',
|
|
201
|
+
},
|
|
202
|
+
localOnly: {
|
|
203
|
+
title: 'Stays on your device',
|
|
204
|
+
lead: 'Never uploaded, never stored on our servers.',
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Wire-schema keys that leave the machine but aren't described in
|
|
209
|
+
* {@link SYNCED_CATEGORIES}. Non-empty means the disclosure has drifted from the
|
|
210
|
+
* protocol and must be updated. Pure — safe to assert on in tests.
|
|
211
|
+
*/
|
|
212
|
+
export function missingSyncDisclosureKeys() {
|
|
213
|
+
const documented = new Set(SYNCED_CATEGORIES.map((c) => c.key));
|
|
214
|
+
return SYNCED_PAYLOAD_KEYS.filter((key) => !documented.has(key));
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=whatSyncs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatSyncs.js","sourceRoot":"","sources":["../src/whatSyncs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AAOzD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAC5C,0BAA0B,CAAC,OAAO,CACnC,CAAC,IAAI,EAAwB,CAAA;AAW9B;;;;;;GAMG;AACH,MAAM,MAAM,GAA0D;IACpE,OAAO,EAAE;QACP,KAAK,EAAE,2DAA2D;QAClE,MAAM,EAAE;YACN,IAAI;YACJ,OAAO;YACP,WAAW;YACX,YAAY;YACZ,SAAS;YACT,WAAW;YACX,SAAS;YACT,aAAa;YACb,UAAU;YACV,iBAAiB;YACjB,eAAe;YACf,UAAU;YACV,uEAAuE;YACvE,qEAAqE;YACrE,kEAAkE;YAClE,+DAA+D;YAC/D,EAAE;YACF,iEAAiE;YACjE,uEAAuE;YACvE,sEAAsE;YACtE,qCAAqC;YACrC,WAAW;SACZ;KACF;IACD,gBAAgB,EAAE;QAChB,KAAK,EAAE,mBAAmB;QAC1B,MAAM,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,CAAC;KACnF;IAC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ACF,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EACH,0NAA0N;IAC5N,MAAM,EAAE;QACN,KAAK,EAAE,qBAAqB;QAC5B,IAAI,EAAE,kEAAkE;KACzE;IACD,UAAU,EAAE;QACV,KAAK,EAAE,mCAAmC;QAC1C,IAAI,EAAE,8LAA8L;QACpM,OAAO,EACL,6bAA6b;KAChc;IACD,SAAS,EAAE;QACT,KAAK,EAAE,sBAAsB;QAC7B,IAAI,EAAE,8CAA8C;KACrD;CACO,CAAA;AAEV;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatSyncs.test.d.ts","sourceRoot":"","sources":["../src/whatSyncs.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { CommitAnchorSchema, DashboardFeedbackCandidateSchema, DashboardGuideSuggestionSchema, DashboardRunUsageSchema, DashboardSkillUsageSchema, DashboardSyncActionSchema, DashboardSyncRequestSchema, RuleFileManifestSchema, RuleManifestFileSchema, RunSelfReportSchema, SkillUsageEntrySchema, TokenUsageSchema, } from './schemas.js';
|
|
3
|
+
import { LOCAL_ONLY_ITEMS, LOCAL_ONLY_KEYS, missingSyncDisclosureKeys, SYNCED_CATEGORIES, SYNCED_PAYLOAD_KEYS, TRANSCRIPT_RULES, } from './whatSyncs.js';
|
|
4
|
+
const fieldsFor = (key) => SYNCED_CATEGORIES.find((c) => c.key === key)?.fields ?? [];
|
|
5
|
+
/** Top-level names covered by a category, collapsing dotted nested paths. */
|
|
6
|
+
const topLevelFields = (key) => new Set(fieldsFor(key).map((f) => f.split('.')[0] ?? f));
|
|
7
|
+
describe('whatSyncs disclosure', () => {
|
|
8
|
+
it('derives the synced payload keys from the wire schema', () => {
|
|
9
|
+
expect([...SYNCED_PAYLOAD_KEYS].sort()).toEqual(Object.keys(DashboardSyncRequestSchema.entries).sort());
|
|
10
|
+
});
|
|
11
|
+
it('documents every category that leaves the machine (drift guard)', () => {
|
|
12
|
+
// If the protocol grows a new top-level sync array, this fails until the
|
|
13
|
+
// disclosure is updated — preventing silent divergence from reality.
|
|
14
|
+
expect(missingSyncDisclosureKeys()).toEqual([]);
|
|
15
|
+
});
|
|
16
|
+
it('only claims to sync keys that exist on the wire schema', () => {
|
|
17
|
+
const wireKeys = new Set(Object.keys(DashboardSyncRequestSchema.entries));
|
|
18
|
+
for (const category of SYNCED_CATEGORIES) {
|
|
19
|
+
expect(wireKeys.has(category.key)).toBe(true);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// Exhaustiveness: a trust surface must not under-disclose. Each category's
|
|
23
|
+
// field list must cover every field on its wire schema (nested token fields
|
|
24
|
+
// collapse to their top-level `usage` parent).
|
|
25
|
+
it('lists every actions field on the wire schema', () => {
|
|
26
|
+
expect(topLevelFields('actions')).toEqual(new Set(Object.keys(DashboardSyncActionSchema.entries)));
|
|
27
|
+
});
|
|
28
|
+
it('lists every guideSuggestions field on the wire schema', () => {
|
|
29
|
+
expect(topLevelFields('guideSuggestions')).toEqual(new Set(Object.keys(DashboardGuideSuggestionSchema.entries)));
|
|
30
|
+
});
|
|
31
|
+
it('lists every feedbackCandidates field on the wire schema', () => {
|
|
32
|
+
expect(topLevelFields('feedbackCandidates')).toEqual(new Set(Object.keys(DashboardFeedbackCandidateSchema.entries)));
|
|
33
|
+
});
|
|
34
|
+
it('lists every runUsage field, including nested token usage', () => {
|
|
35
|
+
expect(topLevelFields('runUsage')).toEqual(new Set(Object.keys(DashboardRunUsageSchema.entries)));
|
|
36
|
+
// Every TokenUsage sub-field is disclosed as `usage.<field>`.
|
|
37
|
+
const usageFields = fieldsFor('runUsage')
|
|
38
|
+
.filter((f) => f.startsWith('usage.'))
|
|
39
|
+
.map((f) => f.slice('usage.'.length));
|
|
40
|
+
expect(new Set(usageFields)).toEqual(new Set(Object.keys(TokenUsageSchema.entries)));
|
|
41
|
+
});
|
|
42
|
+
// The four object-valued categories that had no exhaustiveness test until
|
|
43
|
+
// 2026-08-22. Their absence is what let `selfReport` ship claiming
|
|
44
|
+
// `selfReport.sessionId` — a field path that named a nesting level which
|
|
45
|
+
// does not exist — because `topLevelFields` collapses a dotted path to its
|
|
46
|
+
// first segment, so the disclosure read `{selfReport}` where the wire says
|
|
47
|
+
// `{sessionId, text}`. Nothing compared the two.
|
|
48
|
+
it.each([
|
|
49
|
+
['skillUsage', DashboardSkillUsageSchema],
|
|
50
|
+
['ruleManifest', RuleFileManifestSchema],
|
|
51
|
+
['commitAnchor', CommitAnchorSchema],
|
|
52
|
+
['selfReport', RunSelfReportSchema],
|
|
53
|
+
])('lists every %s field on the wire schema', (key, schema) => {
|
|
54
|
+
expect(topLevelFields(key)).toEqual(new Set(Object.keys(schema.entries)));
|
|
55
|
+
});
|
|
56
|
+
// …and one level down, which the assertion above cannot see. It compares
|
|
57
|
+
// collapsed names, so `usage.model` and `files.path` reduce to `usage` and
|
|
58
|
+
// `files` and match whatever the outer schema says regardless of what sits
|
|
59
|
+
// inside them — the same blindness that let `selfReport` through, in the
|
|
60
|
+
// two newly covered categories that have nested entries. `runUsage` above
|
|
61
|
+
// already drills into `TokenUsageSchema`; these two were left flat.
|
|
62
|
+
it.each([
|
|
63
|
+
['skillUsage', 'usage', SkillUsageEntrySchema],
|
|
64
|
+
['ruleManifest', 'files', RuleManifestFileSchema],
|
|
65
|
+
])('lists every %s.%s sub-field on the wire schema', (key, prefix, schema) => {
|
|
66
|
+
const nested = fieldsFor(key)
|
|
67
|
+
.filter((f) => f.startsWith(`${prefix}.`))
|
|
68
|
+
.map((f) => f.slice(prefix.length + 1));
|
|
69
|
+
expect(new Set(nested)).toEqual(new Set(Object.keys(schema.entries)));
|
|
70
|
+
});
|
|
71
|
+
it('never lists raw content fields as synced', () => {
|
|
72
|
+
// Guard against accidentally disclosing (or worse, adding) a field that
|
|
73
|
+
// would carry raw transcripts / file contents / shell commands.
|
|
74
|
+
const forbidden = ['rawContent', 'content_body', 'command', 'diff', 'transcript'];
|
|
75
|
+
const synced = SYNCED_CATEGORIES.flatMap((c) => c.fields);
|
|
76
|
+
for (const field of forbidden) {
|
|
77
|
+
expect(synced).not.toContain(field);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
it('enumerates the local-only categories', () => {
|
|
81
|
+
expect(LOCAL_ONLY_KEYS).toContain('transcripts');
|
|
82
|
+
expect(LOCAL_ONLY_KEYS).toContain('fileContents');
|
|
83
|
+
expect(LOCAL_ONLY_KEYS.length).toBeGreaterThan(0);
|
|
84
|
+
expect(LOCAL_ONLY_ITEMS.map((item) => item.key)).toEqual(LOCAL_ONLY_KEYS);
|
|
85
|
+
});
|
|
86
|
+
// Two surfaces read these strings — the dashboard panel and `mossbear
|
|
87
|
+
// what-syncs` — and both would render an empty label as a blank row rather
|
|
88
|
+
// than fail. A trust surface with a blank row is one that lists something it
|
|
89
|
+
// does not name.
|
|
90
|
+
it('gives every row a sentence a reader can act on', () => {
|
|
91
|
+
for (const category of SYNCED_CATEGORIES) {
|
|
92
|
+
expect(category.label.trim(), category.key).not.toBe('');
|
|
93
|
+
expect(category.fields.length, category.key).toBeGreaterThan(0);
|
|
94
|
+
}
|
|
95
|
+
for (const item of LOCAL_ONLY_ITEMS)
|
|
96
|
+
expect(item.label.trim(), item.key).not.toBe('');
|
|
97
|
+
expect(TRANSCRIPT_RULES).toHaveLength(3);
|
|
98
|
+
for (const rule of TRANSCRIPT_RULES) {
|
|
99
|
+
expect(rule.title.trim()).not.toBe('');
|
|
100
|
+
expect(rule.body.trim()).not.toBe('');
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
//# sourceMappingURL=whatSyncs.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatSyncs.test.js","sourceRoot":"","sources":["../src/whatSyncs.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACL,kBAAkB,EAClB,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,gBAAgB,CAAA;AAEvB,MAAM,SAAS,GAAG,CAAC,GAAW,EAAY,EAAE,CAC1C,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,MAAM,IAAI,EAAE,CAAA;AAE5D,6EAA6E;AAC7E,MAAM,cAAc,GAAG,CAAC,GAAW,EAAe,EAAE,CAClD,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAE1D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAAC,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