语料配置:每个键都有说明
完整解析 YAML 配置:项目、文件筛选、密钥、嵌入向量、索引、Joern、重索引阈值与校验。
最小可用配置 #
project: myproject
root: C:/path/to/your/project
languages: [python, javascript, markdown]
include: ["**/*.py", "**/*.js", "**/*.md"]
exclude: ["**/node_modules/**", "**/build/**"]ragraf init <目录> 会自行创建配置——带着合理的默认值和注释。下面其余的一切都是可选的,但值得理解。
secrets 段——默认即安全 #
secrets_exclude: # never indexed and never read AT ALL
- "**/.env"
- "**/.env.*"
- "**/*.pem"
- "**/*.key"
- "**/secrets/**"这是排除,而不是遮盖:文件在任何阶段都不会被打开读取——扫描时不打开,分块时不打开,生成向量时不打开,写日志时也不打开。按 M3-T2 协议在诱饵样本上对此做了验证(带有标记的文件只要位于 secrets_exclude 之内,就必须在全部三个存储中都不出现)。
嵌入向量 #
embedding:
model: sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2
dim: 384
batch_size: 64
device: auto # auto | cpu | cuda — see the GPU article模型只下载一次(约 240 MB),存放在 ~/.ragraf/models(可由 RAGRAF_MODEL_CACHE 覆盖)。之所以选择多语言 MiniLM,是因为语料与查询都是混合的(代码 + docblock 以及智能体查询中的俄文/英文)。dim 必须与模型一致——不一致会在索引启动时就被捕获,而不是等到查询回答里才暴露出来。
索引 #
index:
retain_revs: 3 # how many revisions to keep (journal archives not counted)
chunk_budget: 8000 # chunk token budget; overflow splits the chunk
reindex_on_drift: warn # warn | auto | fail
full_reindex_threshold: 0.35 # share of changed files → full rebuild
fast_reindex_threshold: 0.05 # share → fast rebuild of the affected files校验规则:full > fast 是强制要求(违反时就是在启动阶段报配置错误,而不是之后出现奇怪的行为)。阈值以 sha256 已经不一致的文件占比为基准:低于 fast 时——只对受影响的分块做定点重建(未变化分块的嵌入向量按 chunk_sha256 直接复用,不需要重新计算);介于两个阈值之间——标准重建;高于 full 时——完整重建(完整重建通常比上千次定点重建更便宜)。
真实参考值:在 323 个文件的语料上,完整索引耗时 71 秒(其中 CPG 占 64 秒);复用嵌入向量使定点重建只需几秒。
Joern(可选的 CPG 层) #
index:
joern_enabled: true
joern_heap_gb: 8 # or RAGRAF_JOERN_HEAP_GB在没有 Joern/JDK 21 的情况下,索引不会失败:capability=degraded,slice 会带原因拒绝,其余部分照常工作。详情见 CPG 层文章。
数据库结构 #
schema:
migrations: ["migrations/*.sql"] # glob relative to root
dsn_from: config/database.php # index the FACT of the config reference, not its values当环境允许使用 DSN 时,information_schema 以只读方式使用;否则结构只从迁移文件中获取,不再去查询数据库。无论哪种情况,配置里的密钥值都不会进入索引。
遥测 #
telemetry:
enabled: true # usage_call journal kept locally; nothing leaves the machine
arg_digest_chars: 60 # argument digest instead of the full text该日志是 usage 与面板的基础;参数以 sha1 + 摘要的形式保存,完整的查询文本——绝不保存。
校验与调试 #
配置会在每条命令启动时被校验:未知的键——给出警告(这不是错误:为了保持向前兼容),类型不兼容——报错并明确指出是哪个键出了问题。管理面板在写入项目配置变更时会做校验,并保留 .bak 副本。对生效中配置的快速诊断:
ragraf -p config/mycorpus.yaml status # revision, capability, sizes, drift
ragraf -p config/mycorpus.yaml selftest # environment: 9+2 components相关:GPU 计算 → · CPG/Joern → · 首次运行 →