|
11 | 11 | // this repository, as lessons of the read-only `workspace-rules` store (a name reserved for it; the person's own |
12 | 12 | // stores, `team` included, are separate). Delivery, recurrence and `learn show` read it like any other store, so team |
13 | 13 | // rules reach the prompt ("Team rules"), their exposure is recorded, and "corrected again" falls out of recurrence. |
14 | | -// Only a pull writes it; reflection and promotion never target this store. Delivery gives a rule from it only while |
15 | | -// the state holds the same rule (`vouched`): a copy in the project is never trusted on its own. |
| 14 | +// Only a pull writes it; reflection and promotion never target this store. Delivery gives team rules from the state |
| 15 | +// (`vouched`), never from this copy: a copy in the project is never trusted on its own. |
16 | 16 | // |
17 | 17 | // Writes take the learn lock (delivery reads the same directory) and are atomic. |
18 | 18 | import { constants } from "node:fs" |
@@ -224,19 +224,18 @@ async function writePrivate(file: string, data: string): Promise<void> { |
224 | 224 | } |
225 | 225 | } |
226 | 226 |
|
227 | | -/** The team rules delivery may give from the project's `workspace-rules` copy: lesson id → text, as the state holds |
228 | | - * them. None while the project is not linked (unlinked and lost access clear the state's workspace), and none unless |
229 | | - * the credential signed in now is the one they were pulled with: a sign-out or another account stops them at once, |
230 | | - * not at the next sync. No network. */ |
231 | | -export async function vouched(root: string): Promise<Map<string, string>> { |
| 227 | +/** The team rules delivery may give, by lesson id, built from the state: nothing of the project's `workspace-rules` |
| 228 | + * copy (wording, pin, tags, paths) is used. None while the project is not linked (unlinked and lost access clear the |
| 229 | + * state's workspace), and none unless the credential signed in now is the one they were pulled with: a sign-out or |
| 230 | + * another account stops them at once, not at the next sync. No network. */ |
| 231 | +export async function vouched(root: string): Promise<Map<string, Lesson>> { |
232 | 232 | const state = await read(root) |
233 | 233 | if (!state.workspace || !state.pulled_with) return new Map() |
234 | 234 | const { accountDigest } = await import("../workspace/state") |
235 | 235 | if ((await accountDigest().catch(() => null)) !== state.pulled_with) return new Map() |
236 | | - return new Map(state.rules.map((rule) => [lessonId(rule.rule_key), rule.text])) |
| 236 | + return new Map(state.rules.map((rule) => [lessonId(rule.rule_key), toLesson(rule)])) |
237 | 237 | } |
238 | 238 |
|
239 | | - |
240 | 239 | function parse(raw: string | undefined): State | undefined { |
241 | 240 | if (!raw) return structuredClone(EMPTY) |
242 | 241 | try { |
@@ -273,9 +272,8 @@ export function toLesson(rule: RuleOut): Lesson { |
273 | 272 |
|
274 | 273 | const IGNORE = "*\n" |
275 | 274 |
|
276 | | -/** Under the learn lock. The parent learn ignore already keeps `rules.json` out of Git but shares each store's |
277 | | - * `approved.json`, so the mirror needs this one too (whatever an older file said). Written with the mirror only, |
278 | | - * so a project without a workspace never gets it. */ |
| 275 | +/** Under the learn lock. The parent learn ignore shares each store's `approved.json`, so the mirror needs this one |
| 276 | + * (whatever an older file said). Written with the mirror only, so a project without a workspace never gets it. */ |
279 | 277 | async function ensureIgnore(root: string) { |
280 | 278 | const ignore = path.join(dir(root), ".gitignore") |
281 | 279 | const current = await SafeFS.open(root, ignore, constants.O_RDONLY) |
|
0 commit comments