fix(cli): add reviewed command path fallbacks

This commit is contained in:
克谨
2026-08-04 09:35:48 +08:00
parent 9ce95db08e
commit cfaf161fc7
24 changed files with 2240 additions and 28 deletions
+40
View File
@@ -15,11 +15,13 @@ exec_tmp="$(policy_runtime_mktemp_dir dws-generated-drift)"
metadata_generator="$exec_tmp/schema-agent-metadata"
catalog_generator="$exec_tmp/schema-catalog"
param_aliases_generator="$exec_tmp/param-aliases"
command_fallbacks_generator="$exec_tmp/command-path-fallbacks"
trap 'rm -rf "$tmp" "$exec_tmp"' EXIT HUP INT TERM
go build -o "$metadata_generator" ./internal/generator/cmd_schema_agent_metadata
go build -a -o "$catalog_generator" ./internal/generator/cmd_schema_catalog
go build -o "$param_aliases_generator" ./internal/generator/cmd_param_aliases
go build -o "$command_fallbacks_generator" ./internal/generator/cmd_command_path_fallbacks
# CommandRegistry is a reviewed input, never a generated artifact. Keep an
# independent byte-for-byte guard around the ordinary downstream generators.
@@ -30,6 +32,11 @@ concepts_guard="$tmp/param_concepts.json"
concepts_schema_guard="$tmp/param_concepts.schema.json"
cp internal/cli/param_concepts.json "$concepts_guard"
cp internal/cli/param_concepts.schema.json "$concepts_schema_guard"
# Command path fallbacks and their editor schema are reviewed inputs too.
command_fallbacks_guard="$tmp/command_path_fallbacks.json"
command_fallbacks_schema_guard="$tmp/command_path_fallbacks.schema.json"
cp internal/cli/command_path_fallbacks.json "$command_fallbacks_guard"
cp internal/cli/command_path_fallbacks.schema.json "$command_fallbacks_schema_guard"
# Also guard human-authored metadata + selection hint trees.
metadata_guard="$tmp/metadata-hints"
selection_guard="$tmp/selection-hints"
@@ -42,6 +49,8 @@ catalog_tmp="$tmp/schema_catalog"
catalog_tmp_second="$tmp/schema_catalog-second"
param_aliases_tmp="$tmp/param_aliases_generated.go"
param_aliases_tmp_second="$tmp/param_aliases_generated-second.go"
command_fallbacks_tmp="$tmp/command_path_fallbacks_generated.go"
command_fallbacks_tmp_second="$tmp/command_path_fallbacks_generated-second.go"
"$metadata_generator" \
-root . \
@@ -79,6 +88,14 @@ fi
-root . \
-output "$param_aliases_tmp_second"
"$command_fallbacks_generator" \
-root . \
-output "$command_fallbacks_tmp"
"$command_fallbacks_generator" \
-root . \
-output "$command_fallbacks_tmp_second"
if ! diff -qr internal/cli/schema_command_registry "$registry_guard" >/dev/null; then
printf '%s\n' 'generation modified reviewed input internal/cli/schema_command_registry/' >&2
exit 1
@@ -94,6 +111,16 @@ if ! cmp -s internal/cli/param_concepts.schema.json "$concepts_schema_guard"; th
exit 1
fi
if ! cmp -s internal/cli/command_path_fallbacks.json "$command_fallbacks_guard"; then
printf '%s\n' 'generation modified reviewed input internal/cli/command_path_fallbacks.json' >&2
exit 1
fi
if ! cmp -s internal/cli/command_path_fallbacks.schema.json "$command_fallbacks_schema_guard"; then
printf '%s\n' 'generation modified reviewed input internal/cli/command_path_fallbacks.schema.json' >&2
exit 1
fi
if ! diff -qr internal/cli/schema_hints/metadata "$metadata_guard" >/dev/null; then
printf '%s\n' 'generation modified reviewed input internal/cli/schema_hints/metadata' >&2
exit 1
@@ -130,4 +157,17 @@ if ! cmp -s internal/cli/param_aliases_generated.go "$param_aliases_tmp"; then
exit 1
fi
if ! cmp -s "$command_fallbacks_tmp" "$command_fallbacks_tmp_second"; then
printf '%s\n' 'generated drift: consecutive command-path fallback generations are not byte-identical' >&2
diff -u "$command_fallbacks_tmp" "$command_fallbacks_tmp_second" || true
exit 1
fi
if ! cmp -s internal/cli/command_path_fallbacks_generated.go "$command_fallbacks_tmp"; then
printf '%s\n' 'generated drift: internal/cli/command_path_fallbacks_generated.go is stale' >&2
printf '%s\n' 'run: make generate-schema' >&2
diff -u internal/cli/command_path_fallbacks_generated.go "$command_fallbacks_tmp" || true
exit 1
fi
printf 'generated drift check: ok\n'