feat(W4): daily full reconciliation — user/role drift repair + ReconcileLogs audit
- w4-body.js: ONE-DIRECTIONAL sync (NocoDB status = SOT, never reverse);
drift matrix: missing user/role (provision w/ username lookup to avoid
duplicates), dangling refs (adopt/recreate), disabled<->status, canonical
base_path '/' + permission 16384, scopes vs calculateEffectiveGrants,
username drift detect+log_only; verify-after-repair on every change;
password never pushed on repair (方案 C); dry-run via ?dryRun=true
- gen_w4.js: daily 03:00 cron + webhook alist-w4-reconcile; API-import-safe
(UUID node ids, no pinData, webhookId)
- ReconcileLogs table mktsb7le6fqr2u1 (add_reconcilelogs_table.py, idempotent,
v2 API); FK column nc_jitu___Customers_id for bt-link writes (v2 ignores
link column itself)
- test_w4_reconcile.js: 34 assertions / 12 mock worlds, ALL PASSED
- live-verified against production: dry-run (3 drifts + 1 error found),
real repair (3 repaired, verify all passed, 4 log rows), idempotent rerun
- NocoDB 2026.08.x pitfalls documented (v1 col endpoints gone, row delete
via body [{Id}]); n8n API import/activation pitfalls (activeVersionId)
- docs: W4-DESIGN.md new; DATABASE_SCHEMA 8 tables; N8N_WORKFLOWS, SETUP,
PROJECT_STATE updated
This commit is contained in:
+19
-3
@@ -1,8 +1,8 @@
|
||||
# NocoDB 数据结构(Phase 2b — 重建,7 表最终模型)
|
||||
# NocoDB 数据结构(Phase 2b — 重建,8 表最终模型)
|
||||
|
||||
> Source of Truth = NocoDB。AList 只做 enforcement,不存业务授权数据。
|
||||
> 本 schema 按《Hermes 调整指导》最终业务模型重建(2026-08-22)。
|
||||
> 通过 NocoDB API 自动建表,无需手动点 UI。
|
||||
> 通过 NocoDB API 自动建表,无需手动点 UI。ReconcileLogs 于 2026-08-23 W4 新增。
|
||||
|
||||
- **Base**: `AlistAccess`(id `p3lzkresswyowqg`),独立新 base,与旧 `accessDB` 隔离。
|
||||
- **MySQL source**: mysql-server 上的 `alistaccess` schema(由 NocoDB 自动管理)。
|
||||
@@ -19,6 +19,7 @@
|
||||
| AccessGrants | `mxdx3yhfcyej3ao` |
|
||||
| AccessLogs | `ml12zcyzlehgi21` |
|
||||
| Purchases | `mwp12z9lcohhsuk` |
|
||||
| ReconcileLogs | `mktsb7le6fqr2u1`(FK 列 `nc_jitu___Customers_id` = `coa6ynwcdlune6p`) |
|
||||
|
||||
> ⚠ ID 是本次重建生成的。若再次删库重建,ID 会变,需同步更新 n8n 节点 + 本文档。
|
||||
|
||||
@@ -35,6 +36,7 @@
|
||||
| AccessLogs | `customer` | bt | Customers | |
|
||||
| Purchases | `customer` | bt | Customers | |
|
||||
| Purchases | `product` | bt | Products | |
|
||||
| ReconcileLogs | `customer` | bt | Customers | ⚠ 写入时用 FK 列 `nc_jitu___Customers_id`(v2 忽略 link 列本身) |
|
||||
|
||||
> M2M 读写方式(已实测):`GET/POST /api/v2/tables/{products}/links/c4ko4x8kwi16swg/records/{productId}`,
|
||||
> POST body `{"Id": <resourceId>}`。反向用 Resources 的 `cfxi44n9ixkimqc`。
|
||||
@@ -138,7 +140,21 @@
|
||||
| bytes | Number |
|
||||
| timestamp | DateTime |
|
||||
|
||||
### 7. Purchases(纯记录,不参与权限)
|
||||
### 7. ReconcileLogs(W4 对账审计,n8n W4 写入)
|
||||
| 字段 | 类型 | 说明 |
|
||||
|---|---|---|
|
||||
| Id | number (PK) | |
|
||||
| run_id | SingleLineText | 本次对账 run(`recon-<ISO>`) |
|
||||
| customer | link bt → Customers | FK 列 `nc_jitu___Customers_id`(v2 写链接必须写 FK 列) |
|
||||
| drift_type | SingleSelect | user_missing / role_missing / dangling_user_ref / dangling_role_ref / user_disabled_drift / scopes_drift / base_path_drift / permission_drift / role_binding_drift / username_drift / verify_failed / reconcile_error |
|
||||
| details | LongText | 前后值 JSON |
|
||||
| action | SingleLineText | 做了什么(provisioned / adopted / fixed / rewritten / disabled / log_only / verify …) |
|
||||
| result | SingleSelect | repaired / log_only / failed / skipped |
|
||||
| timestamp | DateTime | |
|
||||
|
||||
> 只记 drift / repair / error 行,健康客户不产生行。W4 每日全量或 webhook 触发时写入。
|
||||
|
||||
### 8. Purchases(纯记录,不参与权限)
|
||||
| 字段 | 类型 |
|
||||
|---|---|
|
||||
| Id | number (PK) |
|
||||
|
||||
Reference in New Issue
Block a user