Skip to content

fix(web Wave 8 #15): sweep schema-drift tsc errors surfaced by #1764 regen#1766

Merged
earayu merged 1 commit into
mainfrom
feat/w8-task15-tsc-drift-sweep
Apr 28, 2026
Merged

fix(web Wave 8 #15): sweep schema-drift tsc errors surfaced by #1764 regen#1766
earayu merged 1 commit into
mainfrom
feat/w8-task15-tsc-drift-sweep

Conversation

@earayu
Copy link
Copy Markdown
Collaborator

@earayu earayu commented Apr 28, 2026

Summary

Resolves the 4 tsc errors PR #1764 surfaced as W8-6 sediment: index-status badge color map (document-index-status.tsx × 2) realigned with the four-value DocumentIndexStatus enum (PENDING/RUNNING/ACTIVE/FAILED), and collection-form.tsx zod schema + defaultValues thread the new nullable backend-selection fields (graph_backend_type, fulltext_backend_type).

§K.12 invariant cross-check

4-pattern pre-check matrix

  • Pattern 1 v1 (legacy enum string literals in graph paths): rg "CREATING|DELETING|DELETION_IN_PROGRESS|SKIPPED" web/src shows zero remaining hits in the two files this PR touches. Outside this PR's scope, documents-table.tsx (NON_TERMINAL_INDEX_STATUSES Set) and unrelated Document.status paths still reference these literals — see Findings.
  • Pattern 1 v2 (form submission compatibility): the regenerated web/src/api-v2/schema.d.ts already declares both new fields as `… | null`, so passing null from the form keeps server validation green. Verified by re-running yarn tsc --noEmit → zero errors in collection-form.tsx after the schema fix.
  • Pattern 2 (response-shape change list): the form change is on the request shape only — Collection.config was already carrying these fields on the response side after feat(web Wave 7 #9): regen frontend OpenAPI schema after #1762 cutover #1764, the drift was that the form never threaded them.
  • Pattern 3 (additive helpers): n/a, the PR is purely additive fields + value-set narrowing.

simple-stable directive 4-guardrail

  • feat/frontend #1 不无限扩范围 — strictly the two files named in the W8-6 task description. Did not extend to the documents-table.tsx Set or to other pre-existing tsc errors that pre-date Wave 7.
  • feat: auth bearer token support #2 尽快上线 — three small files, ~15 LOC of diff.
  • feat: api test #3 简单稳定 — the field defaults match the implicit pre-W7 behavior (server picks default backend, color map maps every enum value). No new UI; no new validation.
  • fix: upload token #4 私有化部署免维护 — `null` values mean operators do not need to pre-provision backend pickers in the form before they can create a collection.

Findings (out of scope, sediment)

  1. documents-table.tsx defines a `NON_TERMINAL_INDEX_STATUSES = new Set([...])` whose members (`CREATING`, `DELETING`, `DELETION_IN_PROGRESS`) correspond to the retired enum. The Set is `Set` so tsc does not flag it, but the polling logic that asks "is any document still indexing?" will silently never match — the actual non-terminal values today are `PENDING` and `RUNNING`. Worth a follow-up PR (separate scope: behavioural polling fix, not type drift).

  2. yarn tsc --noEmit still reports five pre-existing errors in app/page.tsx (i18n template literal), collection-header.tsx (`Record<CollectionStatus, …>` indexing), bot/types.ts (`ChatMessage` / `Reference`), and features/collection/types.ts (`Collection`). These pre-date the Wave 7 regen — they are not in W8-6 scope and are a deeper feature-by-feature investigation (translation namespace, type-namespace re-exports).

Test plan

  • yarn tsc --noEmit baseline on origin/main → 9 errors (4 in W8-6 scope + 5 pre-existing)
  • After this PR → 5 errors (zero in W8-6 scope; 5 pre-existing untouched, sedimented)
  • Diff is local: git diff --stat shows 3 files / +6 / -8
  • No new dependency, no new UI surface — pure type/value sweep

🤖 Generated with Claude Code

…regen

Resolve the 4 tsc errors PR #1764 surfaced as W8-6 sediment:

- `app/(workspace|marketplace)/.../document-index-status.tsx`:
  realign the badge-color map with the four-value
  `DocumentIndexStatus` enum (PENDING / RUNNING / ACTIVE /
  FAILED). The legacy seven-value enum mapping (CREATING,
  DELETING, DELETION_IN_PROGRESS, SKIPPED) was rejected by
  TS2353 against the regenerated `Record<DocumentIndexStatus, string>`
  shape. RUNNING inherits the in-progress sky-blue color slot from
  the retired CREATING value; the dropped terminal/skipped colors
  are unreachable now that the backend has migrated.

- `app/workspace/collections/collection-form.tsx`: thread the
  required nullable backend-selection fields
  `graph_backend_type` ("postgres" | "neo4j" | "nebula") and
  `fulltext_backend_type` ("elasticsearch" | "opensearch")
  through the zod schema and `defaultValues`. Both default to
  `null`, which the backend accepts as "use the cluster default
  backend" — matching the previous behavior where the form
  silently omitted them. No new UI knobs are added; that is a
  separate feature, not a drift sweep.

§K.12 invariant cross-check
============================
- #4 (`VectorStoreConnectorAdaptor` abstraction) — n/a at the
  frontend layer, no provider lock-in introduced.
- #11 (candidate detection write-only) — n/a, this PR does not
  touch the curation surface.
- #12 (grep-zero LightRAG) — `rg -i lightrag web/src/` returns
  zero hits both before and after the sweep.

4-pattern pre-check matrix
==========================
- Pattern 1 v1 (legacy enum string literals in graph paths):
  `rg "CREATING|DELETING|DELETION_IN_PROGRESS|SKIPPED" web/src`
  shows zero remaining hits in the two files this PR touches.
  Outside this PR's scope, `documents-table.tsx`
  (`NON_TERMINAL_INDEX_STATUSES` Set) and the unrelated
  `Document.status` paths still reference these literals — see
  Findings.
- Pattern 1 v2 (form submission compatibility): the regenerated
  `web/src/api-v2/schema.d.ts` already declares both new fields
  as `… | null`, so passing `null` from the form keeps server
  validation green. Verified by re-running `yarn tsc --noEmit`
  → zero errors in `collection-form.tsx` after the schema fix.
- Pattern 2 (response-shape change list): the form change is on
  the *request* shape only — `Collection.config` was already
  carrying these fields on the response side after #1764, the
  drift was that the form never threaded them.
- Pattern 3 (additive helpers): n/a, the PR is purely additive
  fields + value-set narrowing.

simple-stable directive 4-guardrail
===================================
- #1 不无限扩范围 — strictly the two files named in the W8-6
  task description. Did *not* extend to the `documents-table.tsx`
  Set or to other pre-existing tsc errors that pre-date Wave 7.
- #2 尽快上线 — three small files, ~15 LOC of diff.
- #3 简单稳定 — the field defaults match the implicit pre-W7
  behavior (server picks default backend, color map maps every
  enum value). No new UI; no new validation.
- #4 私有化部署免维护 — `null` values mean operators do not need
  to pre-provision backend pickers in the form before they can
  create a collection.

Findings (out of scope, sediment)
=================================
1. `app/workspace/collections/[collectionId]/documents/documents-table.tsx`
   defines a `NON_TERMINAL_INDEX_STATUSES = new Set([...])` whose
   members (`CREATING`, `DELETING`, `DELETION_IN_PROGRESS`)
   correspond to the retired enum. The Set is `Set<string>` so
   tsc does not flag it, but the polling logic that asks "is
   any document still indexing?" will silently never match —
   the actual non-terminal values today are `PENDING` and
   `RUNNING`. Worth a follow-up PR (separate scope: behavioural
   polling fix, not type drift).

2. `yarn tsc --noEmit` still reports five pre-existing errors
   in `app/page.tsx` (i18n template literal), `collection-header.tsx`
   (`Record<CollectionStatus, …>` indexing), `bot/types.ts`
   (`ChatMessage` / `Reference`), and `features/collection/types.ts`
   (`Collection`). These pre-date the Wave 7 regen — they are
   not in W8-6 scope ("collection-form.tsx + document-index-status.tsx
   schema drift 修复") and are a deeper feature-by-feature
   investigation (translation namespace, type-namespace re-exports).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator Author

@earayu earayu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 LGTM ✅ (huangheng pass-1, per spec §K.12.11) — GitHub 不允许同账号 approve;verdict = ready to merge

3 files / +6 / -8 — 严格 W8-6 scope (2 document-index-status + 1 collection-form),0 scope creep。frontend 0 break + grep-zero LightRAG ✅ + 5 pre-existing tsc errors 显式 sediment (非本 task scope)。

12-invariant (W8-6 frontend scope)

# Material 状态
4 VectorStoreConnectorAdaptor n/a frontend
11 D-3 candidate detection n/a curation 不动
12 grep-zero LightRAG ✅ pre + post rg -i lightrag web/src/ → 0

4-pattern v1+v2+v2+n/a

PR body 完整 paste — Pattern 1 v1 stale enum literals 全清 (本 PR scope);Pattern 1 v2 form 提交兼容 (null 通过 server validation 绿);Pattern 2 request shape only (response shape 已 #1764 regen);Pattern 3 n/a.

simple-stable

  • #1 不无限扩范围 ✅ 严格 W8-6 描述的 2 文件,不扩 documents-table.tsx Set 或其他 pre-existing
  • #2 尽快上线 ✅ ~15 LOC
  • #3 简单稳定 ✅ field defaults 匹配 pre-W7 行为;color map cover 全 enum 值
  • #4 私有化免维护 ✅ null defaults = operator 0 backend picker 配置

findings sediment

  1. documents-table.tsx NON_TERMINAL_INDEX_STATUSES Set 含 stale enum members (CREATING/DELETING/DELETION_IN_PROGRESS) — Set<string> 所以 tsc 不报,但 polling 逻辑"is any document still indexing?"silently never match (实际 non-terminal 是 PENDING/RUNNING)。这是 behavioral bug 不是 type drift,建议 follow-up PR scope 单独 sediment(不归 W8-6 type drift sweep)。

  2. 5 个 pre-existing tsc errors (page.tsx i18n / collection-header.tsx Record indexing / bot/types.ts / features/collection/types.ts) — pre-date Wave 7 regen,feature-by-feature 调查范畴,非 W8-6 scope。✅ 显式留 W8-8+ candidate sediment (translation namespace / type-namespace re-exports 调查需要)。

修完会 LGTM 的清单

实际上已经可以 merge ✅。

@cuiwenbo 严格 scope + 显式 sediment behavioral bug + 5 pre-existing errors 都标注 — frontend implementer 范例质量。👍

@符炫炜 LGTM,可 merge。
@不穷 推进 task #15 → done after merge;Wave 8 余下 #12 / #13 / #14 / #16 in_progress。

1 个 minor sediment 候选(非阻塞)

documents-table.tsx NON_TERMINAL_INDEX_STATUSES Set behavioral bug 是 W8-8 candidate("frontend behavioral drift sweep — Set/array literals 与 enum drift"),与 W8-6 type-drift sweep 互补。当前 polling 失效是 silent regression,影响 user 体验(UI 永远显示 "indexing complete" 即使后端在 pending/running)。Wave 8 起步时 PM + architect priority sort 看是否纳入。

(W8-8 候选我同时 sediment 进 Wave 8 candidate list 等架构师确认。)

@earayu earayu merged commit f3f2d69 into main Apr 28, 2026
7 checks passed
@earayu earayu deleted the feat/w8-task15-tsc-drift-sweep branch April 28, 2026 02:43
earayu added a commit that referenced this pull request Apr 28, 2026
…rings (#1768)

Replace `NON_TERMINAL_INDEX_STATUSES` with the live four-value
enum members so the document polling loop actually identifies
in-progress index work instead of silently never matching.

The previous Set declared (`PENDING`, `CREATING`, `DELETING`,
`DELETION_IN_PROGRESS`) — three of those four literals were
retired when the backend simplified the per-modality index
enum to (`PENDING`, `RUNNING`, `ACTIVE`, `FAILED`). The Set is
typed `Set<string>` so tsc never flagged the drift, but
`hasNonTerminalDocumentState` would only ever match `'PENDING'`
in practice; documents transitioning through the new `'RUNNING'`
state were treated as terminal, so the table fell out of fast-
poll mode while indexing was still active.

This is the W8-8 sediment from PR #1766 (task #15) findings:
type-drift fixed there is type-safe but did not catch
behavior-drift cases hidden behind `Set<string>` / `Array<string>`
literals. architect msg=ec02b580 authorised cuiwenbo to ship
this short-term follow-up at own cadence.

§K.12 invariant cross-check
============================
Largely n/a (frontend behavioral fix, not graph-layer):

- #12 (grep-zero LightRAG) — `rg -i lightrag web/src/` returns
  zero hits both before and after, no narrative mention added.

4-pattern pre-check matrix
==========================
- Pattern 1 v1 (legacy enum literals in this file):
  `rg "CREATING|DELETION_IN_PROGRESS" documents-table.tsx`
  shows zero remaining hits. The remaining `'DELETING'` literal
  in `NON_TERMINAL_DOCUMENT_STATUSES` (line 67) belongs to the
  separate eight-value `Document.status` enum (`UPLOADED |
  EXPIRED | PENDING | RUNNING | COMPLETE | FAILED | DELETING |
  DELETED`), which still includes `DELETING` — leave intact.
- Pattern 1 v2 (consumers of the Set): only one call site,
  `hasNonTerminalDocumentState`, which polls based on Set
  membership; no other code reads the Set's contents directly.
- Pattern 2 (response-shape change list): n/a, this PR does
  not touch any API surface or schema.
- Pattern 3 (additive helpers): n/a, value-set narrowing only.

simple-stable directive 4-guardrail
===================================
- #1 不无限扩范围 — single-file two-string Set sweep, ~5 LOC
  diff. Did not extend to refactor the polling logic or
  re-derive the Set from the OpenAPI enum (a future cleanup,
  not in scope for the immediate behavior fix).
- #2 尽快上线 — small targeted fix, ~30 min after task #15
  merge.
- #3 简单稳定 — the Set now matches the live enum verbatim
  (`PENDING`, `RUNNING`); no fragile string-to-string mappings
  introduced.
- #4 私有化部署免维护 — fix is invisible to operators; restores
  intended polling behaviour.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant