diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70e9728..3d8540a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,9 @@ jobs: test -d memory-bank - name: Validate priming manifests - run: ruby tools/validate-priming-manifests.rb template/memory-bank + run: | + ruby tools/validate-priming-manifests-test.rb + ruby tools/validate-priming-manifests.rb template/memory-bank - name: Lint template run: memory-bank-cli lint --scope-root template/memory-bank --entrypoint template/memory-bank/README.md diff --git a/docs/development.md b/docs/development.md index 2540ae6..e3a7aca 100644 --- a/docs/development.md +++ b/docs/development.md @@ -10,6 +10,7 @@ ```bash rg --files template/memory-bank +ruby tools/validate-priming-manifests-test.rb ruby tools/validate-priming-manifests.rb template/memory-bank memory-bank-cli lint --scope-root template/memory-bank --entrypoint template/memory-bank/README.md memory-bank-cli doctor --profile template diff --git a/template/memory-bank/flows/templates/feature/implementation-plan.md b/template/memory-bank/flows/templates/feature/implementation-plan.md index da7c566..4a66028 100644 --- a/template/memory-bank/flows/templates/feature/implementation-plan.md +++ b/template/memory-bank/flows/templates/feature/implementation-plan.md @@ -89,12 +89,19 @@ Grounding выполняется до sequencing против конкретно Перед первым write implementing agent читает только этот manifest и проверяет, что рабочая tree начинается с grounded repository revision выше. Это исполняемая инструкция, а не пересказ `GRND-*` facts: перечисляй concrete -repo-relative paths или stable external sources в порядке чтения. Category, -glob, `TODO`, предполагаемый path и «изучи релевантное» не допускаются. +repo-relative paths или stable external sources в порядке чтения. Для каждого +input укажи точную section/symbol, подтверждающий `GRND-*`, цель чтения и +`STEP-*`, до которого input обязателен. Category, glob, `TODO`, предполагаемый +path, unresolved placeholder и «изучи релевантное» не допускаются. -1. `memory-bank/domain/.md` -2. `path/to/existing/module` -3. `path/to/existing/tests` +| Order | Exact path / stable source | Section / symbol | Grounding refs | Purpose | Required before | +| --- | --- | --- | --- | --- | --- | +| `1` | `memory-bank/domain/example-rule.md` | `# Example Rule` | `GRND-01` | Подтвердить применимое domain rule | `STEP-01` | +| `2` | `path/to/existing/module` | `ExistingService` | `GRND-01` | Подтвердить текущий implementation pattern | `STEP-01` | +| `3` | `path/to/existing/tests` | `ExistingServiceTest` | `GRND-02` | Подтвердить test conventions и regression surface | `STEP-02` | + +Замени все example rows фактическими inputs плана. Один input может ссылаться +на несколько `GRND-*` и `STEP-*`; перечисли их явно. Перед первым write выполни `git rev-parse HEAD` и сравни с grounded immutable revision. Если revision расходится или один из перечисленных inputs недоступен, diff --git a/tools/validate-priming-manifests-test.rb b/tools/validate-priming-manifests-test.rb new file mode 100644 index 0000000..a614f05 --- /dev/null +++ b/tools/validate-priming-manifests-test.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require "fileutils" +require "minitest/autorun" +require "pathname" +require "tmpdir" +require "yaml" + +require_relative "validate-priming-manifests" + +class PrimingManifestValidatorTest < Minitest::Test + def test_rejects_absolute_remainder_that_points_outside_scope + Dir.mktmpdir do |directory| + root = Pathname(directory) + scope_root = root.join("memory-bank") + manifest_directory = scope_root.join("flows/priming") + FileUtils.mkdir_p(manifest_directory) + + outside_file = root.join("outside.md") + outside_file.write("outside scope") + manifest_directory.join("sample.yaml").write( + { + "version" => 1, + "process" => "sample", + "stages" => { + "entry" => ["memory-bank/#{outside_file}"] + } + }.to_yaml + ) + + result = nil + _stdout, stderr = capture_io do + result = PrimingManifestValidator.new(scope_root).run + end + + refute result + assert_includes stderr, "must remain relative under memory-bank/" + end + end +end diff --git a/tools/validate-priming-manifests.rb b/tools/validate-priming-manifests.rb index 57afe60..17f43b3 100644 --- a/tools/validate-priming-manifests.rb +++ b/tools/validate-priming-manifests.rb @@ -114,7 +114,13 @@ def validate_input(path, stage, input, template:) end relative = input.delete_prefix("memory-bank/") - if Pathname(relative).each_filename.include?("..") + relative_path = Pathname(relative) + if relative_path.absolute? + add_error(path, "stage #{stage.inspect}: #{input.inspect} must remain relative under memory-bank/") + return + end + + if relative_path.each_filename.include?("..") add_error(path, "stage #{stage.inspect}: #{input.inspect} escapes the scope root") return end @@ -169,5 +175,7 @@ def finish end end -scope_root = ARGV.fetch(0, "template/memory-bank") -exit 1 unless PrimingManifestValidator.new(scope_root).run +if $PROGRAM_NAME == __FILE__ + scope_root = ARGV.fetch(0, "template/memory-bank") + exit 1 unless PrimingManifestValidator.new(scope_root).run +end