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
7 changes: 7 additions & 0 deletions .changepacks/changepack_log_CHxB9HNH9RXXboczwgIMk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"changes": {
"Cargo.toml": "Minor"
},
"note": "Add a per-state and per-requirement verification matrix to devup_feature_trace: Figma-vs-implementation state comparisons, requirement verdicts with scope and evidence, Figma data gaps that block design-match claims, change impact, a user review report and an ordered follow-up for unfinished verification",
"date": "2026-11-28T14:35:15.989000Z"
}
79 changes: 75 additions & 4 deletions crates/devup-mcp/src/server/feature_trace/run.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@


#[cfg(test)]
pub(super) async fn run(
input: FeatureTraceInput,
artifacts: &ArtifactStore,
) -> Result<Value, DevupError> {
run_with(input, artifacts, None).await
}

/// The trace, with the output policy that lets state checks reuse
/// devup_visual_compare for their optional pixel comparisons.
pub(super) async fn run_with(
input: FeatureTraceInput,
artifacts: &ArtifactStore,
policy: Option<&super::output::OutputPolicy>,
) -> Result<Value, DevupError> {
let max_items = input.max_items.unwrap_or(100);
if !(1..=200).contains(&max_items) {
Expand Down Expand Up @@ -34,6 +43,11 @@ pub(super) async fn run(
]
.into_iter()
.any(supplied)
&& input.state_checks.is_empty()
&& !input
.requirements
.iter()
.any(|r| !r.targets.is_empty() || supplied(&r.figma_node_id))
{
return Ok(json!({"status":"REFUSED","message":ACCEPTED}));
}
Expand Down Expand Up @@ -447,11 +461,22 @@ pub(super) async fn run(
"implementedEvidence":implemented.get(*state),
"reason":"Presence records explicit state declarations or App Router boundary components only. Missing evidence is unknown, never assumed absent; runtime coverage requires tests."})).collect::<Vec<_>>();
let acceptance=input.acceptance_criteria.iter().map(|criterion|json!({"criterion":criterion,"status":"UNVERIFIED","reason":"Caller acceptance text is preserved without semantic interpretation; supply tests or inspect the linked evidence."})).collect::<Vec<_>>();
let summary = summarize(
let mut summary = summarize(
&chain,
&anchor_status,
ui["truncation"]["truncated"] == true,
);
let verification = verification(&input, &ui, &root, artifacts, policy).await;
if let Some(claims) = verification.as_ref().map(|v| &v["claims"]) {
let required = summary["required"].as_array_mut().unwrap();
for reason in array(&claims["completionBlockedBy"]) {
required.push(json!(format!(
"Do not claim a design match or a finished verification: {}",
text(reason)
)));
}
summary["verification"] = json!({"designMatch":claims["designMatch"],"verificationComplete":claims["verificationComplete"]});
}
let mut navigation_graph = super::navigation::graph(
&design.evidence["interactiveCandidates"],
&navigation_sources,
Expand All @@ -469,7 +494,7 @@ pub(super) async fn run(
Ok(bound(
json!({"status":"OK","summary":summary,"projectRoot":root,"anchors":{"routePath":input.route_path,"figmaNodeId":input.figma_node_id,"artifactId":input.artifact_id,"operationId":input.operation_id,"apiPath":input.api_path,"method":input.method,"componentPath":input.component_path,"tableName":input.table_name},"requirement":input.requirement,"acceptanceMatrix":acceptance,
"chain":chain,"artifacts":traced_artifacts.into_values().collect::<Vec<_>>(),"sourceOwnership":ownership,"reuseCandidates":reuse,"designContract":comparisons,"requiredStates":states,
"navigationGraph":navigation_graph,
"navigationGraph":navigation_graph,"verification":verification,
"designEvidence":design.evidence,"designDiagnostics":design.diagnostics,"diagnostics":diagnostics,
"inventoryEvidence":{"uiTruncation":ui["truncation"],"uiLimits":ui["limits"],"uiDiagnostics":ui["diagnostics"],"uiExcludedPaths":ui["excludedPaths"],"unparsedFiles":ui["unparsedFiles"],"api":{"found":api["found"],"excludedPaths":api["excludedPaths"],"authorityNote":api["authorityNote"],"issues":array(&api["specs"]).iter().filter(|v|v.get("parseError").is_some()||v.get("readError").is_some()).collect::<Vec<_>>()},
"db":{"found":db["found"],"excludedPaths":db["excludedPaths"],"authorityNote":db["authorityNote"],"issues":array(&db["tables"]).iter().filter(|v|v.get("parseError").is_some()||v.get("readError").is_some()).collect::<Vec<_>>()}
Expand All @@ -478,6 +503,52 @@ pub(super) async fn run(
max_items,
))
}
/// The verification matrix over the caller's states, requirements, gaps and changes.
async fn verification(
input: &FeatureTraceInput,
ui: &Value,
root: &Path,
artifacts: &ArtifactStore,
policy: Option<&super::output::OutputPolicy>,
) -> Option<Value> {
use super::verification_matrix::{MatrixContext, MatrixInput, build};
let matrix = MatrixInput {
state_checks: &input.state_checks,
requirements: &input.requirements,
design_gaps: &input.design_gaps,
changes: &input.changes,
component_path: input.component_path.as_deref(),
};
if matrix.is_empty() {
return None;
}
let lookup = match input
.artifact_id
.as_deref()
.filter(|id| !id.trim().is_empty())
{
Some(id) => Some(
artifacts
.get(id)
.await
.ok_or("artifactId is missing or expired; the design data could not be read."),
),
None => None,
};
let payload = lookup
.as_ref()
.and_then(|l| l.as_ref().ok())
.map(|l| l.payload.clone());
let context = MatrixContext {
ui,
root,
payload: payload.as_deref(),
artifact_unavailable: lookup.and_then(|l| l.err()).map(str::to_owned),
policy,
store: artifacts,
};
build(&context, &matrix).await
}
/// Normalise a caller-supplied component path to the inventory's `a/b/c.tsx` form.
fn anchor_path(path: &str) -> String {
let unified = path.trim().replace('\\', "/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ fn bound(mut value: Value, max_items: usize) -> Value {
.as_object()
.unwrap()
.iter()
.filter(|(k, _)| !matches!(k.as_str(), "truncation" | "limits" | "status" | "summary"))
.filter(|(k, _)| !matches!(k.as_str(), "truncation" | "limits" | "status" | "summary" | "verification"))
.max_by_key(|(_, v)| v.to_string().len())
.map(|(k, _)| k.clone());
let Some(key) = key else {
Expand Down
67 changes: 67 additions & 0 deletions crates/devup-mcp/src/server/feature_trace_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,70 @@ async fn unreadable_or_escaping_component_anchor_is_a_required_fix() {
assert!(!v["summary"]["required"].as_array().unwrap().is_empty());
}
}

#[tokio::test]
async fn state_checks_are_explicit_anchors_and_gate_completion_claims() {
let f = Fixture::new();
let v = f
.trace(json!({"stateChecks":[{"target":"components/UserForm.tsx","routePath":"/users","state":"hover",
"design":{"width":10},"implementation":{"width":10}}]}))
.await;
assert_eq!(v["status"], "OK", "{v}");
let state = &v["verification"]["stateGroups"][0]["states"][0];
assert_eq!(state["verdict"], "unverified");
assert_eq!(state["browserVerificationRequired"], true);
assert_eq!(v["summary"]["verification"]["designMatch"], "blocked");
assert!(
v["summary"]["required"]
.as_array()
.unwrap()
.iter()
.any(|r| r
.as_str()
.unwrap()
.starts_with("Do not claim a design match"))
);
let impact = &v["verification"]["changeImpact"][0];
assert_eq!(impact["path"], "components/UserForm.tsx");
assert_eq!(impact["affectedScreens"], json!(["/users"]));
}

#[tokio::test]
async fn untargeted_requirements_stay_refused_and_old_calls_are_unchanged() {
let f = Fixture::new();
let refused = f
.trace(json!({"requirements":[{"id":"R","text":"anchorless prose"}]}))
.await;
assert_eq!(refused["status"], "REFUSED");
let plain = f.trace(json!({"routePath":"/users"})).await;
assert!(plain["verification"].is_null());
assert!(plain["summary"].get("verification").is_none());
}

#[tokio::test]
async fn a_missing_artifact_is_a_design_gap_for_state_checks() {
let f = Fixture::new();
let v = f
.trace(json!({"artifactId":"gone","stateChecks":[{"target":"Button","state":"default","figmaNodeId":"1:1",
"design":{"width":1},"implementation":{"width":1},"implementationSource":"browser"}]}))
.await;
assert_eq!(v["verification"]["designData"]["complete"], false);
assert_eq!(
v["verification"]["designData"]["gaps"][0]["kind"],
"read-failed"
);
assert_eq!(v["verification"]["claims"]["designMatch"], "blocked");
}

#[test]
fn verification_inputs_reject_unknown_fields() {
let parsed = serde_json::from_value::<FeatureTraceInput>(
json!({"stateChecks":[{"target":"x","state":"hover","bogus":1}]}),
);
assert!(parsed.is_err());
let parsed = serde_json::from_value::<FeatureTraceInput>(
json!({"requirements":[{"id":"r","text":"t","check":"interaction","targets":[{"routePath":"/"}]}]}),
)
.unwrap();
assert_eq!(parsed.requirements.len(), 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl DevupServer {
&self,
Parameters(input): Parameters<tools::FeatureTraceInput>,
) -> Result<CallToolResult, ErrorData> {
let result = feature_trace::run(input, &self.artifacts)
let result = feature_trace::run_with(input, &self.artifacts, Some(&self.output_policy))
.await
.map_err(to_mcp_error)?;
Ok(tool_result(result))
Expand Down
2 changes: 2 additions & 0 deletions crates/devup-mcp/src/server/mod_parts/state_and_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ mod validation;
mod validation_guidance;
#[path = "../verdict_scope.rs"]
mod verdict_scope;
#[path = "../verification_matrix.rs"]
mod verification_matrix;
#[path = "../visual_compare.rs"]
mod visual_compare;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,62 @@ These rules apply to every plan this workflow produces.

Treat `DEVUP_DESIGN_COMPONENT_WIDTH_MISMATCH` as an automatically resolved design placement error. The screen plan records the strict same-width majority, the expected master and a correct sibling instance, plus native-node PNG comparisons when available (otherwise `render=unavailable`). Follow that assumption without another question. Header/Footer/Nav remains one responsive component across widths, not a second variant. Audit planning substitutes the correct sibling's height and children at screen width and the suspect's original y position. The original whole-page PNG still depicts the design error and must not be accepted as a corrected-page visual reference.

## Verify states and requirements, report for review

Use `devup_feature_trace` as the verification matrix. Static source reading and
browser observation are kept apart everywhere: a value read from source is
`static`, and static evidence never verifies rendered behaviour.

- **Before implementing**, read `reuseCandidates` (existing components and
style patterns), `verification.changeImpact` (every screen that imports a
component you will change: `shared` means the change reaches all of them) and
`verification.configScope` (shared files such as `devup.json` or the root
layout versus screen-only files). Put a value only one screen needs in that
screen's files.
- **States.** Send one `stateChecks` row per state of a component or screen
(default, hover, active, focus, selected, disabled, ...): `target`,
`routePath`, `state`, the Figma `figmaNodeId` of that state (with
`artifactId` its size, position, colour, border and typography are read from
the snapshot; component-set variants become `expectedStates`), the measured
`implementation` values and `implementationSource` (`browser` when read from
computed style in a browser). Add `visual` (the `devup_visual_compare` input)
only when a pixel comparison is needed. A state without a design or a capture,
an expected state nobody checked, and a static-only state are `unverified`,
never a pass. Capture only to compare or to analyse a failure.
- **Requirements.** Send each design spec card (`origin: design-spec-card`)
and user requirement as `requirements` with its `targets` (route, component,
state, Figma node) and `check` kind. Verdicts are `verified`, `unverified`
or `not-applicable` with `reason`, `evidence` and `scope`. Interaction and
visual requirements need browser, automated-test or manual evidence; static
passes leave them `browser-verification-required`. A requirement reaching
several screens (`scope.multiScreen`, `sharedComponents`) needs evidence on
every screen in `scope.screens`.
- **Incomplete Figma data.** `verification.designData.gaps` lists each missing
node or property with its cause (from the artifact, plus `designGaps` you add
for failed reads or exports) and `cannotJudge` names the screens, states and
requirements it blocks. While `claims.designMatch` or
`claims.verificationComplete` is `blocked`, do not report a design match or
a finished verification.
- **Review report.** Pass `changes` (summary, route, files, requirementIds).
`reviewReport.changes` gives the user, per change, the path to open, the
steps, the expected result and the results split into automated, browser,
manual and static. Captures appear only for failed visual comparisons; write
a separate capture summary only when the user asks for one.
- **When a verification cannot be finished**, follow `followUp.order`:
1. find the cause; fix what is inside the request's scope and verify again
(`followUp.fixInScope` carries the next action);
2. finish other work that does not depend on it;
3. only when a user permission or an external environment change is
required, ask once, briefly: the unfinished verification and the cause
found so far, the recommended fix and what it would verify, and the action
or permission needed (record it as `blocker` with `cause`,
`recommendation`, `verifies`, `userAction`; `followUp.askUser` names any
field still missing);
4. keep doing unaffected work while waiting;
5. report what cannot be resolved with the attempts made and the remaining
constraint (`blocker.kind: unresolvable` with `attempts`; listed in
`followUp.unresolved`).

## Delivery quality

Apply `developmentContract` and `behaviorPlan` on every export. Read the bundled
Expand Down
4 changes: 2 additions & 2 deletions crates/devup-mcp/src/server/skills/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
"documents": [
{
"path": "SKILL.md",
"bytes": 48735,
"sha256": "5fe7b752fb5f830e8efda50cb33e1e6ae23db22d6725544139d4fc70401f83d3"
"bytes": 52386,
"sha256": "9e97e444543da65a55d2957efe3d614339ca79627f047dd6d672a89829ac906a"
}
],
"sourceUrl": "https://github.com/dev-five-git/devup-mcp/blob/HEAD/crates/devup-mcp/src/server/skills/devup-implementation-plan",
Expand Down
2 changes: 1 addition & 1 deletion crates/devup-mcp/src/server/text/devup-feature-trace.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Read-only cross-layer feature slice and acceptance matrix from explicit anchors: routePath, figmaNodeId/artifactId, operationId or apiPath+method, componentPath, tableName. Refuses anchorless prose. Returns evidence-backed or UNVERIFIED hops, generated-source ownership, ranked UI reuse, literal design binding versus request/response fields, required-state coverage, and named truncation caps. Optional requirement/acceptanceCriteria are echoed without semantic interpretation. componentTsx is a caller-declared Figma export; artifactId uses the cached snapshot. Static parsing never proves runtime behavior.
Read-only cross-layer feature slice and acceptance matrix from explicit anchors: routePath, figmaNodeId/artifactId, operationId or apiPath+method, componentPath, tableName. Refuses anchorless prose. Returns evidence-backed or UNVERIFIED hops, generated-source ownership, ranked UI reuse, literal design binding versus request/response fields, required-state coverage, and named truncation caps. Optional requirement/acceptanceCriteria are echoed without semantic interpretation. componentTsx is a caller-declared Figma export; artifactId uses the cached snapshot. Static parsing never proves runtime behavior. Optional verification inputs (stateChecks, requirements, designGaps, changes) return verification: per-state groups comparing Figma size/position/colour/border/typography (from artifactId or design values) with implementation values, optional devup_visual_compare pixels, and expected component-set variant states; requirement verdicts verified/unverified/not-applicable with evidence, screen/component/state scope and browser-verification-required for interaction or visual requirements proven only statically; Figma gaps (missing nodes/properties, failed reads/exports) with what they block; changeImpact and configScope; a reviewReport per change (path, steps, expected, automated/browser/manual/static results, captures only for failures); followUp in the order fix-in-scope, continue independent work, ask the user only for permissions or environment, keep working, report unresolved with attempts; and claims gating design-match and completion. Missing design or capture is unverified, never a pass. See devup://guide/usage section 17.
Loading
Loading