wzyn20051216/matlab-agent-skills / skills/matlab-testing-ci
matlab-testing-ci
VerifiedMATLAB testing, validation, and CI workflow for matlab.unittest, MATLAB Test, Simulink Test, coverage, artifact generation, GitHub Actions, and open-source reproducibility. Use whenever MATLAB work needs verification, regression tests, CI, GitHub publication, or acceptance criteria.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.5 KB |
| assets/install-roots.json | config | 2.9 KB |
| scripts/mas_bench_record.m | other | 11.5 KB |
| scripts/mas_capability_check.m | other | 12.7 KB |
| scripts/mas_delivery_check.m | other | 32.2 KB |
| scripts/mas_grade.m | other | 5.5 KB |
| scripts/mas_phase43_grade.m | other | 12.4 KB |
| scripts/mas_ref_derive.m | other | 21.7 KB |
| scripts/mas_ref_spec.m | other | 6.3 KB |
| scripts/mas_refcheck.m | other | 10.7 KB |
| scripts/mas_skill_audit.m | other | 10.9 KB |
| scripts/mas_skill_install_audit.m | other | 13.7 KB |
| scripts/mas_verify_task.m | other | 3.9 KB |
| tests/test_bench.m | other | 5.4 KB |
| tests/test_capability.m | other | 6.1 KB |
| tests/test_delivery_check.m | other | 22.0 KB |
| tests/test_grade.m | other | 3.0 KB |
| tests/test_phase43_grade.m | other | 9.1 KB |
| tests/test_refcheck.m | other | 5.0 KB |
| tests/test_skill_install_audit.m | other | 8.7 KB |
tests/test_refcheck.m
View on GitHubfunction res = test_refcheck(verbose)
%TEST_REFCHECK The reference mechanism must reject bad values and tampered files.
%
% res = test_refcheck()
%
% A verifier that only ever says PASS is indistinguishable from no verifier. These
% cases feed it deliberately wrong values and a deliberately edited manifest, and
% require the correct rejection in each case.
if nargin < 1, verbose = true; end
here = fileparts(mfilename('fullpath'));
repo = fileparts(fileparts(fileparts(here)));
scr = fullfile(repo, 'skills', 'matlab-testing-ci', 'scripts');
addpath(scr);
manifest = fullfile(repo, 'evals', 'references', 'reference_manifest.json');
tmp = fullfile(tempdir, 'mas_refcheck_test');
if ~isfolder(tmp), mkdir(tmp); end
T = struct('name', {}, 'fn', {}, 'expect', {});
T(end+1) = tc('correct values pass', @() mas_verify_task('D3', ...
struct('magAtFc', -3.0103, 'magAt2Fc', -27.9657, 'stable', true, 'dcGain', 1)), 'PASS');
T(end+1) = tc('analog formula rejected', @() mas_verify_task('D3', ...
struct('magAtFc', -3.0103, 'magAt2Fc', -24.0998, 'stable', true, 'dcGain', 1)), 'FAIL');
T(end+1) = tc('dc gain 0.707 rejected', @() mas_verify_task('D3', ...
struct('magAtFc', -3.0103, 'magAt2Fc', -27.9657, 'stable', true, 'dcGain', 0.7071)), 'FAIL');
T(end+1) = tc('missing field -> UNDETERMINED', @() mas_verify_task('D3', ...
struct('magAtFc', -3.0103, 'stable', true)), 'UNDETERMINED');
T(end+1) = tc('unstable filter rejected', @() mas_verify_task('D3', ...
struct('magAtFc', -3.0103, 'magAt2Fc', -27.9657, 'stable', false, 'dcGain', 1)), 'FAIL');
T(end+1) = tc('row/col centroid swap rejected', @() mas_verify_task('D4', ...
struct('areas', [592 100], 'centroidBig', [20.5676 35.5541])), 'FAIL');
T(end+1) = tc('wrong peak time rejected', @() mas_verify_task('D5', ...
struct('overshoot', 16.3034, 'peakTime', 1.0, 'settlingTime', 4.0, 'stable', true)), 'FAIL');
T(end+1) = tc('unknown task id', @() mas_verify_task('ZZ9', struct()), 'UNDETERMINED');
nP = 0;
if verbose, fprintf('=== reference verifier tests ===\n'); end
R = struct('case', {}, 'got', {}, 'pass', {});
for k = 1:numel(T)
t = T(k);
r = t.fn();
ok = strcmp(r.status, t.expect);
nP = nP + ok;
if verbose
fprintf(' [%s] %-32s -> %-13s (want %s)\n', tern(ok, 'PASS', 'FAIL'), ...
t.name, r.status, t.expect);
end
R(end+1) = struct('case', t.name, 'got', r.status, 'pass', ok); %#ok<AGROW>
end
% ---- manifest tampering ----------------------------------------------------
% Two attacks, because they exercise different guards:
% (a) edit a value, leave the hash -> the recomputed value no longer matches
% the frozen value (VALUE guard)
% (b) edit the value AND the hash -> the hash no longer equals the hash of the
% re-derived values (HASH guard)
% Neither can be caught by the task-level verifier alone, which grades against
% whatever the manifest says. That is why the manifest has its own verify pass.
% fileread, not fread(...,'char'): fread with a 'char' precision still returns a
% DOUBLE array in MATLAB, and jsondecode then rejects it with "JSON text must be a
% character vector". strrep() tolerated the doubles, so the write step worked and
% only the decode failed -- a confusing half-failure.
raw = fileread(manifest);
bad1 = strrep(raw, '-27.9657', '-24.0998');
f1 = fullfile(tmp, 'tamper_value.json');
fid = fopen(f1, 'w'); fwrite(fid, bad1, 'char'); fclose(fid);
c1 = mas_refcheck('verify', f1);
ok1 = ~c1.pass && ~strcmp(c1.entries.D3.status, 'OK');
nP = nP + ok1;
if verbose
fprintf(' [%s] %-32s -> %s\n', tern(ok1, 'PASS', 'FAIL'), 'value edited', ...
c1.entries.D3.status);
end
% read the committed hash through the JSON decoder rather than a regexp: the
% pretty-printed file may format the field differently, and a regexp that silently
% matches nothing turns this into a test of nothing (which is what happened first).
Mfull = jsondecode(raw);
hD3 = Mfull.entries.D3.hash;
bad2 = strrep(bad1, hD3, repmat('0', 1, numel(hD3)));
f2 = fullfile(tmp, 'tamper_hash.json');
fid = fopen(f2, 'w'); fwrite(fid, bad2, 'char'); fclose(fid);
c2 = mas_refcheck('verify', f2);
ok2 = ~c2.pass && strcmp(c2.entries.D3.status, 'HASH_CHANGED');
nP = nP + ok2;
if verbose
fprintf(' [%s] %-32s -> %s\n', tern(ok2, 'PASS', 'FAIL'), 'value and hash edited', ...
c2.entries.D3.status);
end
% ---- the frozen file itself must verify ------------------------------------
vr = mas_refcheck('verify');
okFrozen = vr.pass;
nP = nP + okFrozen;
if verbose
fprintf(' [%s] %-32s -> %d/%d referenced verified\n', tern(okFrozen, 'PASS', 'FAIL'), ...
'committed manifest verifies', vr.nPass, vr.nTotal);
end
total = numel(T) + 3;
res = struct('nPass', nP, 'nTotal', total, 'cases', R, 'pass', nP == total, ...
'manifestVerify', vr);
if verbose
fprintf('\n---- %d / %d verifier cases passed ----\n', nP, total);
end
end
% ---------------------------------------------------------------------------
function t = tc(name, fn, expect)
t = struct('name', name, 'fn', fn, 'expect', expect);
end
function s = tern(c, a, b)
if c, s = a; else, s = b; end
end
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |