feat(#1416): formalize Resolution convention + agent-skills value envelope (Resolution Provenance P3) (#1425)

Narrows P3 of ADR-1411 (Resolution Provenance, epic #1411) based on an
adversarial fit-analysis that showed a single Resolution<T> envelope adopted
by agent-skills, capability-state, and capability-writer fails the deletion
test: configured/reason are meaningless for capability verbs, and
capability-writer's errors[] (operation-not-applied) cannot fold into
warnings[]. The only genuinely shared seam is warnings: string[].

Changes:

- src/resolution.cts: new pure types+builder leaf — exports Resolution<T>
  {value, configured, reason, warnings}, makeResolution<T>() builder, and
  AgentSkillsValue {block, skills_count}. No other src/ imports.

- src/init.cts: cmdAgentSkills --json IR gains additive value:{block,
  skills_count} field (built via makeResolution). All existing flat fields
  (agent_type, block, skills_count, warnings, configured, reason, source,
  degraded) are retained unchanged for back-compat.

- src/capability-state.cts: doc comment on ResolveCapabilityRuntimeStateResult
  naming it the canonical read-verb envelope. No JSON change.

- src/capability-writer.cts: doc comment on SetCapabilityStateResult naming it
  the canonical mutation-verb result (warnings=advisory, errors=operation-
  not-applied). No JSON change.

- CONTEXT.md: new ### Resolution Convention glossary entry after
  ### Resolution Provenance.

- docs/adr/1411-resolution-provenance.md: P3 narrowing amendment appended.

- tests/resolution.test.cjs: 9 unit tests for makeResolution (new).
- tests/agent-skills.test.cjs: 2 P3 tests for value.block/value.skills_count
  and back-compat of all flat fields.

All 277 tests pass (5 suites). npm run lint clean. All lint checks pass.

Part of #1411

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-18 07:44:52 -04:00
committed by GitHub
parent 484a5b7b86
commit b0c774c2e3
11 changed files with 261 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ const { checkAgentsInstalled } = agentInstallCheck;
// eslint-disable-next-line @typescript-eslint/no-require-imports -- git-base-branch.cjs is an export= CommonJS module
import gitBaseBranch = require('./git-base-branch.cjs');
const { gitWorktreeInfoInternal } = gitBaseBranch;
import { makeResolution } from './resolution.cjs';
const { output, error } = io;
const { loadConfig, loadConfigResolved } = configLoader;
@@ -2081,6 +2082,14 @@ function cmdAgentSkills(
const normalizedPaths = Array.isArray(skillPaths) ? skillPaths : [];
if (jsonMode) {
// Build the Resolution<AgentSkillsValue> envelope and embed .value additively.
// Flat fields are retained unchanged for back-compat; value formalises the
// Resolution convention (ADR-1411 P3, #1416). source/degraded remain
// config-provenance extras, outside the Resolution<T> envelope.
const resolution = makeResolution(
{ block: block || '', skills_count: normalizedPaths.length },
{ configured, reason, warnings: diagnostics.warnings },
);
output({
agent_type: agentType,
block: block || '',
@@ -2090,6 +2099,7 @@ function cmdAgentSkills(
reason,
source,
degraded,
value: resolution.value,
}, raw);
return;
}