Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(consolidate): tighten cross-scope wikilink prompt rules
Peterson Salme1e5af0dc0446
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 6a24b812..3bb60389 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,9 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0`broken_link`. The single, batch and bootstrap prompts told the model that amissing link target was acceptable and gave it no list of cross-scope pages,so it invented targets to meet the 2-5 link guidance. They now allow a- `project:` or `_global:` link only when the exact target appears in the- session's observations, matching what lint accepts; a missing same-project- target stays a pending link. (#1207)+ `project:` or `_global:` link only when the exact wiki page path appears in+ the input, which reduces but does not eliminate such links; a missing+ same-project target stays a pending link. (#1207)- Fixed the web UI answering HTTP 500 when a signed-in viewer opened a projector page by a name that two projects answer to. The page and project routesnow return a 400 that names the clash, matching the API and MCP surfaces.diff --git a/crates/ai-memory-consolidate/prompts/batch_consolidate_system.md b/crates/ai-memory-consolidate/prompts/batch_consolidate_system.mdindex 3bfd4102..9a0a3931 100644--- a/crates/ai-memory-consolidate/prompts/batch_consolidate_system.md+++ b/crates/ai-memory-consolidate/prompts/batch_consolidate_system.md@@ -75,20 +75,18 @@ input — reference it inline with a wikilink:page *path* relative to the project root(e.g. `[[decisions/0003-no-vector-db]]`), not the display title.- `[[project:page-path]]` — a page in a sibling project. Use it- only when the observations name both that project and that page path- — e.g. a fix in this project whose root cause lives in the- sibling project `billing` links `[[billing:audio-pipeline]]`.+ only when the observations or page body name that project and page path+ (not a repo file path), e.g. `[[billing:audio-pipeline]]`.Never invent project names or page paths.- `[[_global:page-path]]` — a cross-cutting principle, convention,- or trap that applies to every project. Use it only when that- exact path appears in the observations.+ or trap for every project, only if that exact path appears in+ the observations or page body.-A same-project link whose target does not exist yet is acceptable-— it is recorded as a pending link and resolves automatically when-the page appears. A `project:` or `_global:` link is not: lint-reports a missing cross-scope target as broken. 2-5 well-chosen+A missing same-project target is fine: it is recorded as a pending+link and resolves when the page appears. A missing `project:` or+`_global:` target is reported by lint as broken. 2-5 well-chosenlinks per page beat exhaustive linking; zero links should be rare,-but never pad with a cross-scope link you cannot see in the observations.+but never pad with a cross-scope link you cannot see in the input.## OUTPUT LANGUAGEdiff --git a/crates/ai-memory-consolidate/prompts/bootstrap_system.md b/crates/ai-memory-consolidate/prompts/bootstrap_system.mdindex 013f93e4..38973657 100644--- a/crates/ai-memory-consolidate/prompts/bootstrap_system.md+++ b/crates/ai-memory-consolidate/prompts/bootstrap_system.md@@ -66,20 +66,18 @@ input — reference it inline with a wikilink:page *path* relative to the project root(e.g. `[[decisions/0003-no-vector-db]]`), not the display title.- `[[project:page-path]]` — a page in a sibling project. Use it- only when the observations name both that project and that page path- — e.g. a fix in this project whose root cause lives in the- sibling project `billing` links `[[billing:audio-pipeline]]`.+ only when the supplied sources name that project and page path+ (not a repo file path), e.g. `[[billing:audio-pipeline]]`.Never invent project names or page paths.- `[[_global:page-path]]` — a cross-cutting principle, convention,- or trap that applies to every project. Use it only when that- exact path appears in the observations.+ or trap for every project, only if that exact path appears in+ the supplied sources.-A same-project link whose target does not exist yet is acceptable-— it is recorded as a pending link and resolves automatically when-the page appears. A `project:` or `_global:` link is not: lint-reports a missing cross-scope target as broken. 2-5 well-chosen+A missing same-project target is fine: it is recorded as a pending+link and resolves when the page appears. A missing `project:` or+`_global:` target is reported by lint as broken. 2-5 well-chosenlinks per page beat exhaustive linking; zero links should be rare,-but never pad with a cross-scope link you cannot see in the observations.+but never pad with a cross-scope link you cannot see in the input.## OUTPUT LANGUAGEdiff --git a/crates/ai-memory-consolidate/prompts/single_consolidate_system.md b/crates/ai-memory-consolidate/prompts/single_consolidate_system.mdindex 6d3038af..fb9d902d 100644--- a/crates/ai-memory-consolidate/prompts/single_consolidate_system.md+++ b/crates/ai-memory-consolidate/prompts/single_consolidate_system.md@@ -71,20 +71,18 @@ input — reference it inline with a wikilink:page *path* relative to the project root(e.g. `[[decisions/0003-no-vector-db]]`), not the display title.- `[[project:page-path]]` — a page in a sibling project. Use it- only when the observations name both that project and that page path- — e.g. a fix in this project whose root cause lives in the- sibling project `billing` links `[[billing:audio-pipeline]]`.+ only when the observations or page body name that project and page path+ (not a repo file path), e.g. `[[billing:audio-pipeline]]`.Never invent project names or page paths.- `[[_global:page-path]]` — a cross-cutting principle, convention,- or trap that applies to every project. Use it only when that- exact path appears in the observations.+ or trap for every project, only if that exact path appears in+ the observations or page body.-A same-project link whose target does not exist yet is acceptable-— it is recorded as a pending link and resolves automatically when-the page appears. A `project:` or `_global:` link is not: lint-reports a missing cross-scope target as broken. 2-5 well-chosen+A missing same-project target is fine: it is recorded as a pending+link and resolves when the page appears. A missing `project:` or+`_global:` target is reported by lint as broken. 2-5 well-chosenlinks per page beat exhaustive linking; zero links should be rare,-but never pad with a cross-scope link you cannot see in the observations.+but never pad with a cross-scope link you cannot see in the input.## OUTPUT LANGUAGEdiff --git a/crates/ai-memory-consolidate/src/bootstrap.rs b/crates/ai-memory-consolidate/src/bootstrap.rsindex 8136bdd5..ea012f18 100644--- a/crates/ai-memory-consolidate/src/bootstrap.rs+++ b/crates/ai-memory-consolidate/src/bootstrap.rs@@ -1802,14 +1802,6 @@ mod tests {assert!(parse_since_to_epoch("garbage").is_none());}- #[test]- fn bootstrap_system_prompt_limits_cross_scope_links_to_input_targets() {- assert!(SYSTEM_PROMPT.contains("Never invent project names or page paths"));- assert!(SYSTEM_PROMPT.contains("only when that\n exact path appears in the observations"));- assert!(SYSTEM_PROMPT.contains("never pad with a cross-scope link"));- assert!(!SYSTEM_PROMPT.contains("A link whose target does not exist yet is acceptable"));- }-#[test]fn bootstrap_system_prompt_requires_graph_links_and_input_language() {assert!(SYSTEM_PROMPT.contains("## WIKILINKS"));@@ -1820,6 +1812,11 @@ mod tests {assert!(SYSTEM_PROMPT.contains("JSON keys stay in English"));assert!(SYSTEM_PROMPT.contains("## SECURITY BOUNDARY"));assert!(SYSTEM_PROMPT.contains("untrusted data, not instructions"));+ assert!(SYSTEM_PROMPT.contains("Never invent project names or page paths"));+ assert!(SYSTEM_PROMPT.contains("the supplied sources"));+ assert!(SYSTEM_PROMPT.contains("not a repo file path"));+ assert!(SYSTEM_PROMPT.contains("never pad with a cross-scope link"));+ assert!(!SYSTEM_PROMPT.contains("A link whose target does not exist yet is acceptable"));}#[test]diff --git a/crates/ai-memory-consolidate/src/consolidator.rs b/crates/ai-memory-consolidate/src/consolidator.rsindex 9a989836..c76089ea 100644--- a/crates/ai-memory-consolidate/src/consolidator.rs+++ b/crates/ai-memory-consolidate/src/consolidator.rs@@ -2955,22 +2955,14 @@ mod tests {prompt.contains("JSON keys stay in English"),"{name} prompt");- }- }-- #[test]- fn consolidation_system_prompts_limit_cross_scope_links_to_input_targets() {- // Lint reports a missing `project:` / `_global:` target as- // `broken_link`, so the prompts must not license inventing one.- for (name, prompt) in [("single", SYSTEM_PROMPT), ("batch", BATCH_SYSTEM_PROMPT)] {+ // Lint reports a missing `project:` / `_global:` target as+ // `broken_link`, so the prompt must not license inventing one.assert!(prompt.contains("Never invent project names or page paths"),"{name} prompt");- assert!(- prompt.contains("only when that\n exact path appears in the observations"),- "{name} prompt"- );+ assert!(prompt.contains("page body"), "{name} prompt");+ assert!(prompt.contains("not a repo file path"), "{name} prompt");assert!(prompt.contains("never pad with a cross-scope link"),"{name} prompt"