diff --git a/hooks/ways/frontmatter-schema.yaml b/hooks/ways/frontmatter-schema.yaml index 06bdad2b..7a9b39f4 100644 --- a/hooks/ways/frontmatter-schema.yaml +++ b/hooks/ways/frontmatter-schema.yaml @@ -28,8 +28,11 @@ way: required: optional default: 0.35 role: Cosine similarity threshold for embedding engine (0.0-1.0, higher = stricter) - # embed_model: removed — derived automatically by corpus builder - # (.md ways → en model, .locales.jsonl entries → multilingual model) + redisclose: + type: number + required: optional + default: 25 + role: Context window % before re-disclosure (lower = more frequent, default 25) pattern: type: regex required: optional diff --git a/hooks/ways/softwaredev/code/quality/quality.md b/hooks/ways/softwaredev/code/quality/quality.md index 76cdc034..b46f78ac 100644 --- a/hooks/ways/softwaredev/code/quality/quality.md +++ b/hooks/ways/softwaredev/code/quality/quality.md @@ -3,6 +3,7 @@ description: code quality, refactoring, SOLID principles, code review standards, vocabulary: refactor quality solid principle decompose extract method responsibility coupling cohesion maintainability readability threshold: 2.0 pattern: solid.?principle|refactor|code.?review|code.?quality|clean.?up|simplify|decompos|extract.?method|tech.?debt +redisclose: 15 macro: append scan_exclude: \.md$|\.lock$|\.min\.(js|css)$|\.generated\.|\.bundle\.|vendor/|node_modules/|dist/|build/|__pycache__/ scope: agent, subagent diff --git a/hooks/ways/softwaredev/delivery/branching/branching.md b/hooks/ways/softwaredev/delivery/branching/branching.md index e21ffada..1ed908d9 100644 --- a/hooks/ways/softwaredev/delivery/branching/branching.md +++ b/hooks/ways/softwaredev/delivery/branching/branching.md @@ -2,6 +2,7 @@ description: Git branch awareness and branching guidance when editing files vocabulary: branch checkout worktree main trunk feature fix refactor files: \.(md|rs|sh|py|js|ts|json|yaml|yml|toml|go|rb|java|c|cpp|h|hpp|css|html|sql)$ +redisclose: 10 macro: prepend scope: agent, subagent --- diff --git a/hooks/ways/softwaredev/delivery/commits/commits.md b/hooks/ways/softwaredev/delivery/commits/commits.md index f7ef003a..fe84f6fd 100644 --- a/hooks/ways/softwaredev/delivery/commits/commits.md +++ b/hooks/ways/softwaredev/delivery/commits/commits.md @@ -4,6 +4,7 @@ vocabulary: commit message branch conventional feat fix refactor scope atomic sq threshold: 2.0 pattern: commit|push.*(remote|origin|upstream) commands: git\ commit +redisclose: 15 scope: agent, subagent --- diff --git a/hooks/ways/softwaredev/delivery/github/github.md b/hooks/ways/softwaredev/delivery/github/github.md index f5e84434..9e396eb7 100644 --- a/hooks/ways/softwaredev/delivery/github/github.md +++ b/hooks/ways/softwaredev/delivery/github/github.md @@ -4,6 +4,7 @@ vocabulary: pr pullrequest issue review checks ci label milestone fork repositor threshold: 2.0 pattern: github|\ issue|pull.?request|\ pr\ |\ pr$|review.?(pr|comment)|merge.?request|ship.?(it|this|the)|land.?(it|this)|merge.?(it|this) commands: ^gh\ |^gh$ +redisclose: 10 macro: prepend scope: agent, subagent --- diff --git a/hooks/ways/softwaredev/delivery/release/release.md b/hooks/ways/softwaredev/delivery/release/release.md index d3ed5b18..2dce3f0c 100644 --- a/hooks/ways/softwaredev/delivery/release/release.md +++ b/hooks/ways/softwaredev/delivery/release/release.md @@ -2,6 +2,7 @@ description: software releases, changelog generation, version bumping, semantic versioning, tagging vocabulary: release changelog version bump semver tag publish ship major minor breaking threshold: 2.0 +redisclose: 15 pattern: release|changelog|tag|version.?bump|bump.?version|npm.?publish|cargo.?publish scope: agent, subagent --- diff --git a/hooks/ways/softwaredev/environment/deps/deps.md b/hooks/ways/softwaredev/environment/deps/deps.md index 17a3b8ab..8e8a2ace 100644 --- a/hooks/ways/softwaredev/environment/deps/deps.md +++ b/hooks/ways/softwaredev/environment/deps/deps.md @@ -4,6 +4,7 @@ vocabulary: dependency package library install upgrade outdated audit vulnerabil threshold: 2.0 pattern: dependenc|package|library|npm.?install|pip.?install|upgrade.*version commands: npm\ install|yarn\ add|pip\ install|cargo\ add|go\ get +redisclose: 15 scope: agent, subagent --- diff --git a/hooks/ways/softwaredev/environment/makefile/makefile.md b/hooks/ways/softwaredev/environment/makefile/makefile.md index f548d987..8eef3775 100644 --- a/hooks/ways/softwaredev/environment/makefile/makefile.md +++ b/hooks/ways/softwaredev/environment/makefile/makefile.md @@ -4,6 +4,7 @@ vocabulary: makefile make target build lint linter test format clean install pub files: Makefile$|makefile$|GNUmakefile$|\.mk$ commands: make threshold: 1.5 +redisclose: 10 scope: agent, subagent macro: append --- diff --git a/tools/ways-cli/src/cmd/show/mod.rs b/tools/ways-cli/src/cmd/show/mod.rs index e37a7a43..502ee0a7 100644 --- a/tools/ways-cli/src/cmd/show/mod.rs +++ b/tools/ways-cli/src/cmd/show/mod.rs @@ -40,9 +40,11 @@ pub fn way(id: &str, session_id: &str, trigger: &str) -> Result { } // Session marker check + token-gated re-disclosure (ADR-104) + let redisclose_pct: Option = extract_field(&content, "redisclose") + .and_then(|s| s.parse().ok()); let is_redisclosure; if session::way_is_shown(id, session_id) { - match session::token_distance_exceeded(id, session_id) { + match session::token_distance_exceeded(id, session_id, redisclose_pct) { Some(_distance) => { is_redisclosure = true; } diff --git a/tools/ways-cli/src/frontmatter.rs b/tools/ways-cli/src/frontmatter.rs index cf3ac91e..374bbb3f 100644 --- a/tools/ways-cli/src/frontmatter.rs +++ b/tools/ways-cli/src/frontmatter.rs @@ -16,6 +16,9 @@ pub struct Frontmatter { pub scope: Option, #[serde(default)] pub embed_threshold: Option, + #[serde(default)] + #[allow(dead_code)] // parsed for serde compat, read via extract_field in show/mod.rs + pub redisclose: Option, } /// Extract YAML frontmatter from a way file. diff --git a/tools/ways-cli/src/session.rs b/tools/ways-cli/src/session.rs index 01c75fdb..ba893add 100644 --- a/tools/ways-cli/src/session.rs +++ b/tools/ways-cli/src/session.rs @@ -218,14 +218,16 @@ pub fn stamp_way_tokens(way_id: &str, session_id: &str, position: u64) { /// Check if token distance exceeds re-disclosure threshold. /// Returns Some(distance) if exceeded, None if not. -pub fn token_distance_exceeded(way_id: &str, session_id: &str) -> Option { +/// `redisclose_pct` overrides the global default when set (per-way frontmatter). +pub fn token_distance_exceeded(way_id: &str, session_id: &str, redisclose_pct: Option) -> Option { let tokens_path = session_dir(session_id).join("way-tokens").join(way_id).join(".value"); let last_tokens = read_u64_path(&tokens_path); let current = get_token_position(session_id); let distance = current.saturating_sub(last_tokens); + let pct = redisclose_pct.unwrap_or(REDISCLOSE_PCT); let context_window = detect_context_window(session_id); - let threshold = context_window * REDISCLOSE_PCT / 100; + let threshold = context_window * pct / 100; if distance >= threshold { Some(distance)