Files
dingtalk-workspace-cli/scripts/policy/check-runtime-confirmation-truth.sh
玉澜 51dc237d8a feat: declarative LeafSpec command framework + schema generation/consumption separation
== LeafSpec command framework (internal/helpers/leaf.go) ==
Declarative command construction: LeafSpec/LeafFlag/NewLeafCommand with
Call (pluggable dispatch), LeafInt, PostMount, Trim, Validate. Collapses
per-command hand-written required validation, alias/env fallback, value
transform, and toolArgs assembly into one declarative path.

== devapp migration (28/31 commands) ==
All MCP-direct devapp leaf commands migrated to LeafSpec. Factories
(devAppCall/devAppCallCursor/devAppMeta) fold 33 repeated closures.
fakeDevAppRunner asserts toolArgs for every migrated command. 4 complex
commands (delete/robot submit/result/config) kept hand-written.

== Schema generation/consumption separation ==
- gen.go: isolated //go:generate pragmas from business code.
- command_meta.go: ResolveMeta(cliPath) -> CommandMeta{Identity,Safety,Selection}.
- command_safety.go: SafetyForCLIPath + RenderSafetyAnnotation; safety metadata
  flows from embedded catalog into --help output.
- calendar.go HelpFunc fix: delegates to root HelpFunc at help-time.
- schema_catalog_structure.go: closed catalog structure validation gate.

== Registry + catalog per-product sharding ==
schema_command_registry and schema_catalog split into per-product shards,
eliminating concurrent-PR merge conflicts on these files.

== MCP metadata refresh tool ==
cmd/fetch_mcp_metadata: iterates 26 MCP server endpoints, merges with previous
data for cross-server interface_ref. make fetch-mcp-metadata target.

== AGENTS.md ==
Documents the generation/consumption split.

Verified: make policy exit 0, drift zero, all tests pass.
2026-07-19 09:38:43 +08:00

83 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
set -eu
# Ensure catalog confirmation=user_required exactly matches metadata
# runtime_gate != none across schema_hints/metadata/*.json.
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)"
cd "$ROOT"
metadata_dir="internal/cli/schema_hints/metadata"
if [ ! -d "$metadata_dir" ]; then
printf '%s\n' "missing agent metadata directory: $metadata_dir" >&2
exit 1
fi
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT HUP INT TERM
# The release Catalog is committed as a per-product split; reassemble it into
# the single-document shape these jq queries consume.
catalog="$tmp/catalog-combined.json"
scripts/policy/with-catalog.sh >"$catalog"
jq -r '
.tools
| to_entries[]
| select((.value.runtime_gate // "none") != "none")
| .key
' "$metadata_dir"/*.json | sort -u >"$tmp/truth_gated"
jq -r '
.tools
| to_entries[]
| select(.value.confirmation == "user_required")
| .key
' "$catalog" | sort >"$tmp/catalog_required"
if ! cmp -s "$tmp/truth_gated" "$tmp/catalog_required"; then
printf '%s\n' 'catalog confirmation=user_required differs from schema_hints/metadata runtime_gate!=none set' >&2
printf '%s\n' 'update internal/cli/schema_hints/metadata/<product>.json runtime_gate/confirmation, then regenerate schema' >&2
diff -u "$tmp/truth_gated" "$tmp/catalog_required" || true
exit 1
fi
jq -s '
reduce .[] as $file ({};
. * (
$file.tools
| to_entries
| map({key: .key, value: (.value.runtime_gate // "none")})
| from_entries
)
)
' "$metadata_dir"/*.json >"$tmp/gates.json"
jq -r --slurpfile catalog "$catalog" '
. as $gate_map |
($catalog[0].tools) as $tools |
$gate_map
| to_entries[]
| .key as $canonical
| .value as $gate
| $tools[$canonical] as $tool
| select($tool != null)
| select(
if $gate == "none" then
$tool.confirmation != "not_required" or $tool.risk == "high" or $tool.effect == "destructive"
else
$tool.confirmation != "user_required"
end
)
| "\(.key)\tgate=\(.value)\teffect=\($tool.effect // "MISSING")\trisk=\($tool.risk // "MISSING")\tconfirmation=\($tool.confirmation // "MISSING")"
' "$tmp/gates.json" >"$tmp/gate_problems" || true
if [ -s "$tmp/gate_problems" ]; then
printf '%s\n' 'schema_hints/metadata runtime_gate disagree with catalog effect/risk/confirmation' >&2
cat "$tmp/gate_problems" >&2
exit 1
fi
printf '%s\n' "runtime confirmation truth ok ($(wc -l <"$tmp/truth_gated" | tr -d ' ') gated)"