Skip to content

knowledge_source: lint and os validate check the object and field references and the gates that need no principal, also at publish #37307

Backlog

Description

@objectstack-fleet

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

Filing gate: ③ maintainer-directed (topic child). Source: topic #37000; maintainer 2026-11-25 「现在拆阶段三」 (decision card in the project thread) and 「#4 只负责在手任务,你接手专题剩余任务」. Reviewed by an independent Fable pass before filing.
Grading: area:build · Feature · p2 (topic) · reach: every package that ships a knowledge_source, and every source saved at runtime · evidence: read.

维护者速读

  • 问题:知识源写错了对象名或字段名,或者指向一个不允许检索的对象(系统对象、API 不开放检索的对象),现在要等到检索时才发现「怎么搜不到」。
  • 做什么:os validate 和发布时就检查并报出来,报错写明是哪个对象、哪个字段、为什么不行。
  • 谁受益:写应用包的作者和用 AI 搭建的作者,错误在发布前就看到。
  • 需要你做的:无。

What

Carries ADR-0161 (docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md) Execution row "rows 4, 5, 5b": K4's reference checks ("refused when the object or a named field does not exist (the lint and os validate checks are row 4)") and "A packaged item meets the gates that need no principal in os validate and at publish (row 4)". The precedent is validateAiContext (packages/lint/src/validate-ai-context.ts, PR #37173) and its at-publish wiring (PR #37247, #37176).

  1. A rule file packages/lint/src/validate-knowledge-source.ts, registered in packages/lint/src/authoring-rules.ts beside validateAiContext (:1984) and exported from packages/lint/src/index.ts, each rule with an os explain entry in packages/lint/src/rule-explanations.ts (the ai_context entries start at :6008). Reference checks, against the stack's objects:
    • source.object names no object;
    • a source.content or source.metadataFields member names no field of that object;
    • a member names a credential-class or internal field, which the index never carries (K5: skipped even when named) — the author hears that it will be skipped (an addition past the Execution row, under ADR-0078).
  2. The gates that need no principal (K4, the gates of PR fix(service-knowledge): knowledge search asks the object's API exposure and the caller's field-level read rules per source #36850 as packages/services/service-knowledge/src/knowledge-source-admission.ts states them):
    • the object's API exposure refuses search (canServeApiOperation(enable, 'search'), packages/spec/src/data);
    • a system object without enable.aiReadable (isAiReadExposed, packages/spec/src/data/ai-read-exposure.ts).
      Reuse those predicates; do not restate them. The disabled-package gate and the field-queryable gate need an environment or a principal and stay at save (row 3a).
  3. At publish. Map knowledge_source to its collection in packages/lint/src/runtime-gate.ts (the ai_context row is :312, and its comment states the rule: no mapping ahead of its rule), so the runtime publish door reports the same rule ids and messages os validate prints. Follow the refuse-or-warn verdict the ai_context row took and state it.
  4. Severity. A missing object or field, and both gates, are errors: such a source can never serve a hit. The credential/internal member is a warning. State each in the PR.

Rulings carried (ADR-0161 K10): embedding is egress, so the check reads the explicit content list (no wildcard exists after row 3a); no key is added.

Acceptance

  • os validate on a package whose source names a missing object, a missing content field, a missing metadata field, an object with apiEnabled: false, an object whose apiMethods omit search, or a sys_* object without enable.aiReadable prints one finding each, with the rule id and the object or field named; a clean source prints none.
  • A credential-class field in content prints the warning.
  • The same source published at runtime reports the same rule ids and messages.
  • os explain answers each rule id.
  • The authoring-rule wiring test and the lint suite are green.
  • Container run per AGENTS.md.

Out of scope

  • The type, its loader, the named permission and source admission at save as the authoring principal (disabled package, field-queryable): row 3a.
  • The Studio form that shows these reports: row 5. Teaching the rules in skills/objectstack-ai: row 5b.
  • Whether a source that names a field withheld by the field-egress declaration is refused at authoring: the field-egress topic (ADR-0161 K5).

Blocked-by: #37304 (row 3a).
Parent: #37000. Reader: domain:spec lane (packages/lint).
Dedupe: knowledge source lint 361 (open hits are unrelated lint and seat cards; none checks a knowledge source) · "knowledge" "os validate" 82 (open: #37000, unrelated) · knowledge os validate object unknown 102 (open: none on knowledge).

Activity

  1. added
    priority:p2
    domain:spec
    pm:blocked
    on Nov 25, 2026
  2. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    First touch 2026-11-25T14:33Z. Confirmed as filed: Feature · area:build · domain:spec · p2, pm:blocked on #37304 (row 4). It is a row of topic #37000, so it routes to repo:objectstack#1 (maintainer 13:49Z 「继续专题 开发 37000」). The body's Blocked-by: line already reads in line form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:builddomain:specpm:blockedpriority:p2

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions