---
title: "find 是有界描述层查询，unknown 不是 not-found"
---

> Documentation Index
> Fetch the complete documentation index at: https://koine.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# find 是有界描述层查询，unknown 不是 not-found

## 背景

ADR-0013 决定 find 与 explore 分开：find 属于描述层，explore 属于驱动层。但 find 的 CLI 语义还没有定义：

- 探索有界（`--depth` / `--max-worlds` / `--timeout`），没找完时该说什么？
- `where` 谓词求值失败（除零、函数式读取缺行）时，算 false 还是算错误？
- find 会不会改变世界？

## 选项

- 边界耗尽返回 `not-found`：简单，但把“没找到”和“没找完”混为一谈。
- 求值失败当 false：把失败和“条件不成立”混为一谈，掩盖模型错误。
- find 只返回世界集合，不返回路径：失去“怎么走到”的信息。
- find 执行时产生中间世界：破坏描述层查询不改变世界的边界。

## 决定

find 是有界描述层查询：

- 在 explore 的可达世界集合里按 BFS 序找第一个满足 `where` 的世界；
- `where` 是当前世界的 Bool 表达式（无自由变量；可用 relation/define/aggregate/量词/now）；
- 三态结果：找到 `found`（附路径与世界）、完整搜索无命中 `not-found`、边界耗尽或后继无法枚举 `unknown` + `reason`；
- 谓词求值失败（非 Bool、求值失败）是查询失败：报诊断、退出码 1，不当作 false；
- find 不改变世界。

## 理由

- `unknown` 与 `not-found` 的置信度不同：调用方必须知道“没找到”是否可靠。
- 失败不是 false：false 是值，失败是模型/查询错误，静默吞掉会掩盖缺陷（与 ADR-0026 对 require/axiom 的立场一致）。
- BFS 序保证路径最短；路径复用 ADR-0015 的快照序列语义，不存中间世界。
- 描述层查询不产生世界，explore/find 的起点之外没有新世界被物化。

## 后果

- find 需要与 explore 相同的边界参数；输出 `reason`（`depth` | `max-worlds` | `timeout` | `unknown`）。
- `where` 需要一个独立的表达式解析入口（`koine::parse_expression`），复用 parser，不另写解析器。
- 谓词求值失败的用户必须读诊断修复查询，而不是把失败当答案。

## 相关

- [ADR-0013](https://koine.systems/notes/decisions/0013-observation-boundaries/)
- [ADR-0015](https://koine.systems/notes/decisions/0015-history-as-snapshot-sequence/)
- [ADR-0026](https://koine.systems/notes/decisions/0026-require-axiom/)
- [观察规范](https://koine.systems/reference/spec/observations/)

Source: https://koine.systems/notes/decisions/0028-find-is-bounded-descriptive-query/index.mdx
