Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ AGENTS.md files may begin with optional YAML frontmatter to control loading:
---
memory_type: project
priority: 10
scope: project
scope: repo
trust: maintainer_approved
visibility: public_review
source: github_pr
source_ref: OpenCoven/coven-code#123
expires_at: 2099-12-31
---

# My Project Notes
Expand All @@ -362,9 +367,22 @@ Frontmatter fields:

| Field | Description |
|-------|-------------|
| `memory_type` | Informal label (currently informational only). |
| `id` | Stable memory id used for hosted review citation, for example `mem_auth_policy`. If omitted, Coven Code derives a stable id from path and content. |
| `memory_type` | Memory category label such as `project`, `user`, `reference`, or `feedback`. |
| `priority` | Integer sort priority (lower numbers are prepended first within the same scope). |
| `scope` | Informational label for documentation purposes. |
| `scope` | Intended scope, such as `user`, `tenant`, `installation`, `repo`, `branch`, or `pr`. |
| `trust` | Source trust. Hosted review enforces this against `hostedReview.memoryTrustThreshold`. Supported values include `system_policy`, `maintainer_approved`, `default_branch_code`, `model_inferred`, `contributor_input`, `fork_input`, and `unknown`. |
| `visibility` | Intended review visibility: `public_review`, `private_review`, or `security_private`. Hosted public reviews exclude `security_private` memory by default. |
| `source` | Provenance source kind, for example `manual`, `github_pr`, `github_pr_review`, or `session_memory_extraction`. |
| `source_ref` | Source reference such as `owner/repo#123`, a commit SHA, or another non-secret audit handle. |
| `expires_at` | Optional expiry date in `YYYY-MM-DD` format. Expired hosted memory is ignored. |
| `created_at`, `created_by`, `session_id`, `transcript_ref`, `confidence` | Optional provenance fields for audit and review artifacts. |

Local mode tolerates missing metadata for backward compatibility. Hosted review
mode treats missing trust as `unknown`, ignores expired memory, and excludes
memory below the configured trust threshold. Tagged hosted memory is injected
with memory ids and provenance metadata; findings that rely on memory should
include those ids in `memory_refs`.

### @include directives

Expand Down
34 changes: 34 additions & 0 deletions docs/shared/hosted-review-phase-4-pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Hosted Review Phase 4 PR Notes

## Linked issues

Fixes #105.
Fixes #106.
Fixes #112.

## Summary

- Extends AGENTS.md frontmatter with enforceable hosted metadata: stable id, trust, visibility, source, source_ref, expiry, created_at, created_by, session_id, transcript_ref, and confidence.
- Enforces hosted memory metadata during loading: missing trust is lowest trust, expired memory is ignored, security-private memory is excluded from public hosted review, and trust must meet the configured threshold.
- Renders hosted memory as tagged entries with stable ids, trust, visibility, source, source_ref, and session metadata so review output can cite memory refs.
- Threads session-scoped provenance into hosted auto-extracted memory candidates.
- Adds structured review-output parsing and validation helpers for `memory_refs` on memory-dependent findings.
- Documents the hosted frontmatter contract and citation behavior.

## Test evidence

- `cargo fmt --all -- --check`
- `cargo check --workspace`
- `cargo clippy --workspace --all-targets -- -D warnings`
- `cargo test -p claurst-core --lib claudemd --quiet`
- `cargo test -p claurst-core --lib system_prompt --quiet`
- `cargo test -p claurst-core --lib --quiet`
- `cargo test -p claurst-query session_memory --quiet`
- `cargo test -p claurst-commands structured_review_output --quiet`
- `cargo test --workspace --quiet`

## Risk notes

- The slash `/review` command remains markdown-first; the structured review parser is available for hosted integrations that request JSON review artifacts.
- Hosted memory without trust metadata is intentionally ignored unless policy lowers the trust threshold.
- Provenance stores references and ids, not secret values.
60 changes: 59 additions & 1 deletion src-rust/crates/commands/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3382,6 +3382,39 @@ impl SlashCommand for LearnCommand {

// ---- /review -------------------------------------------------------------

#[derive(Debug, Clone, serde::Deserialize, PartialEq, Eq)]
pub struct StructuredReviewOutput {
#[serde(default)]
pub findings: Vec<StructuredReviewFinding>,
}

#[derive(Debug, Clone, serde::Deserialize, PartialEq, Eq)]
pub struct StructuredReviewFinding {
pub title: String,
#[serde(default)]
pub memory_refs: Vec<String>,
#[serde(default)]
pub memory_dependent: bool,
}

pub fn parse_structured_review_output(text: &str) -> Option<StructuredReviewOutput> {
serde_json::from_str::<StructuredReviewOutput>(text).ok()
}

pub fn validate_structured_review_memory_refs(review: &StructuredReviewOutput) -> Vec<String> {
review
.findings
.iter()
.filter(|finding| finding.memory_dependent && finding.memory_refs.is_empty())
.map(|finding| {
format!(
"finding '{}' is marked memory-dependent but has no memory_refs",
finding.title
)
})
.collect()
}

#[async_trait]
impl SlashCommand for ReviewCommand {
fn name(&self) -> &str {
Expand Down Expand Up @@ -3527,7 +3560,8 @@ impl SlashCommand for ReviewCommand {
(1-3 sentences describing what changed)\n\n\
## Issues\n\
(bulleted list: [CRITICAL|MAJOR|MINOR] file:line — description; \
omit section if none)\n\n\
omit section if none; if the issue depends on a loaded memory entry, \
include memory_refs: [\"mem_...\"] on that bullet)\n\n\
## Suggestions\n\
(bulleted list of optional improvements; omit section if none)\n\n\
## Verdict\n\
Expand Down Expand Up @@ -10488,6 +10522,30 @@ mod tests {
}
}

#[test]
fn structured_review_output_parses_memory_refs() {
let review = parse_structured_review_output(
r#"{"findings":[{"title":"Auth check","memory_refs":["mem_auth"],"memory_dependent":true}]}"#,
)
.unwrap();

assert_eq!(review.findings[0].memory_refs, vec!["mem_auth"]);
assert!(validate_structured_review_memory_refs(&review).is_empty());
}

#[test]
fn structured_review_output_warns_when_memory_refs_missing() {
let review = parse_structured_review_output(
r#"{"findings":[{"title":"Auth check","memory_dependent":true}]}"#,
)
.unwrap();

let warnings = validate_structured_review_memory_refs(&review);
assert_eq!(warnings.len(), 1);
assert!(warnings[0].contains("Auth check"));
assert!(warnings[0].contains("memory_refs"));
}

#[tokio::test]
async fn test_learn_resolves_and_emits_skill_prompt() {
// Resolvable by name and by alias.
Expand Down
Loading