Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/<rule>.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 недоступен,
Expand Down
40 changes: 40 additions & 0 deletions tools/validate-priming-manifests-test.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 11 additions & 3 deletions tools/validate-priming-manifests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Loading