gatelight 0.40.8 → 0.40.9

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatelight",
3
3
  "displayName": "gatelight",
4
- "version": "0.40.8",
4
+ "version": "0.40.9",
5
5
  "description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
6
6
  "author": {
7
7
  "name": "coffeecoproject"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatelight",
3
3
  "displayName": "gatelight",
4
- "version": "0.40.8",
4
+ "version": "0.40.9",
5
5
  "description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
6
6
  "author": {
7
7
  "name": "coffeecoproject"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatelight",
3
- "version": "0.40.8",
3
+ "version": "0.40.9",
4
4
  "description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
5
5
  "author": {
6
6
  "name": "coffeecoproject"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatelight",
3
- "version": "0.40.8",
3
+ "version": "0.40.9",
4
4
  "description": "Gates for coding agents: tests actually ran before code lands, code stays inside its module boundaries, standards (types, lint, format, secrets) are not quietly loosened, plus test-writing conventions and a change-triggered checklist",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/coffeecoproject/gatelight#readme",
@@ -33,6 +33,7 @@ testpace 不管测试的写法风格(分几层、怎么组织、写多细)
33
33
  | `full` | 落地到默认分支前必须通过的、测试以外的检查:类型检查、lint、构建这些。不在这里跑测试。里面有构建步骤的(比如先打包页面、编译后台),构建产物(`dist/`、`build/` 等)要在 `.gitignore` 里:`testpace full` 跑完会核对工作区有没有变,产物没被忽略就算跑的过程中代码改过,通过也不记录。不要用 `ignore` 字段处理产物 |
34
34
  | `tests` | 找测试文件的路径规则,以 `!` 开头的是排除。`testpace full` 在 `full` 通过后,把规则在工作区里找到的全部测试文件(已跟踪的和没被 .gitignore 忽略的新文件)一次交给 `files` 跑。新加的测试不用改配置就会被跑到。规则要覆盖项目里每一种测试,又只圈真正的测试文件:和测试放在同一目录下的练习脚本、工具脚本不能被圈进去(比如 `e2e/` 下既有测试又有导入练习时,写 `e2e/tests/**/*.spec.ts`,不写 `e2e/**/*.spec.ts`)。一个都找不到时整组不跑。合并门只认 `testpace full` 跑出的通过记录。把整套系统起起来跑的测试(页面测试、端到端验收)也要在规则里,不能排除掉、只留到发布后在服务器上跑;它们要的系统由 `files` 起好。页面测试测什么、放在哪一层,归写测试的约定管,这里只管它要在整组里 |
35
35
  | `ignore` | 可选。不影响测试的路径,改了它们不用重跑。`**` 跨目录,`*` 不跨目录,结尾 `/` 表示整个目录。不要写 `**/*.md` 这类通配。`testpace.json` 自己不算忽略路径:改了它(包括改 `ignore`)要在改完的代码上重跑整组 |
36
+ | `layermap` | 可选。检查用的 LayerMap 版本(`0.1.60` 以上),比如 `"0.1.60"`:focused 选测试和 modwall 都跑这一版,同一份代码今天明天查出来一样。不写时跟着本机的 LayerMap 走,它会自己升到 npm 上的最新版。改了版本合并后才生效(这次改动还按分叉点上写的那一版查)。layermap 命令的启动器太旧、不认固定的版本时,focused 退回建议跑整组,modwall check 算没查全 |
36
37
 
37
38
  三条命令都从仓库根目录运行、不需要交互、退出码 0 表示通过。不能有别的字段。
38
39
 
@@ -5,12 +5,18 @@ import { existsSync, readFileSync } from 'node:fs'
5
5
  import { join } from 'node:path'
6
6
  import { defaultBranch, fileAt, refTip } from './git.ts'
7
7
  import { modules } from './module.ts'
8
+ import { compareVersions } from './version.ts'
8
9
 
9
10
  export const CONTRACT_FILE = 'testpace.json'
10
11
 
12
+ /** LayerMap 从这一版起认 LAYERMAP_VERSION、在输出里说是哪一版跑的:固定的版本要不低于它,才核对得了。 */
13
+ const LAYERMAP_PINNABLE = '0.1.60'
14
+
11
15
  export interface Contract {
12
16
  /** 这份约定里写的、不影响结果的路径规则。文件写坏了读不出来时为空(按没有 ignore 算:要内容完全一致的通过记录)。判断时认哪些见 effectiveIgnore。 */
13
17
  ignore: string[]
18
+ /** 检查用的 LayerMap 版本("layermap");没写时跟着本机的版本走。哪一份约定里的算数见 base/layermap.ts。 */
19
+ layermap?: string
14
20
  /** 文件的内容;不是合法的 JSON 对象时没有。 */
15
21
  raw?: Record<string, unknown>
16
22
  /** 约定的问题:格式不对、未知字段、ignore 写错,和各模块对自己字段的检查。有问题时整组跑不了。 */
@@ -77,7 +83,7 @@ export function parseContract(raw: unknown): Contract {
77
83
  }
78
84
  const record = raw as Record<string, unknown>
79
85
  const problems: string[] = []
80
- const known = new Set(['ignore', ...modules().flatMap(module => module.fields ?? [])])
86
+ const known = new Set(['ignore', 'layermap', ...modules().flatMap(module => module.fields ?? [])])
81
87
  for (const key of Object.keys(record)) {
82
88
  if (!known.has(key)) problems.push(`未知字段 "${key}"`)
83
89
  }
@@ -90,5 +96,11 @@ export function parseContract(raw: unknown): Contract {
90
96
  ignore = record.ignore as string[]
91
97
  }
92
98
  }
93
- return { ignore, raw: record, problems }
99
+ let layermap: string | undefined
100
+ if (record.layermap !== undefined) {
101
+ if (typeof record.layermap !== 'string' || !/^\d+\.\d+\.\d+$/.test(record.layermap)) problems.push('"layermap" 应该是 LayerMap 的版本号,比如 "0.1.60"')
102
+ else if (compareVersions(record.layermap, LAYERMAP_PINNABLE) < 0) problems.push(`"layermap" 要 ${LAYERMAP_PINNABLE} 以上:更早的版本认不出固定的版本`)
103
+ else layermap = record.layermap
104
+ }
105
+ return { ignore, ...(layermap ? { layermap } : {}), raw: record, problems }
94
106
  }
@@ -1,6 +1,8 @@
1
1
  // 调 LayerMap:只在这里碰它的命令。找命令、跑、读 JSON、出了问题怎么说都在这一处;
2
2
  // 输出里要哪些事实由用的模块自己读(各模块要的不一样),读不到要的字段就按版本太旧说(tooOld)。
3
- // 不看版本号,按能力判断:没有要的命令、输出不是 JSON 或缺字段,就是版本太旧。版本下限只有这里的一个。
3
+ // 不看版本号,按能力判断:没有要的命令、输出不是 JSON 或缺字段,就是版本太旧。版本下限只有这里的一个(固定的版本能写多低归 contract.ts)。
4
+ // testpace.json 写了 "layermap" 的,跑那一版(LAYERMAP_VERSION),同一份代码今天明天查出来一样;旧的启动器不认这个变量,
5
+ // 所以要核对输出里说的版本,对不上就是拿不到事实。
4
6
  //
5
7
  // 出问题时的规则只有一条:命令找不到、没跑成、版本太旧,都拿不到事实,用的模块要退回更严的一边
6
8
  // (选测试退回跑整组,别的检查算没做完),不能当成"没有问题"。所以这里的结果要么是事实,要么是说明了原因的失败,没有空值。
@@ -8,6 +10,9 @@
8
10
  // 底座不自己做代码分析:要 LayerMap 新出的事实,向它提需求、等它发版。
9
11
 
10
12
  import { spawnSync } from 'node:child_process'
13
+ import { contractAt } from './contract.ts'
14
+ import { forkPoint } from './git.ts'
15
+ import { compareVersions } from './version.ts'
11
16
 
12
17
  export const LAYERMAP_MINIMUM = '0.1.58'
13
18
 
@@ -25,7 +30,38 @@ export type LayermapFailure = {
25
30
  problem: string
26
31
  }
27
32
 
28
- export type LayermapAnswer = { ok: true; value: unknown } | LayermapFailure
33
+ /** 跑这次的 LayerMap:版本和建地图的分析器。0.1.60 起的输出里才有。 */
34
+ export interface LayermapRun {
35
+ version: string
36
+ analyzer: string
37
+ }
38
+
39
+ /** ranBy:输出里说的跑这次的 LayerMap。 */
40
+ export type LayermapAnswer = { ok: true; value: unknown; ranBy?: LayermapRun } | LayermapFailure
41
+
42
+ /**
43
+ * 检查用的 LayerMap 版本:分叉点上那份 testpace.json 里的 "layermap",没写或认不出分叉点时没有(跟着本机的版本走)。
44
+ * 它决定检查怎么判,按评判用的配置走"合并后才生效"(judging.ts):分支上改的版本这次不算,换不了查它自己的那一版。
45
+ */
46
+ export function pinnedLayermap(root: string): string | undefined {
47
+ const { commit } = forkPoint(root)
48
+ return commit ? contractAt(root, commit)?.layermap : undefined
49
+ }
50
+
51
+ /** 跑 layermap 的环境:固定了版本的带上 LAYERMAP_VERSION。 */
52
+ function runWith(pinned: string | undefined): NodeJS.ProcessEnv {
53
+ return pinned ? { ...process.env, LAYERMAP_VERSION: pinned } : process.env
54
+ }
55
+
56
+ function ranBy(value: unknown): LayermapRun | undefined {
57
+ const by = typeof value === 'object' && value !== null ? (value as { layermap?: unknown }).layermap : undefined
58
+ if (typeof by !== 'object' || by === null) return undefined
59
+ const { version, analyzer } = by as Record<string, unknown>
60
+ return typeof version === 'string' && typeof analyzer === 'string' ? { version, analyzer } : undefined
61
+ }
62
+
63
+ const UPGRADE =
64
+ '升级一次 LayerMap 插件(Claude Code 里是 claude plugin marketplace update layermap 再 claude plugin update layermap@layermap,Codex 里是 codex plugin marketplace upgrade layermap),~/.local/bin 的 layermap 命令再跑一次 npx layermap setup command;之后它自己跟着 npm 的最新版更新。开新会话后再跑'
29
65
 
30
66
  /**
31
67
  * 版本太旧的说法:模块在输出里读不到要的字段时也用它。
@@ -35,13 +71,13 @@ export function tooOld(): LayermapFailure {
35
71
  return {
36
72
  ok: false,
37
73
  kind: 'old',
38
- problem: `layermap 版本太旧,要 ${LAYERMAP_MINIMUM} 以上:升级一次 LayerMap 插件(Claude Code 里是 claude plugin marketplace update layermap 再 claude plugin update layermap@layermap,Codex 里是 codex plugin marketplace upgrade layermap),~/.local/bin 的 layermap 命令再跑一次 npx layermap setup command;之后它自己跟着 npm 的最新版更新。开新会话后再跑`,
74
+ problem: `layermap 版本太旧,要 ${LAYERMAP_MINIMUM} 以上:${UPGRADE}`,
39
75
  }
40
76
  }
41
77
 
42
- /** layermap --version 的输出(给各模块的 status 看);找不到命令或它没跑成时为 undefined。 */
43
- export function layermapVersion(): string | undefined {
44
- const r = spawnSync('layermap', ['--version'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
78
+ /** 在这个仓库里跑的 layermap 的 --version 输出(给各模块的 status 看);找不到命令或它没跑成时为 undefined。 */
79
+ export function layermapVersion(root: string): string | undefined {
80
+ const r = spawnSync('layermap', ['--version'], { cwd: root, env: runWith(pinnedLayermap(root)), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
45
81
  return r.status === 0 ? r.stdout.trim() : undefined
46
82
  }
47
83
 
@@ -50,7 +86,10 @@ const TIMEOUT_MS = 600_000
50
86
 
51
87
  /** 在仓库根目录跑一条 layermap 命令(args 里要带 --json),读回它输出的 JSON。 */
52
88
  export function layermap(root: string, args: string[]): LayermapAnswer {
53
- const r = spawnSync('layermap', args, { cwd: root, encoding: 'utf8', maxBuffer: 1024 * 1024 * 1024, timeout: TIMEOUT_MS, stdio: ['ignore', 'pipe', 'pipe'] })
89
+ const pinned = pinnedLayermap(root)
90
+ if (pinned && compareVersions(pinned, LAYERMAP_MINIMUM) < 0)
91
+ return { ok: false, kind: 'failed', problem: `testpace.json 固定的 LayerMap ${pinned} 低于要的 ${LAYERMAP_MINIMUM}:改 "layermap",合并后生效` }
92
+ const r = spawnSync('layermap', args, { cwd: root, env: runWith(pinned), encoding: 'utf8', maxBuffer: 1024 * 1024 * 1024, timeout: TIMEOUT_MS, stdio: ['ignore', 'pipe', 'pipe'] })
54
93
  if (r.error) {
55
94
  const code = (r.error as NodeJS.ErrnoException).code
56
95
  if (code === 'ENOENT') return { ok: false, kind: 'missing', problem: '找不到 layermap 命令' }
@@ -64,9 +103,18 @@ export function layermap(root: string, args: string[]): LayermapAnswer {
64
103
  const how = r.status === null ? `被信号 ${r.signal} 终止` : `退出码 ${r.status}`
65
104
  return { ok: false, kind: 'failed', problem: `layermap 出错了${said ? `:${said}` : `(${how})`}` }
66
105
  }
106
+ let value: unknown
67
107
  try {
68
- return { ok: true, value: JSON.parse(r.stdout) }
108
+ value = JSON.parse(r.stdout)
69
109
  } catch {
70
110
  return tooOld()
71
111
  }
112
+ const by = ranBy(value)
113
+ if (pinned && by?.version !== pinned)
114
+ return {
115
+ ok: false,
116
+ kind: 'old',
117
+ problem: `testpace.json 固定用 LayerMap ${pinned},跑的却是${by ? ` ${by.version}` : '没说版本的旧版'}:layermap 命令的启动器太旧,不认固定的版本。${UPGRADE}`,
118
+ }
119
+ return { ok: true, value, ...(by ? { ranBy: by } : {}) }
72
120
  }
package/src/wall/check.ts CHANGED
@@ -6,6 +6,7 @@ import { readFileSync, writeFileSync } from 'node:fs'
6
6
  import { join } from 'node:path'
7
7
  import { askUser } from '../base/confirm.ts'
8
8
  import { EXIT } from '../base/exit.ts'
9
+ import type { LayermapRun } from '../base/layermap.ts'
9
10
  import { pathsAt } from '../base/git.ts'
10
11
  import type { Repo } from '../base/repo.ts'
11
12
  import { CONFIG_PATH } from './config.ts'
@@ -41,6 +42,8 @@ export interface Report {
41
42
  overlapping: boolean
42
43
  /** layermap imports 用不了:R1、R2、R3 没查(R4 和入口清单也就没查);R5、R6 照常查了。 */
43
44
  layermapProblem?: string
45
+ /** 读 import 的 LayerMap:通过记录里记下是哪一版、哪个分析器查的。 */
46
+ layermap?: LayermapRun
44
47
  /** 只有 layermap check 没跑成:R1–R3 照常查了,R4 和入口新增导出这次没查。只进日志和 modwall status,不进 check 的输出、不影响退出码。 */
45
48
  changesProblem?: string
46
49
  violations: Violation[]
@@ -120,6 +123,7 @@ export function analyze(project: Project, repo: Repo): Report {
120
123
  let facts: ProjectImports | undefined
121
124
  const imports = readImports(project.root)
122
125
  if (imports.ok) {
126
+ if (imports.value.ranBy) report.layermap = imports.value.ranBy
123
127
  const assets = withAssets(imports.value, project.files)
124
128
  facts = { imports: [...assets.imports, ...miniprogram.imports], unresolved: assets.unresolved }
125
129
  // 数据库里模块之间的引用和代码的 import 一起算环
@@ -7,7 +7,7 @@ import { CONTRACT_FILE, loadContract } from '../base/contract.ts'
7
7
  import { EXIT } from '../base/exit.ts'
8
8
  import { filesNow } from '../base/git.ts'
9
9
  import { matchesAny } from '../base/glob.ts'
10
- import { LAYERMAP_COMMAND, LAYERMAP_MINIMUM, layermapVersion } from '../base/layermap.ts'
10
+ import { LAYERMAP_COMMAND, LAYERMAP_MINIMUM, layermapVersion, pinnedLayermap } from '../base/layermap.ts'
11
11
  import { openRepo, type Repo } from '../base/repo.ts'
12
12
  import { analyze, exitCode, formatReport, logCheck, prepare, type Report, violationLines } from './check.ts'
13
13
  import { CONFIG_PATH, MODWALL_DIR, schemeOf } from './config.ts'
@@ -18,7 +18,7 @@ import { leaveReceipt } from './receipt.ts'
18
18
  import { draftConfig } from './init.ts'
19
19
  import type { Module } from './layout.ts'
20
20
  import { configText } from './loosen.ts'
21
- import { checkPassed, contentKey, currentKey, layoutOf, openProject, passRecord, type Project } from './project.ts'
21
+ import { contentKey, currentKey, layoutOf, openProject, passOf, passRecord, type Project } from './project.ts'
22
22
  import { BLOCKING_RULES, unownedFiles } from './rules.ts'
23
23
  import { openStore, type Store } from './store.ts'
24
24
 
@@ -102,7 +102,7 @@ function check(): number {
102
102
  const code = exitCode(report)
103
103
  if (code !== EXIT.ok) return code
104
104
  // 结论是按开始时的内容得出的:检查的过程中内容改过,这次不记、不算
105
- if (!store.passes.saveChecked(key, () => currentKey(project.root) ?? '', passRecord(project))) {
105
+ if (!store.passes.saveChecked(key, () => currentKey(project.root) ?? '', passRecord(project, report.layermap))) {
106
106
  console.log('\n检查过程中内容改过(检查是按开始时的样子做的),这次的结论不算:代码不再改动时重跑 modwall check。')
107
107
  return EXIT.fail
108
108
  }
@@ -255,11 +255,14 @@ function status(): number {
255
255
  else if (report.changesProblem) lines.push(`越界:${counts.join('、')};R4 和入口新增导出没查(这次改动增删的关系没读到)`)
256
256
  else lines.push(`越界:${counts.join('、')};R4 提示 ${report.behavior.length}(详情跑 modwall check)`)
257
257
  }
258
- lines.push(`通过记录:${checkPassed(project, store) ? '当前内容 modwall check 通过过' : '当前内容还没有通过记录(modwall check)'}`)
259
- const version = layermapVersion()
258
+ const pass = passOf(project, store)
259
+ const passedBy = pass?.layermap ? `(LayerMap ${pass.layermap.version},分析器 ${pass.layermap.analyzer})` : ''
260
+ lines.push(`通过记录:${pass ? `当前内容 modwall check 通过过${passedBy}` : '当前内容还没有通过记录(modwall check)'}`)
261
+ const version = layermapVersion(project.root)
262
+ const pinned = pinnedLayermap(project.root)
260
263
  lines.push(
261
264
  version
262
- ? `LayerMap:${version}${report.layermapProblem ? `,用不了:${report.layermapProblem}` : report.changesProblem ? `,layermap check 没跑成:${report.changesProblem}` : ',能用'}(最低 ${LAYERMAP_MINIMUM})`
265
+ ? `LayerMap:${version}${pinned ? `(testpace.json 固定用 ${pinned})` : ''}${report.layermapProblem ? `,用不了:${report.layermapProblem}` : report.changesProblem ? `,layermap check 没跑成:${report.changesProblem}` : ',能用'}(最低 ${LAYERMAP_MINIMUM})`
263
266
  : `LayerMap:没找到 layermap 命令,要装 LayerMap 插件(${LAYERMAP_MINIMUM} 以上);${LAYERMAP_COMMAND}`,
264
267
  )
265
268
  lines.push(...testpaceStatus(project, report.layout !== undefined && report.layout.databases.length > 0))
@@ -2,7 +2,7 @@
2
2
  // 找命令、版本下限、出了问题怎么说都在那一处;这里读不到要的字段,就按版本太旧说。
3
3
  // LayerMap 用不了时检查算没做完,不算通过(check.ts)。
4
4
 
5
- import { layermap, LAYERMAP_COMMAND, LAYERMAP_MINIMUM, tooOld } from '../base/layermap.ts'
5
+ import { layermap, LAYERMAP_COMMAND, LAYERMAP_MINIMUM, type LayermapRun, tooOld } from '../base/layermap.ts'
6
6
 
7
7
  const TOO_OLD = tooOld().problem
8
8
  const MISSING = `没找到 layermap 命令:modwall 用 LayerMap 读代码里的 import,要装 LayerMap 插件(${LAYERMAP_MINIMUM} 以上),开新会话后在 Bash 里再跑;${LAYERMAP_COMMAND}`
@@ -27,6 +27,8 @@ export interface UnresolvedFact {
27
27
  export interface ProjectImports {
28
28
  imports: ImportFact[]
29
29
  unresolved: UnresolvedFact[]
30
+ /** 读出这些 import 的 LayerMap(0.1.60 起的输出里才有)。 */
31
+ ranBy?: LayermapRun
30
32
  }
31
33
 
32
34
  /** 这次改动(和分叉点比)增删的关系。 */
@@ -50,7 +52,7 @@ export type Result<T> = { ok: true; value: T } | { ok: false; problem: string }
50
52
  /** 外部包和语言自带的库:忽略。其余原因(含以后新加的)都当成可能是项目自己的。 */
51
53
  const EXTERNAL = new Set(['OUTSIDE_SOURCE_CONTEXT', 'DECLARATION_NOT_AVAILABLE', 'COMPILER_LIBRARY'])
52
54
 
53
- function run(root: string, args: string[]): Result<unknown> {
55
+ function run(root: string, args: string[]): { ok: true; value: unknown; ranBy?: LayermapRun } | { ok: false; problem: string } {
54
56
  const answer = layermap(root, args)
55
57
  if (answer.ok) return answer
56
58
  if (answer.kind === 'missing') return { ok: false, problem: MISSING }
@@ -89,7 +91,7 @@ export function readImports(root: string): Result<ProjectImports> {
89
91
  : undefined,
90
92
  )
91
93
  if (!imports || !unresolved) return { ok: false, problem: TOO_OLD }
92
- return { ok: true, value: { imports, unresolved } }
94
+ return { ok: true, value: { imports, unresolved, ...(out.ranBy ? { ranBy: out.ranBy } : {}) } }
93
95
  }
94
96
 
95
97
  /** 这次改动(和 base 比,含未提交的)增删的关系。 */
@@ -6,6 +6,7 @@ import { existsSync, readFileSync } from 'node:fs'
6
6
  import { join } from 'node:path'
7
7
  import { currentBranch, fileNow, filesNow, forkPoint } from '../base/git.ts'
8
8
  import { judgingFile } from '../base/judging.ts'
9
+ import type { LayermapRun } from '../base/layermap.ts'
9
10
  import { hash } from '../base/records.ts'
10
11
  import { type Config, CONFIG_PATH, joined, MODWALL_DIR, parseConfig, readConfig } from './config.ts'
11
12
  import { isCode, isTest } from './files.ts'
@@ -67,7 +68,7 @@ const MATTERS = (path: string): boolean =>
67
68
 
68
69
  /**
69
70
  * 当前内容的摘要:影响检查结果的文件。通过记录按它记。
70
- * 不含分叉点上的配置:检查过不过和分叉点有关的只有放宽项,记在通过记录里(checkPassed)。含了的话,
71
+ * 不含分叉点上的配置:检查过不过和分叉点有关的只有放宽项,记在通过记录里(passOf)。含了的话,
71
72
  * 分支改过配置、快进到默认分支后分叉点变成自己,合并前刚通过的记录就对不上了。
72
73
  */
73
74
  export function contentKey(project: Project): string {
@@ -83,19 +84,19 @@ export function contentKey(project: Project): string {
83
84
  return hash(...parts)
84
85
  }
85
86
 
86
- /** 检查通过时要记的:通过时和分叉点比出来的放宽项(都经用户同意过,不然过不了)。 */
87
- export function passRecord(project: Project): PassRecord {
88
- return { at: Date.now(), loosening: looseningItems(project.before.config, project.now).map(item => item.text) }
87
+ /** 检查通过时要记的:通过时和分叉点比出来的放宽项(都经用户同意过,不然过不了),和查的 LayerMap。 */
88
+ export function passRecord(project: Project, layermap: LayermapRun | undefined): PassRecord {
89
+ return { at: Date.now(), loosening: looseningItems(project.before.config, project.now).map(item => item.text), ...(layermap ? { layermap } : {}) }
89
90
  }
90
91
 
91
92
  /**
92
- * 当前内容 modwall check 通过过:有这份内容的通过记录,现在和分叉点比出来的放宽项都在通过时那一组里。
93
+ * 当前内容 modwall check 通过过的那条记录(没有为 undefined):有这份内容的通过记录,现在和分叉点比出来的放宽项都在通过时那一组里。
93
94
  * 分叉点挪了(快进、合进默认分支)放宽项只会少;多出来的没经用户同意,要重跑。
94
95
  */
95
- export function checkPassed(project: Project, store: Store): boolean {
96
+ export function passOf(project: Project, store: Store): PassRecord | undefined {
96
97
  const record = store.passes.get(contentKey(project))
97
- if (!record) return false
98
- return looseningItems(project.before.config, project.now).every(item => record.loosening.includes(item.text))
98
+ if (!record) return undefined
99
+ return looseningItems(project.before.config, project.now).every(item => record.loosening.includes(item.text)) ? record : undefined
99
100
  }
100
101
 
101
102
  /** 这个仓库现在的内容摘要(重新打开一遍);没接入时为 undefined。写通过记录前用它核对内容没变。 */
package/src/wall/store.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  // 都经底座存取(base/records.ts,文件在 .git/testpace/wall/ 下,所有 worktree 共用),这里只定记的是什么。
3
3
  // 用户同意过的放宽项不在这里:归底座的用户确认(base/confirm.ts)。
4
4
 
5
+ import type { LayermapRun } from '../base/layermap.ts'
5
6
  import { hash, ModuleRecords } from '../base/records.ts'
6
7
  import type { Repo } from '../base/repo.ts'
7
8
  import { newRunId } from '../base/store.ts'
@@ -10,6 +11,8 @@ export interface PassRecord {
10
11
  at: number
11
12
  /** 通过时和分叉点比出来的放宽项(给用户看的文字)。 */
12
13
  loosening: string[]
14
+ /** 查的 LayerMap:只给 modwall status 看。换了固定的版本就是改了 testpace.json,内容变了,记录本来就对不上。 */
15
+ layermap?: LayermapRun
13
16
  }
14
17
 
15
18
  /** 一个分支上一次查全了的检查:下一次据此算改正了哪些越界。 */
@@ -19,7 +22,7 @@ export interface LastCheck {
19
22
  }
20
23
 
21
24
  export interface Store {
22
- /** modwall check 的通过记录,按当时的内容记,内容变了就对不上(还算不算数见 project.ts 的 checkPassed)。 */
25
+ /** modwall check 的通过记录,按当时的内容记,内容变了就对不上(还算不算数见 project.ts 的 passOf)。 */
23
26
  passes: ModuleRecords<PassRecord>
24
27
  /** 按分支记。 */
25
28
  last: ModuleRecords<LastCheck>