From ee38182b79494ae5afb02d7fdb71cc5c7aac6fc4 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 26 Feb 2026 15:08:36 -0700 Subject: [PATCH] Add native impact remediation synthesis loop (sprint 242) --- docs/constructive_editing_runtime_plan.md | 6 +- ...rator_readiness_gap_registry_2026-02-26.md | 2 +- docs/progress_log_2026-02-26.md | 14 ++++ .../sprint242_execution_tracker_2026-02-26.md | 35 +++++++++ editor/src/Sprint242IntegrationSummary.h | 6 ++ sprint242_plan.md | 11 +++ .../mcp/run_native_impact_remediation_loop.sh | 69 ++++++++++++++++++ tools/mcp/run_sprint_taskitem_pipeline.sh | 16 ++++ ..._native_impact_remediation_requirements.py | 73 +++++++++++++++++++ 9 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 docs/sprint242_execution_tracker_2026-02-26.md create mode 100644 editor/src/Sprint242IntegrationSummary.h create mode 100644 sprint242_plan.md create mode 100755 tools/mcp/run_native_impact_remediation_loop.sh create mode 100755 tools/mcp/synthesize_native_impact_remediation_requirements.py diff --git a/docs/constructive_editing_runtime_plan.md b/docs/constructive_editing_runtime_plan.md index 45771ae..8b500e7 100644 --- a/docs/constructive_editing_runtime_plan.md +++ b/docs/constructive_editing_runtime_plan.md @@ -150,7 +150,7 @@ Parallel planning tranche (active): - `logs/taskitem_runs/TEST_ONLY_spec_planning_baseline_20260226/deterministic_spec_readiness.json` Planning runtime controls (active): -- `sprint232_plan.md` to `sprint241_plan.md` +- `sprint232_plan.md` to `sprint242_plan.md` - semantic bridge + intake augmentation + requirement injection + expansion gating are wired into: - `tools/mcp/run_sprint_taskitem_pipeline.sh` - current policy default is native-first semantic fallback: @@ -174,3 +174,7 @@ Planning runtime controls (active): - `WSTONE_NATIVE_IMPACT_COVERAGE_ENFORCE` - `WSTONE_NATIVE_IMPACT_COVERAGE_PROFILES` - `native_impact_coverage` +- remediation loop can synthesize profile-specific extra constraints and rerun: + - `WSTONE_EXTRA_NORMALIZED_REQUIREMENTS_FILE` + - `tools/mcp/synthesize_native_impact_remediation_requirements.py` + - `tools/mcp/run_native_impact_remediation_loop.sh` diff --git a/docs/generator_readiness_gap_registry_2026-02-26.md b/docs/generator_readiness_gap_registry_2026-02-26.md index 47c98e7..90fc427 100644 --- a/docs/generator_readiness_gap_registry_2026-02-26.md +++ b/docs/generator_readiness_gap_registry_2026-02-26.md @@ -47,7 +47,7 @@ This is the canonical dated registry for "not production-ready" generator gaps. | GR-018 | Performance/security/rollout constrained refactor enforcement gap | `docs/gap_hunt_fullstack_multifile_2026-02-26.md`, `logs/taskitem_runs/challenging_fullstack_multifile_20260226_r5/results.jsonl` | `partial` | Hard checks now enforce migration rollback + data-loss policy, security deny-by-default, SLO p95 presence, and rollout staged+abort policy. Enforcement is contract-level; generator capability under these constraints is still weak in C++ AB path. | Constraint-aware generation follow-up | | GR-019 | Parity-blocked readiness load (gating without capability closure) | `logs/taskitem_runs/challenging_fullstack_multifile_20260226_r7/summary.json`, `logs/taskitem_runs/challenging_subset_prod_20260226_r7/summary.json`, `docs/sprint225_227_execution_tracker_2026-02-26.md` | `partial` | Sprint 225-227 reduced blocked parity load from `6` to `0` on both tracked hard catalogs while keeping unresolved divergence at `0`. This closes immediate safety debt for current corpora, but robustness is still contingent on pattern-driven repair classes. | Generalize repairs beyond queue-shaped transpile outputs | | GR-020 | Semantic fallback overuse masks weak native decomposition | `logs/taskitem_runs/TEST_ONLY_sprint236_semantic_fallback_audit_20260226/semantic_fallback_summary.json`, `logs/taskitem_runs/TEST_ONLY_sprint237_semantic_fallback_gate_fail_20260226/semantic_fallback_budget_gate.json`, `logs/taskitem_runs/TEST_ONLY_sprint238_native_gate_fail_20260226.json`, `logs/taskitem_runs/TEST_ONLY_sprint239_semantic_fallback_audit_20260226/semantic_fallback_summary.json`, `logs/taskitem_runs/TEST_ONLY_sprint240_retry_20260226_145631/00_summary.json`, `docs/sprint236_execution_tracker_2026-02-26.md`, `docs/sprint237_execution_tracker_2026-02-26.md`, `docs/sprint238_execution_tracker_2026-02-26.md`, `docs/sprint239_execution_tracker_2026-02-26.md`, `docs/sprint240_execution_tracker_2026-02-26.md` | `partial` | Sprint 236 added deterministic fallback-gap auditing with tool + constraint metadata. Sprint 237 added fallback-budget hard gate (`max-fallback-rate`) and produced expected fail/pass artifacts. Sprint 238 added native decomposition hard gate in pipeline (`min task count`, `min semantic signal count`) so weak native generation can be blocked before fallback masking. Sprint 239 added native reason enrichment and improved semantic signal density (`0 -> 6`). Sprint 240 added native decomposition retry with explicit minimum-task policy; on current sample retry attempted but did not improve depth (`2 -> 2`). | Native decomposition task-depth upgrade (increase native task granularity beyond 2) | -| GR-021 | Impact-specific native decomposition coverage not enforced uniformly | `docs/native_decomposition_impact_list_2026-02-26.md`, `tools/mcp/profiles/native_decomposition_impact_profiles.json`, `logs/taskitem_runs/TEST_ONLY_sprint241_fullstack_impact_20260226_150416/00_summary.json`, `logs/taskitem_runs/TEST_ONLY_sprint241_native_impact_aggregate_20260226/native_impact_coverage_aggregate.json` | `partial` | Sprint 241 added one-by-one impact profiles and a pipeline-integrated native impact coverage gate (`native_impact_coverage`). Current fullstack sample activates 7 profiles and all fail, proving enforcement catches shallow coverage but generator closure is still pending. | Implement profile-specific native decomposition expansion to satisfy failing profile constraints | +| GR-021 | Impact-specific native decomposition coverage not enforced uniformly | `docs/native_decomposition_impact_list_2026-02-26.md`, `tools/mcp/profiles/native_decomposition_impact_profiles.json`, `logs/taskitem_runs/TEST_ONLY_sprint241_fullstack_impact_20260226_150416/00_summary.json`, `logs/taskitem_runs/TEST_ONLY_sprint241_native_impact_aggregate_20260226/native_impact_coverage_aggregate.json`, `logs/taskitem_runs/TEST_ONLY_sprint242_impact_remediation_loop_20260226/remediation_loop_summary.json` | `partial` | Sprint 241 added one-by-one impact profiles and a pipeline-integrated native impact coverage gate (`native_impact_coverage`). Sprint 242 added profile-driven remediation synthesis and rerun loop. Current hard fullstack sample remains unchanged after one remediation pass (`failing_profile_count 7 -> 7`), so capability closure is still pending. | Implement profile-specific decomposition operators that synthesize concrete task bundles, not only constraints | ## What Was Covered Today (Sprints 175-184) diff --git a/docs/progress_log_2026-02-26.md b/docs/progress_log_2026-02-26.md index 3ec8ea3..7c3d9f4 100644 --- a/docs/progress_log_2026-02-26.md +++ b/docs/progress_log_2026-02-26.md @@ -204,3 +204,17 @@ - `logs/taskitem_runs/TEST_ONLY_sprint241_impact_gate_20260226_150404/06_native_impact_coverage.json` - `logs/taskitem_runs/TEST_ONLY_sprint241_fullstack_impact_20260226_150416/00_summary.json` - `logs/taskitem_runs/TEST_ONLY_sprint241_native_impact_aggregate_20260226/native_impact_coverage_aggregate.json` + +## Sprint 242 Added (Same Day) + +- Added remediation synthesis + rerun tooling for failing impact profiles: + - `tools/mcp/synthesize_native_impact_remediation_requirements.py` + - `tools/mcp/run_native_impact_remediation_loop.sh` +- Pipeline now accepts externally supplied extra normalized requirements: + - `WSTONE_EXTRA_NORMALIZED_REQUIREMENTS_FILE` + - summary packet: `extra_normalized_requirements` +- Dated remediation loop artifacts: + - `logs/taskitem_runs/TEST_ONLY_sprint242_impact_remediation_loop_20260226/remediation_loop_summary.json` + - `logs/taskitem_runs/TEST_ONLY_sprint242_impact_remediation_loop_20260226/extra_normalized_requirements.json` +- Current measured loop result on hard fullstack sample: + - `failing_profile_count 7 -> 7` (wiring complete, capability uplift still pending) diff --git a/docs/sprint242_execution_tracker_2026-02-26.md b/docs/sprint242_execution_tracker_2026-02-26.md new file mode 100644 index 0000000..93c9d51 --- /dev/null +++ b/docs/sprint242_execution_tracker_2026-02-26.md @@ -0,0 +1,35 @@ +# Sprint 242 Execution Tracker - 2026-02-26 + +## Scope +- `sprint242_plan.md` + +## Implemented + +Pipeline enhancement in `tools/mcp/run_sprint_taskitem_pipeline.sh`: +- Added `WSTONE_EXTRA_NORMALIZED_REQUIREMENTS_FILE` input. +- Validates file exists and contains JSON array. +- Appends extra requirements into `NORMALIZED_REQS` before generation. +- Summary now includes `extra_normalized_requirements`. + +New remediation tooling: +- `tools/mcp/synthesize_native_impact_remediation_requirements.py` + - Converts failing profile checks into deterministic constraint requirements. +- `tools/mcp/run_native_impact_remediation_loop.sh` + - Runs baseline coverage pass. + - Synthesizes extra requirements from failing checks. + - Reruns pipeline with injected requirements. + - Emits before/after delta summary. + +## Baseline Loop Artifact + +- `logs/taskitem_runs/TEST_ONLY_sprint242_impact_remediation_loop_20260226/remediation_loop_summary.json` +- `logs/taskitem_runs/TEST_ONLY_sprint242_impact_remediation_loop_20260226/extra_normalized_requirements.json` + +Observed result on fullstack sample: +- before: `failing_profile_count=7` +- after: `failing_profile_count=7` +- delta: `0` (remediation wiring is operational; generator capability uplift still required) + +## Explicit Completion Signal + +- Sprint 242: `DONE` (implemented + end-to-end remediation loop verified) diff --git a/editor/src/Sprint242IntegrationSummary.h b/editor/src/Sprint242IntegrationSummary.h new file mode 100644 index 0000000..94104e2 --- /dev/null +++ b/editor/src/Sprint242IntegrationSummary.h @@ -0,0 +1,6 @@ +#pragma once + +// Sprint 242 integration summary: +// - Added profile-driven remediation requirement synthesis from failing impact checks. +// - Added deterministic two-pass remediation loop wrapper. +// - Pipeline now supports externally supplied extra normalized requirements. diff --git a/sprint242_plan.md b/sprint242_plan.md new file mode 100644 index 0000000..86400ce --- /dev/null +++ b/sprint242_plan.md @@ -0,0 +1,11 @@ +# Sprint 242 Plan: Profile-Driven Native Impact Remediation Loop + +## Goal +Automatically convert failing impact-coverage profiles into deterministic extra requirements and rerun native decomposition to attempt closure. + +## Steps +- Step 2254: Add remediation requirement synthesizer from failing impact checks. +- Step 2255: Add two-pass remediation loop wrapper (baseline -> synthesize -> rerun). +- Step 2256: Add pipeline support for externally supplied extra normalized requirements. +- Step 2257: Emit loop before/after delta artifact. +- Step 2258: Add `Sprint242IntegrationSummary.h` and execution tracker. diff --git a/tools/mcp/run_native_impact_remediation_loop.sh b/tools/mcp/run_native_impact_remediation_loop.sh new file mode 100755 index 0000000..272b747 --- /dev/null +++ b/tools/mcp/run_native_impact_remediation_loop.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +SPEC_PATH="${1:-}" +if [[ -z "$SPEC_PATH" ]]; then + echo "usage: $0 [out_dir]" >&2 + exit 2 +fi +if [[ ! -f "$SPEC_PATH" ]]; then + echo "error: spec not found: $SPEC_PATH" >&2 + exit 2 +fi + +OUT_DIR="${2:-$ROOT_DIR/logs/taskitem_runs/TEST_ONLY_native_impact_remediation_loop_$(date +%Y%m%d_%H%M%S)}" +mkdir -p "$OUT_DIR" + +BASE_NAME="$(basename "$SPEC_PATH" .md)" + +run_pipeline_once() { + local extra_file="$1" + if [[ -n "$extra_file" ]]; then + WSTONE_NATIVE_IMPACT_COVERAGE_GATE=1 \ + WSTONE_NATIVE_IMPACT_COVERAGE_ENFORCE=0 \ + WSTONE_EXTRA_NORMALIZED_REQUIREMENTS_FILE="$extra_file" \ + "$ROOT_DIR/tools/mcp/run_sprint_taskitem_pipeline.sh" "$SPEC_PATH" >/dev/null + else + WSTONE_NATIVE_IMPACT_COVERAGE_GATE=1 \ + WSTONE_NATIVE_IMPACT_COVERAGE_ENFORCE=0 \ + "$ROOT_DIR/tools/mcp/run_sprint_taskitem_pipeline.sh" "$SPEC_PATH" >/dev/null + fi + ls -1dt "$ROOT_DIR/logs/taskitem_runs/${BASE_NAME}_"* | head -n1 +} + +RUN1_DIR="$(run_pipeline_once "")" +RUN1_REPORT="$RUN1_DIR/06_native_impact_coverage.json" +if [[ ! -f "$RUN1_REPORT" ]]; then + echo "error: missing first-run coverage report: $RUN1_REPORT" >&2 + exit 3 +fi + +REQ_FILE="$OUT_DIR/extra_normalized_requirements.json" +python3 "$ROOT_DIR/tools/mcp/synthesize_native_impact_remediation_requirements.py" \ + --coverage-report "$RUN1_REPORT" \ + --profiles "${WSTONE_NATIVE_IMPACT_COVERAGE_PROFILES:-$ROOT_DIR/tools/mcp/profiles/native_decomposition_impact_profiles.json}" \ + --out "$REQ_FILE" >/dev/null + +RUN2_DIR="$(run_pipeline_once "$REQ_FILE")" +RUN2_REPORT="$RUN2_DIR/06_native_impact_coverage.json" +if [[ ! -f "$RUN2_REPORT" ]]; then + echo "error: missing second-run coverage report: $RUN2_REPORT" >&2 + exit 4 +fi + +jq -n \ + --arg run1 "$RUN1_DIR" \ + --arg run2 "$RUN2_DIR" \ + --arg req_file "$REQ_FILE" \ + --argjson first "$(cat "$RUN1_REPORT")" \ + --argjson second "$(cat "$RUN2_REPORT")" \ + '{ + status:"ok", + run1:$run1, + run2:$run2, + remediation_requirements_file:$req_file, + before:{active_profile_count:$first.active_profile_count,failing_profile_count:$first.failing_profile_count,status:$first.status}, + after:{active_profile_count:$second.active_profile_count,failing_profile_count:$second.failing_profile_count,status:$second.status}, + delta:{failing_profile_count: (($second.failing_profile_count // 0) - ($first.failing_profile_count // 0))} + }' | tee "$OUT_DIR/remediation_loop_summary.json" diff --git a/tools/mcp/run_sprint_taskitem_pipeline.sh b/tools/mcp/run_sprint_taskitem_pipeline.sh index 482cfd4..34c6187 100755 --- a/tools/mcp/run_sprint_taskitem_pipeline.sh +++ b/tools/mcp/run_sprint_taskitem_pipeline.sh @@ -42,6 +42,7 @@ NATIVE_DECOMP_TARGET_MIN_TASKS="${WSTONE_NATIVE_DECOMP_TARGET_MIN_TASKS:-5}" NATIVE_IMPACT_COVERAGE_GATE="${WSTONE_NATIVE_IMPACT_COVERAGE_GATE:-0}" NATIVE_IMPACT_COVERAGE_ENFORCE="${WSTONE_NATIVE_IMPACT_COVERAGE_ENFORCE:-0}" NATIVE_IMPACT_COVERAGE_PROFILES="${WSTONE_NATIVE_IMPACT_COVERAGE_PROFILES:-$ROOT_DIR/tools/mcp/profiles/native_decomposition_impact_profiles.json}" +EXTRA_NORMALIZED_REQUIREMENTS_FILE="${WSTONE_EXTRA_NORMALIZED_REQUIREMENTS_FILE:-}" CAPABILITY_SIGNALS_JSON="${WSTONE_CAPABILITY_SIGNALS_JSON:-}" if [[ -z "$CAPABILITY_SIGNALS_JSON" ]]; then CAPABILITY_SIGNALS_JSON='{}' @@ -97,6 +98,7 @@ NATIVE_DECOMP_GATE_JSON='{}' NATIVE_REASON_ENRICHMENT_JSON='{}' NATIVE_DECOMP_RETRY_JSON='{}' NATIVE_IMPACT_COVERAGE_JSON='{}' +EXTRA_NORMALIZED_REQUIREMENTS_JSON='[]' if [[ "$SEMANTIC_PLANNING_BRIDGE" == "1" ]]; then python3 "$ROOT_DIR/tools/mcp/markdown_to_semantic_annotations.py" \ --spec "$INPUT_FILE" \ @@ -286,6 +288,18 @@ if [[ "$SEMANTIC_PLANNING_BRIDGE" == "1" && "$SEMANTIC_REQUIREMENT_INJECTION" == NORMALIZED_REQS="$(jq -nc --argjson base "$NORMALIZED_REQS" --argjson sem "$SEM_REQS" '$base + $sem')" SEMANTIC_REQUIREMENT_INJECTION_JSON="$(jq -nc --argjson sem "$SEM_REQS" '{injected_count: ($sem|length), injected_requirements:$sem}')" fi +if [[ -n "$EXTRA_NORMALIZED_REQUIREMENTS_FILE" ]]; then + if [[ ! -f "$EXTRA_NORMALIZED_REQUIREMENTS_FILE" ]]; then + echo "error: extra normalized requirements file not found: $EXTRA_NORMALIZED_REQUIREMENTS_FILE" >&2 + exit 13 + fi + if ! jq -e 'type == "array"' "$EXTRA_NORMALIZED_REQUIREMENTS_FILE" >/dev/null 2>&1; then + echo "error: extra normalized requirements file must be a JSON array: $EXTRA_NORMALIZED_REQUIREMENTS_FILE" >&2 + exit 14 + fi + EXTRA_NORMALIZED_REQUIREMENTS_JSON="$(cat "$EXTRA_NORMALIZED_REQUIREMENTS_FILE")" + NORMALIZED_REQS="$(jq -nc --argjson base "$NORMALIZED_REQS" --argjson extra "$EXTRA_NORMALIZED_REQUIREMENTS_JSON" '$base + $extra')" +fi CONFLICTS="$(printf '%s' "$INTAKE_JSON" | jq '.conflicts // []')" GEN_ARGS="$(jq -nc --argjson nr "$NORMALIZED_REQS" --argjson cf "$CONFLICTS" --arg strict "$STRICT_EXECUTION_CONTRACT" \ '{normalizedRequirements:$nr,conflicts:$cf,strictExecutionContract:($strict == "1")}')" @@ -514,6 +528,7 @@ SUMMARY_JSON="$(jq -nc \ --argjson native_decomposition_gate "$NATIVE_DECOMP_GATE_JSON" \ --argjson native_reason_enrichment "$NATIVE_REASON_ENRICHMENT_JSON" \ --argjson native_decomposition_retry "$NATIVE_DECOMP_RETRY_JSON" \ + --argjson extra_normalized_requirements "$EXTRA_NORMALIZED_REQUIREMENTS_JSON" \ --argjson intake "$INTAKE_JSON" \ --argjson generated "$GEN_JSON" \ --argjson queue "$QUEUE_JSON" \ @@ -534,6 +549,7 @@ SUMMARY_JSON="$(jq -nc \ native_decomposition_gate: $native_decomposition_gate, native_reason_enrichment: $native_reason_enrichment, native_decomposition_retry: $native_decomposition_retry, + extra_normalized_requirements: $extra_normalized_requirements, intake: { success: ($intake.success // false), normalized_requirement_count: (($intake.normalizedRequirements // [])|length), diff --git a/tools/mcp/synthesize_native_impact_remediation_requirements.py b/tools/mcp/synthesize_native_impact_remediation_requirements.py new file mode 100755 index 0000000..245ba75 --- /dev/null +++ b/tools/mcp/synthesize_native_impact_remediation_requirements.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +import argparse +import json +from pathlib import Path +from typing import Dict, List + + +def load_json(path: Path) -> Dict: + with path.open("r", encoding="utf-8") as f: + return json.load(f) + + +def write_json(path: Path, obj) -> None: + with path.open("w", encoding="utf-8") as f: + json.dump(obj, f, indent=2, sort_keys=True) + f.write("\n") + + +def make_requirement(profile: Dict, missing: List[str], idx: int) -> Dict: + pid = str(profile.get("id", f"profile_{idx}")) + req_ops = profile.get("required_prerequisite_ops") or [] + req_contract = profile.get("required_execution_contract") or [] + reason_keys = profile.get("required_reason_keywords") or [] + min_tasks = int(profile.get("min_native_task_count", 0) or 0) + + text = ( + f"native decomposition remediation for {pid}: " + f"produce at least {min_tasks} concrete taskitems; " + f"ensure prerequisiteOps include {', '.join(req_ops) if req_ops else 'none'}; " + f"ensure executionContract includes {', '.join(req_contract) if req_contract else 'none'}; " + f"ensure reasons include keywords {', '.join(reason_keys) if reason_keys else 'none'}; " + f"close missing checks: {', '.join(missing) if missing else 'none'}." + ) + + return { + "requirementId": f"native-impact-remediation-{pid}", + "kind": "constraint", + "normalizedText": text, + "anchor": "native_impact_coverage_remediation", + "sourceLine": 0, + "ambiguous": False, + } + + +def main() -> int: + p = argparse.ArgumentParser(description="Synthesize extra normalized requirements from failing native impact coverage checks.") + p.add_argument("--coverage-report", required=True) + p.add_argument("--profiles", required=True) + p.add_argument("--out", required=True) + args = p.parse_args() + + coverage = load_json(Path(args.coverage_report)) + profiles_doc = load_json(Path(args.profiles)) + by_id = {str(x.get("id", "")): x for x in (profiles_doc.get("profiles") or [])} + + out: List[Dict] = [] + i = 0 + for check in coverage.get("checks", []): + if check.get("passed", False): + continue + pid = str(check.get("id", "")) + profile = by_id.get(pid, {"id": pid}) + missing = [str(m) for m in (check.get("missing") or [])] + out.append(make_requirement(profile, missing, i)) + i += 1 + + write_json(Path(args.out), out) + print(json.dumps({"status": "ok", "count": len(out), "out": args.out}, sort_keys=True)) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main())