bmad-method-test-architecture-enterprise 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -587,13 +587,69 @@ function interpolates(text, mask, kind) {
587
587
  function selfComparisons(stripped, views, pattern) {
588
588
  const spans = [];
589
589
  for (const match of stripped.matchAll(pattern)) {
590
- const operands = [1, 2].map((group) => {
591
- const [start, end] = match.indices[group] ?? [0, 0];
592
- return { text: views.code.slice(start, end), mask: views.mask.slice(start, end) };
593
- });
594
- if (operands.some(({ text, mask }) => interpolates(text, mask, views.kind))) continue;
595
- const [left, right] = operands.map(({ text, mask }) => normalizeOperand(text, mask));
596
- if (left.length > 0 && left === right) spans.push([match.index, match.index + match[0].length]);
590
+ const ranges = [1, 2].map((group) => match.indices[group] ?? [0, 0]);
591
+ if (operandsMatch(views, ranges)) spans.push([match.index, match.index + match[0].length]);
592
+ }
593
+ return spans;
594
+ }
595
+
596
+ /** Whether the two `[start, end]` ranges read as the same expression. */
597
+ function operandsMatch(views, ranges) {
598
+ const operands = ranges.map(([start, end]) => ({ text: views.code.slice(start, end), mask: views.mask.slice(start, end) }));
599
+ if (operands.some(({ text, mask }) => interpolates(text, mask, views.kind))) return false;
600
+ const [left, right] = operands.map(({ text, mask }) => normalizeOperand(text, mask));
601
+ return left.length > 0 && left === right;
602
+ }
603
+
604
+ /**
605
+ * The top-level arguments of the call whose argument list starts at `from` (the
606
+ * index right after the opening paren), as `[start, end]` ranges, or null when the
607
+ * call never closes. `()`, `[]` and `{}` nest, so a comma inside an array, an
608
+ * object or a nested call never splits an argument. It reads the stripped view,
609
+ * where a literal is blank and cannot fake a bracket or a comma. A trailing comma
610
+ * leaves no empty last argument.
611
+ */
612
+ function callArguments(stripped, from) {
613
+ const ranges = [];
614
+ let depth = 0;
615
+ let start = from;
616
+ for (let index = from; index < stripped.length; index += 1) {
617
+ const character = stripped[index];
618
+ if ('([{'.includes(character)) depth += 1;
619
+ else if (')]}'.includes(character)) {
620
+ if (depth === 0) {
621
+ if (character !== ')') return null;
622
+ ranges.push([start, index]);
623
+ if (ranges.length > 1 && stripped.slice(...ranges.at(-1)).trim() === '') ranges.pop();
624
+ return ranges;
625
+ }
626
+ depth -= 1;
627
+ } else if (character === ',' && depth === 0) {
628
+ ranges.push([start, index]);
629
+ start = index + 1;
630
+ }
631
+ }
632
+ return null;
633
+ }
634
+
635
+ /**
636
+ * `selfComparisons` for assertion calls that take the compared values as their
637
+ * first two arguments. `prefix` matches up to the first of them.
638
+ *
639
+ * The arguments are split at top-level commas, so `assert.deepStrictEqual([1, [1, 2]], actual)`
640
+ * compares `[1, [1, 2]]` against `actual`. An operand with a paren in it holds a
641
+ * call or a grouping, which can evaluate differently each time, and is never
642
+ * reported.
643
+ */
644
+ function selfComparingCalls(stripped, views, prefix) {
645
+ const spans = [];
646
+ for (const match of stripped.matchAll(prefix)) {
647
+ const from = match.index + match[0].length;
648
+ const args = callArguments(stripped, from);
649
+ if (!args || args.length < 2) continue;
650
+ const ranges = args.slice(0, 2);
651
+ if (ranges.some(([start, end]) => /[()]/.test(stripped.slice(start, end)))) continue;
652
+ if (operandsMatch(views, ranges)) spans.push([match.index, ranges[1][1]]);
597
653
  }
598
654
  return spans;
599
655
  }
@@ -603,7 +659,7 @@ function matchSpans(source, pattern) {
603
659
  return [...source.matchAll(pattern)].map((match) => [match.index, match.index + match[0].length]);
604
660
  }
605
661
 
606
- const SKIP_TOKEN = /\.skip|xit|xdescribe|test\.todo|@Ignore|@Disabled|pytest\.mark\.skip/;
662
+ const SKIP_TOKEN = /\.skip|\.fixme|\.Skip|xit|xdescribe|test\.todo|@Ignore|@Disabled|pytest\.mark\.skip/;
607
663
 
608
664
  /**
609
665
  * Where this line's comment starts, or -1.
@@ -642,8 +698,39 @@ function commentIndex(line, kind) {
642
698
  return -1;
643
699
  }
644
700
 
701
+ /**
702
+ * Whether the call matched by `callPattern` on this line carries a non-empty
703
+ * string literal as its argument number `argIndex` (zero-based).
704
+ *
705
+ * The argument boundaries come from the stripped line, where every literal is
706
+ * blank, so a comma or a paren inside a test title cannot fake one. The string
707
+ * itself is read from the kept line (`code`) at the same offset: the stripped
708
+ * line has no quote left to find.
709
+ */
710
+ function callHasStringArgument(stripped, code, callPattern, argIndex) {
711
+ const call = callPattern.exec(stripped);
712
+ if (!call) return false;
713
+ let depth = 0;
714
+ let argument = 0;
715
+ let start = call.index + call[0].length;
716
+ for (let index = start; argument < argIndex && index < stripped.length; index += 1) {
717
+ const character = stripped[index];
718
+ if ('([{'.includes(character)) depth += 1;
719
+ else if (')]}'.includes(character)) {
720
+ if (depth === 0) break;
721
+ depth -= 1;
722
+ } else if (character === ',' && depth === 0) {
723
+ argument += 1;
724
+ start = index + 1;
725
+ }
726
+ }
727
+ if (argument !== argIndex) return false;
728
+ const opening = code.slice(start).match(/^\s*(["'`])(?!\1)/);
729
+ return Boolean(opening);
730
+ }
731
+
645
732
  /** C1's escape hatch: a comment on the line or the line above documents the skip. */
646
- function hasAdjacentComment(rawLines, lineIndex, kind) {
733
+ function hasAdjacentComment(rawLines, lineIndex, kind, stripped = '', code = '') {
647
734
  const current = rawLines[lineIndex] || '';
648
735
  const above = (rawLines[lineIndex - 1] || '').trim();
649
736
 
@@ -654,10 +741,18 @@ function hasAdjacentComment(rawLines, lineIndex, kind) {
654
741
  // and `@Disabled("...")` are the documented forms in their languages, and the
655
742
  // reason sits in a different argument position in each. An annotation call with
656
743
  // any string literal in it is the honest predicate; pinning the position would
657
- // pass one language and fail the other. JavaScript has no such form, so this
658
- // branch is scoped rather than applied everywhere.
744
+ // pass one language and fail the other. This branch is scoped to the languages
745
+ // that have annotations.
659
746
  if ((kind === 'py' || kind === 'java') && /@[\w.]+\s*\(/.test(current) && /["']/.test(current)) return true;
660
747
 
748
+ // JavaScript and Go put the reason inside the call. Playwright documents
749
+ // `test.skip(condition, 'reason')` and `test.fixme(condition, 'reason')`: the
750
+ // reason is the second argument. Go's `t.Skip("reason")` and `t.Skipf("...")`
751
+ // carry it as the first. Only a non-empty string counts, so `test.skip(cond)`,
752
+ // `test.skip(title, fn)` and an empty `""` still report.
753
+ if (kind === 'js' && callHasStringArgument(stripped, code, /\.(?:skip|fixme)\s*\(/, 1)) return true;
754
+ if (kind === 'go' && callHasStringArgument(stripped, code, /\.Skip(?:f)?\s*\(/, 0)) return true;
755
+
661
756
  // A trailing comment AFTER the token. One before it documents something else.
662
757
  const tokenIndex = current.search(SKIP_TOKEN);
663
758
  const comment = commentIndex(current, kind);
@@ -672,6 +767,142 @@ function hasAdjacentComment(rawLines, lineIndex, kind) {
672
767
  // the reason it is not a block.
673
768
  // ---------------------------------------------------------------------------
674
769
 
770
+ /**
771
+ * Whether the bare identifier `delay` is MSW's `delay` in this file: imported as
772
+ * `import { delay } from 'msw'` (also a subpath, also beside a default import) or
773
+ * destructured as `const { delay } = require('msw')`. Read from the kept view
774
+ * because the module name is a string literal. An aliased `delay as X` leaves the
775
+ * bare name free, and a `delay` from any other module is a real wait and still
776
+ * fires. Member calls such as `msw.delay(300)` never match the bare-call pattern.
777
+ */
778
+ const MSW_MODULE = String.raw`['"]msw(?:\/[\w/-]+)?['"]`;
779
+ const MSW_NAMED_IMPORT = new RegExp(String.raw`\bimport\s+(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*${MSW_MODULE}`, 'g');
780
+ const MSW_DESTRUCTURE = new RegExp(
781
+ String.raw`\b(?:const|let|var)\s*\{([^}]*)\}\s*=\s*(?:await\s+)?(?:require\s*\(|import\s*\()\s*${MSW_MODULE}\s*\)`,
782
+ 'g',
783
+ );
784
+
785
+ function bindsMswDelay(code) {
786
+ const binds = (list, separator) =>
787
+ list.split(',').some((entry) => {
788
+ const [name, local = name] = entry
789
+ .replace(/=.*$/s, '')
790
+ .trim()
791
+ .split(separator)
792
+ .map((part) => part.trim());
793
+ return name === 'delay' && local === 'delay';
794
+ });
795
+ return (
796
+ [...code.matchAll(MSW_NAMED_IMPORT)].some((match) => binds(match[1].replaceAll(/\btype\s+(?=[\w$])/g, ''), /\s+as\s+/)) ||
797
+ [...code.matchAll(MSW_DESTRUCTURE)].some((match) => binds(match[1], /\s*:\s*/))
798
+ );
799
+ }
800
+
801
+ /**
802
+ * The index just past the bracket that closes the one at `open`, or -1.
803
+ * `([{` nest as one family; `<` is not a bracket here.
804
+ */
805
+ function closingIndex(source, open) {
806
+ let depth = 0;
807
+ for (let index = open; index < source.length; index += 1) {
808
+ const character = source[index];
809
+ if ('([{'.includes(character)) depth += 1;
810
+ else if (')]}'.includes(character)) {
811
+ depth -= 1;
812
+ if (depth === 0) return index + 1;
813
+ }
814
+ }
815
+ return -1;
816
+ }
817
+
818
+ /**
819
+ * Where a TypeScript return-type annotation ends, given the index of its colon on
820
+ * the stripped source: `'body'` when a `{` opens a function body after it,
821
+ * `'signature'` when the type is cut off by `;`, `,`, a closing bracket or the end
822
+ * of the line, and null when the shape is neither.
823
+ *
824
+ * A `{` right after `:`, `|`, `&`, `,`, `(`, `<`, `=>` or inside generics is a type
825
+ * literal and is skipped as a whole. Any other `{` is the body.
826
+ */
827
+ function returnTypeEnd(source, colon) {
828
+ let angle = 0;
829
+ let previous = ':';
830
+ let arrow = false;
831
+ for (let index = colon + 1; index < source.length; index += 1) {
832
+ const character = source[index];
833
+ if (character === '\n') {
834
+ if (angle > 0) continue;
835
+ const continues = /^\s*(?:\|(?!\|)|&(?!&))/.test(source.slice(index + 1)) || '|&:,<'.includes(previous) || arrow;
836
+ if (continues) continue;
837
+ return 'signature';
838
+ }
839
+ if (/\s/.test(character)) continue;
840
+ const opensLiteral = angle > 0 || arrow || ':|&,(<'.includes(previous);
841
+ if (character === '{' && !opensLiteral) return 'body';
842
+ if ('([{'.includes(character)) {
843
+ const end = closingIndex(source, index);
844
+ if (end === -1) return null;
845
+ index = end - 1;
846
+ previous = source[index];
847
+ arrow = false;
848
+ continue;
849
+ }
850
+ if (character === '=' && source[index + 1] === '>') {
851
+ index += 1;
852
+ previous = '>';
853
+ arrow = true;
854
+ continue;
855
+ }
856
+ arrow = false;
857
+ if (character === '<') angle += 1;
858
+ else if (character === '>' && angle > 0) angle -= 1;
859
+ else if (angle === 0 && ';,)}]'.includes(character)) return 'signature';
860
+ else if (angle === 0 && character === '=') return null;
861
+ previous = character;
862
+ }
863
+ return 'signature';
864
+ }
865
+
866
+ /** A modifier a TypeScript member may carry before its name. */
867
+ const MEMBER_MODIFIERS = String.raw`(?:(?:public|private|protected|static|abstract|readonly|async|declare|override)\s+)*`;
868
+
869
+ /**
870
+ * Spans of the `sleep(...)` calls in JavaScript or TypeScript, leaving out the
871
+ * places that declare a helper named sleep and wait on nothing:
872
+ *
873
+ * - `function sleep(ms) {`, `declare function sleep(ms): Promise<void>;`
874
+ * - a method with a body: `sleep(cb: () => void) {}`, `sleep(): { ok: boolean } {}`,
875
+ * `async sleep(): Promise<void> {`, with the parameter list read to its balanced
876
+ * closing paren so parens and braces inside it do not end it early
877
+ * - a body-less signature in an interface, type literal, abstract class or
878
+ * overload list: `sleep(ms: number): Promise<void>;`, where the name starts a
879
+ * member (after `{`, `;`, `,`, `}`, or at the head of its line, behind any
880
+ * modifiers) and a `: type` follows the parameters on the same line.
881
+ *
882
+ * A ternary `cond ? sleep(1) : other` is a call: `sleep` is not at the head of a
883
+ * member there. Anything not recognised as one of the shapes above is a call.
884
+ */
885
+ function sleepCalls(source) {
886
+ const spans = [];
887
+ const memberHead = new RegExp(String.raw`(?:^|[\n{;,}])[ \t]*${MEMBER_MODIFIERS}$`);
888
+ for (const match of source.matchAll(/(?<![\w.$])sleep\s*\(/g)) {
889
+ const before = source.slice(Math.max(0, match.index - 200), match.index);
890
+ if (/\bfunction\s*\*?\s*$/.test(before)) continue;
891
+ const open = match.index + match[0].length - 1;
892
+ const close = closingIndex(source, open);
893
+ if (close !== -1) {
894
+ if (/^\s*\{/.test(source.slice(close, close + 40))) continue;
895
+ const colon = source.slice(close, close + 40).match(/^[ \t]*:/);
896
+ if (colon) {
897
+ const end = returnTypeEnd(source, close + colon[0].length - 1);
898
+ if (end === 'body' || (end === 'signature' && memberHead.test(before))) continue;
899
+ }
900
+ }
901
+ spans.push([match.index, match.index + match[0].length]);
902
+ }
903
+ return spans;
904
+ }
905
+
675
906
  const RULES = [
676
907
  {
677
908
  id: 'C1',
@@ -685,17 +916,19 @@ const RULES = [
685
916
  // fight TEA's doctrine and train users to disable the hook.
686
917
  actionReason: 'the row is conditioned on a documented, still-true reason, which is not mechanically decidable',
687
918
  scope: 'line',
688
- kinds: ['js', 'py', 'java'],
919
+ kinds: ['js', 'py', 'java', 'go'],
689
920
  fix: 'Delete the test, or document why it is skipped on the line or the line above and keep that reason true.',
690
921
  match(line, context) {
691
922
  const patterns = {
692
- js: /(?:^|[^\w.])(?:x(?:it|describe|test)\s*\(|\w+\.skip\s*[(.]|\w+\.todo\s*\()/,
693
- py: /@pytest\.mark\.skip/,
923
+ js: /(?:^|[^\w.])(?:x(?:it|describe|test)\s*\(|\w+(?:\.\w+)*\.(?:skip|fixme)\s*[(.]|\w+\.todo\s*\()/,
924
+ py: /@(?:pytest\.mark\.skip|unittest\.skip)/,
925
+ // No identifier is required before the dot: `s.T().Skip()` is a skip too.
926
+ go: /\.Skip(?:f|Now)?\s*\(/,
694
927
  java: /@(?:Ignore|Disabled)\b/,
695
928
  };
696
929
  const pattern = patterns[context.kind];
697
930
  if (!pattern || !pattern.test(line)) return false;
698
- return !hasAdjacentComment(context.rawLines, context.lineIndex, context.kind);
931
+ return !hasAdjacentComment(context.rawLines, context.lineIndex, context.kind, line, context.code);
699
932
  },
700
933
  },
701
934
  {
@@ -729,27 +962,44 @@ const RULES = [
729
962
  // `.not.` is excluded on purpose: `expect(x).not.toBe(x)` is a defect too,
730
963
  // but it always FAILS, so it is not the "test cannot fail" failure this row
731
964
  // is about, and blocking it would be this hook overreaching its row.
732
- return selfComparisons(
733
- stripped,
734
- context,
735
- /expect\s*\(([^(),]+?)\)\s*\.\s*(?:to\s*\.\s*)?(?:toBe|toEqual|toStrictEqual|toBeCloseTo|equal|equals|eql|deep\s*\.\s*equal)\s*\(([^(),]+?)\)/dg,
736
- );
965
+ return [
966
+ ...selfComparisons(
967
+ stripped,
968
+ context,
969
+ /expect\s*\(([^(),]+?)\)\s*\.\s*(?:to\s*\.\s*)?(?:toBe|toEqual|toStrictEqual|toBeCloseTo|equal|equals|eql|deep\s*\.\s*equal)\s*\(([^(),]+?)\)/dg,
970
+ ),
971
+ // node:assert and chai's assert style. The optional third argument is a
972
+ // message, and `notStrictEqual` always fails, so it is not listed.
973
+ ...selfComparingCalls(stripped, context, /(?<![\w$])assert\s*\.\s*(?:strictEqual|equal|deepStrictEqual|deepEqual)\s*\(/g),
974
+ ];
737
975
  }
738
976
  if (context.kind === 'py') {
739
977
  // Horizontal whitespace only: a Python statement does not continue onto the
740
978
  // next line without a bracket or a backslash, so `\s` here would pair an
741
979
  // `assert` with a `==` on a later, unrelated line.
742
- return selfComparisons(stripped, context, /assert[ \t]+([^=<>!\s]+)[ \t]*==[ \t]*([^=<>!\s#]+)/dg);
980
+ return [
981
+ ...selfComparisons(stripped, context, /assert[ \t]+([^=<>!\s]+)[ \t]*==[ \t]*([^=<>!\s#]+)/dg),
982
+ // unittest. The third argument, when present, is a message.
983
+ ...selfComparingCalls(
984
+ stripped,
985
+ context,
986
+ /\bself\s*\.\s*assert(?:Equal|Equals|Is|CountEqual|ListEqual|DictEqual|TupleEqual|SetEqual|SequenceEqual|AlmostEqual)\s*\(/g,
987
+ ),
988
+ // `assert True, "msg"` is as inert as `assert True`. `assert True == x` is not it.
989
+ ...matchSpans(stripped, /^[ \t]*assert[ \t]+True[ \t]*(?=,|$)/gm),
990
+ ];
743
991
  }
744
992
  if (context.kind === 'java') {
745
993
  return [
746
994
  ...matchSpans(stripped, /assertTrue\s*\(\s*true\s*\)/g),
747
995
  ...matchSpans(stripped, /assertFalse\s*\(\s*false\s*\)/g),
748
996
  ...selfComparisons(stripped, context, /assertEquals\s*\(([^,()]+?),([^,()]+?)\)/dg),
997
+ // AssertJ.
998
+ ...selfComparisons(stripped, context, /assertThat\s*\(([^,()]+?)\)\s*\.\s*(?:isEqualTo|isSameAs)\s*\(([^,()]+?)\)/dg),
749
999
  ];
750
1000
  }
751
1001
  if (context.kind === 'go') {
752
- return selfComparisons(stripped, context, /assert\.(?:Equal|EqualValues)\s*\(\s*t\s*,([^,()]+?),([^,()]+?)\)/dg);
1002
+ return selfComparisons(stripped, context, /(?:assert|require)\.(?:Equal|EqualValues)\s*\(\s*t\s*,([^,()]+?),([^,()]+?)\)/dg);
753
1003
  }
754
1004
  return [];
755
1005
  },
@@ -790,14 +1040,53 @@ const RULES = [
790
1040
  kinds: ['js', 'py', 'java', 'go', 'maestro'],
791
1041
  fix: 'Wait on a web-first assertion, an explicit readiness signal, `cy.wait("@alias")`, or `extendedWaitUntil` in a Maestro flow.',
792
1042
  matchSource(source, context) {
1043
+ // The timer a hard wait hands to a Promise executor, ending at the delay's
1044
+ // first digit. It must CALL the resolver: `setTimeout(r, 1000)` and
1045
+ // `setTimeout(() => r(), 1000)` wait, while `setTimeout(() => reject(...), 5000)`
1046
+ // is a timeout guard on something else and stays silent.
1047
+ const timer = (resolver) => `setTimeout\\s*\\(\\s*(?:${resolver}|\\(\\s*\\)\\s*=>\\s*${resolver}\\s*\\(\\s*\\))\\s*,\\s*\\d`;
1048
+ // The optional `<void>` is the TypeScript type argument on `new Promise<void>(`.
1049
+ const promise = String.raw`\bnew\s+Promise\s*(?:<[^<>()]*>)?\s*\(\s*`;
1050
+ const params = String.raw`([\w$]+)\s*(?:,\s*[\w$]+\s*)?`;
1051
+ const firstParam = String.raw`\1`;
793
1052
  const patterns = {
794
- js: /(?:\bwaitForTimeout\s*\(|\bcy\.wait\s*\(\s*\d|(?:^|[^\w.\r\n])sleep\s*\(|\bdelay\s*\(\s*\d|\bawait\s+setTimeout\s*\(\s*\d|\bnew\s+Promise\s*\(\s*(?:\(\s*)?([\w$]+)\s*(?:,\s*[\w$]+\s*)?\)?\s*=>\s*(?:{\s*)?setTimeout\s*\(\s*\1\s*,\s*\d)/gm,
795
- py: /(?:\btime\.sleep\s*\(|(?:^|[^\w.\r\n])sleep\s*\()/gm,
796
- java: /\bThread\.sleep\s*\(/g,
797
- go: /\btime\.Sleep\s*\(/g,
798
- maestro: /^[ \t]*-[ \t]*sleep[ \t]*:/gm,
1053
+ js: [
1054
+ /\bwaitForTimeout\s*\(/g,
1055
+ /\bcy\.wait\s*\(\s*\d/g,
1056
+ // MSW's `delay()` simulates server latency inside a handler, so it is
1057
+ // left out when the bare `delay` is the one imported from msw. A member
1058
+ // call such as `nockScope.delay(200)` belongs to a library and is left
1059
+ // out too.
1060
+ ...(bindsMswDelay(context.code) ? [] : [/(?<![\w.$])delay\s*\(\s*\d/g]),
1061
+ /\bawait\s+setTimeout\s*\(\s*\d/g,
1062
+ new RegExp(String.raw`${promise}(?:\(\s*)?${params}\)?\s*=>\s*(?:{\s*)?${timer(firstParam)}`, 'g'),
1063
+ new RegExp(String.raw`${promise}function\s*\(\s*${params}\)\s*{\s*${timer(firstParam)}`, 'g'),
1064
+ ],
1065
+ py: [
1066
+ /\btime\.sleep\s*\(/g,
1067
+ // `def sleep(self):` defines a helper.
1068
+ /(?<![\w.])(?<!\bdef\s+)sleep\s*\(/g,
1069
+ // `asyncio.sleep(0)` is a cooperative yield, not a wait.
1070
+ /\basyncio\.sleep\s*\((?!\s*0(?:\.0*)?\s*\))/g,
1071
+ ],
1072
+ // Kotlin's `delay()` stays out on purpose: under `runTest` it advances
1073
+ // virtual time and waits on nothing.
1074
+ java: [
1075
+ /\bThread\.sleep\s*\(/g,
1076
+ /\b(?:TimeUnit\.)?(?:NANOSECONDS|MICROSECONDS|MILLISECONDS|SECONDS|MINUTES|HOURS|DAYS)\.sleep\s*\(/g,
1077
+ ],
1078
+ // A bare `<-time.After(d)` statement blocks for d. Inside a select it is
1079
+ // `case <-time.After(d):`, a timeout guard, and the line does not start with
1080
+ // the receive.
1081
+ go: [/\btime\.Sleep\s*\(/g, /(?:^|[;{])[ \t]*<-[ \t]*time\.After\s*\(/gm],
1082
+ maestro: [/^[ \t]*-[ \t]*sleep[ \t]*:/gm],
799
1083
  };
800
- return [...source.matchAll(patterns[context.kind])].map((match) => [match.index, match.index + match[0].length]);
1084
+ return [
1085
+ ...patterns[context.kind].flatMap((pattern) =>
1086
+ [...source.matchAll(pattern)].map((match) => [match.index, match.index + match[0].length]),
1087
+ ),
1088
+ ...(context.kind === 'js' ? sleepCalls(source) : []),
1089
+ ].sort((a, b) => a[0] - b[0]);
801
1090
  },
802
1091
  },
803
1092
  {
@@ -514,8 +514,8 @@ const totalRequirements = traceabilityMatrix.length;
514
514
  const coveredRequirements = traceabilityMatrix.filter((r) => r.coverage === 'FULL' || r.coverage === 'PARTIAL').length;
515
515
  const fullyCovered = traceabilityMatrix.filter((r) => r.coverage === 'FULL').length;
516
516
 
517
- // Rounded percentages are presentation values. Step 5 compares covered/total counts for every gate threshold.
518
- const safePct = (covered, total) => (total > 0 ? Math.round((covered / total) * 100) : 100);
517
+ // Percentages round DOWN, so a displayed value reaches a whole-number threshold exactly when the counts do. Step 5 compares covered/total counts for every gate threshold.
518
+ const safePct = (covered, total) => (total > 0 ? Math.floor((covered * 100) / total) : 100);
519
519
  const coveragePercentage = safePct(fullyCovered, totalRequirements);
520
520
 
521
521
  // Priority-specific coverage
@@ -112,7 +112,7 @@ const p1Coverage = priorityBreakdown.P1.percentage;
112
112
  const hasP1Requirements = (priorityBreakdown.P1.total || 0) > 0;
113
113
  const effectiveP1Coverage = hasP1Requirements ? p1Coverage : 100;
114
114
  const overallCoverage = stats.overall_coverage_percentage;
115
- // Keep rounded percentages for display. Apply thresholds to integer counts.
115
+ // Displayed percentages round down (Math.floor), so a displayed value reaches a whole-number threshold exactly when the counts do. Apply thresholds to integer counts.
116
116
  const meetsCoverage = (covered, total, threshold) => total === 0 || covered * 100 >= threshold * total;
117
117
  const p0Met = meetsCoverage(priorityBreakdown.P0.covered, priorityBreakdown.P0.total, 100);
118
118
  const p1MinimumMet = meetsCoverage(priorityBreakdown.P1.covered, priorityBreakdown.P1.total, 80);
@@ -958,7 +958,7 @@ This is the only write of report content in this step. Section 6 changes the fro
958
958
  - Requirements covered only by live evidence: {liveOnlyCoveredRequirements} (this run is capped at CONCERNS)
959
959
  {endif}
960
960
 
961
- ⚠️ Critical Gaps: {criticalGaps.length} (P0 criteria below FULL coverage)
961
+ ⚠️ Critical Gaps: {criticalGaps} (P0 criteria below FULL coverage)
962
962
 
963
963
  {if waivers}
964
964
  🔓 Waivers Filed: {waivers.filed} ({waivers.valid} valid, {waivers.invalid} invalid). None applied; the decision above is the derived one.
@@ -2,7 +2,7 @@
2
2
 
3
3
  [bmod]
4
4
  code = "tea"
5
- version = "4.0.0"
5
+ version = "4.0.2"
6
6
  update_source = "github:bmad-code-org/bmad-method-test-architecture-enterprise/skills"
7
7
  skills = [
8
8
  "bmad-tea",
@@ -15,7 +15,7 @@ skills = [
15
15
  "bmad-tea-test-review",
16
16
  "bmad-tea-trace",
17
17
  ]
18
- required_skills = [{ skill = "bmad", version = "6.13.0-next", source = "github:bmad-code-org/BMAD-METHOD/skills" }]
18
+ required_skills = [{ skill = "bmad", version = "6.13.0-next", source = "github:bmad-code-org/BMAD-METHOD/skills/core-tools" }]
19
19
  pre_install_message = ""
20
20
  post_install_message = '''
21
21
  TEA is ready. Talk to Murat (bmad-tea) or start with Test Design (bmad-tea-test-design).
@@ -20,16 +20,16 @@ For a release gate, the order is: `bmad-tea-test-review` (optional), `bmad-tea-n
20
20
 
21
21
  TEA works on its own. When the method module is installed too, these routes add testing to its flow. Name a method skill only when it is installed, and a TEA skill only when it is installed; otherwise give the route without the missing step, and say which TEA skill would fill it once installed. Depth follows risk: a small, low-risk change needs none of this beyond the checks its build runs.
22
22
 
23
- | The user is | Recommend | Because |
24
- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
25
- | Planning an initiative whose risk, compliance or reach calls for a test strategy | `bmad-tea-test-design` at system level, once the PRD and architecture exist | Testability concerns reach the architecture while it can still change. |
26
- | About to build the stories of an epic | `bmad-tea-test-design` at epic level, then `bmad-tea-framework` when the project has no test framework | The epic's plan sets priorities for every story in it. |
27
- | About to build one story with settled criteria, and wants test-first work | `bmad-tea-automate` in red mode, then `bmad-build` | The builder turns the red tests green; the checklist lists them for the story's plan. Red mode takes the story's ref (`1.2`), its title, or its leaf file, and reads the ticket through the method's ticket tools; on v6 it takes the story file. |
28
- | Done with `bmad-build` and wants a maintained test suite for the work | `bmad-tea-automate` in expand mode | It writes tests that follow the project's framework and fixtures, runs them, and heals test defects. `bmad-qa-generate-e2e-tests` remains the fit for a quick, one-off set of end-to-end tests. |
29
- | Upgraded a v6 project with `bmad migrate method` and has TEA checklists, matrices or reports from before | `bmad migrate tea`, after the method migration | It moves each story output onto its v7 ticket's key from exact evidence, keeps historical citations, and lists anything it cannot map. |
30
- | Has `bmad-tea-atdd` or `bmad-tea-ci` customizations, or `bmad setup` cleanup listed them as unused | `bmad migrate tea` (migration 3), before cleanup when you can | It moves red settings into `[workflow.red]` of `bmad-tea-automate.toml` and CI settings into `[workflow.ci]` of `bmad-tea-framework.toml`, reading the cleanup backup when cleanup already removed a file. Keep the `.v6-v7-migration-backup-*` folder until it has run. |
31
- | Has tests whose quality is in doubt | `bmad-tea-test-review` | A scored audit names the flaky, slow or weak tests. |
32
- | Closing an epic or preparing a release | The release-gate order above | Trace gives the gate decision; Test Review and NFR are added when risk calls for them. |
23
+ | The user is | Recommend | Because |
24
+ | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | Planning an initiative whose risk, compliance or reach calls for a test strategy | `bmad-tea-test-design` at system level, once the PRD and architecture exist | Testability concerns reach the architecture while it can still change. |
26
+ | About to build the stories of an epic | `bmad-tea-test-design` at epic level, then `bmad-tea-framework` when the project has no test framework | The epic's plan sets priorities for every story in it. |
27
+ | About to build one story with settled criteria, and wants test-first work | `bmad-tea-automate` in red mode, then `bmad-build` | The builder turns the red tests green; the checklist lists them for the story's plan. Red mode takes the story's ref (`1.2`), its title, or its leaf file, and reads the ticket through the method's ticket tools; on v6 it takes the story file. When the ticket has only a `Verify:` line, the criteria come from the build's plan: stop `bmad-build` at its plan checkpoint with Approve and stop, run red mode, then run `bmad-build` again. A team that wants this in every build sets `bmad-build`'s `before_implement` hook to run red mode. |
28
+ | Done with `bmad-build` and wants a maintained test suite for the work | `bmad-tea-automate` in expand mode | It writes tests that follow the project's framework and fixtures, runs them, and heals test defects. `bmad-qa-generate-e2e-tests` remains the fit for a quick, one-off set of end-to-end tests. |
29
+ | Upgraded a v6 project with `bmad migrate method` and has TEA checklists, matrices or reports from before | `bmad migrate tea`, after the method migration | It moves each story output onto its v7 ticket's key from exact evidence, keeps historical citations, and lists anything it cannot map. |
30
+ | Has `bmad-tea-atdd` or `bmad-tea-ci` customizations, or `bmad setup` cleanup listed them as unused | `bmad migrate tea` (migration 3), before cleanup when you can | It moves red settings into `[workflow.red]` of `bmad-tea-automate.toml` and CI settings into `[workflow.ci]` of `bmad-tea-framework.toml`, reading the cleanup backup when cleanup already removed a file. Keep the `.v6-v7-migration-backup-*` folder until it has run. |
31
+ | Has tests whose quality is in doubt | `bmad-tea-test-review` | A scored audit names the flaky, slow or weak tests. |
32
+ | Closing an epic or preparing a release | The release-gate order above | Trace gives the gate decision; Test Review and NFR are added when risk calls for them. |
33
33
 
34
34
  The story's status is never TEA's to change. Red mode hands its tests to the builder, the builder records the work in the story's plan, and the user or an orchestrator marks the ticket done.
35
35