rachnasutra 0.4.0 → 0.5.0

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +19 -2
  2. package/CITATION.cff +2 -2
  3. package/Dockerfile +9 -0
  4. package/README.gu.md +35 -0
  5. package/README.md +14 -12
  6. package/ROADMAP.md +8 -1
  7. package/case-studies/clean-blog/fixes.diff +152 -152
  8. package/dist/audit.js +24 -6
  9. package/dist/browser.js +147 -0
  10. package/dist/cli.js +117 -17
  11. package/dist/report.js +23 -0
  12. package/dist/rules.js +176 -0
  13. package/dist/tw-color.js +36 -0
  14. package/docs/cli-reference.md +1 -1
  15. package/docs/compatibility.md +1 -1
  16. package/docs/status.md +13 -6
  17. package/documents/rachnasutra/00-overview.md +4 -4
  18. package/documents/rachnasutra/02-functional-specification.md +6 -6
  19. package/documents/rachnasutra/03-architecture.md +1 -1
  20. package/documents/rachnasutra/04-technical-reference.md +2 -2
  21. package/documents/rachnasutra/05-user-guide.md +1 -1
  22. package/documents/rachnasutra/06-audit-rules-reference.md +46 -1
  23. package/documents/rachnasutra/10-testing-and-evidence.md +22 -21
  24. package/documents/rachnasutra/11-deployment-and-ci.md +26 -6
  25. package/documents/rachnasutra/12-roadmap-and-status.md +13 -11
  26. package/documents/rachnasutra/13-maintainer-handbook.md +1 -1
  27. package/documents/rachnasutra/15-rule-examples.md +456 -0
  28. package/documents/rachnasutra/16-validation-and-benchmarks.md +3 -3
  29. package/examples/prime-session-example.md +2 -2
  30. package/fixtures/rule-cases.mjs +85 -70
  31. package/llms.txt +4 -3
  32. package/package.json +7 -2
  33. package/samples/broken-ui/latest.html +42 -30
  34. package/samples/broken-ui/latest.json +39 -14
  35. package/samples/broken-ui/latest.md +24 -13
  36. package/samples/broken-ui/latest.sarif +48 -10
  37. package/samples/good-ui/latest.html +1 -1
  38. package/samples/good-ui/latest.json +3 -3
  39. package/samples/good-ui/latest.md +2 -2
@@ -623,6 +623,460 @@ x
623
623
 
624
624
  **Result:** rule did not fire
625
625
 
626
+ ## RS-A11Y-001 (role=img with no name): Image has no alt attribute
627
+
628
+ Category: accessibility. Default severity: high. Criterion: WCAG 1.1.1.
629
+
630
+ **Failing input**
631
+
632
+ ```html
633
+ /* index.html */
634
+ <!doctype html>
635
+ <html lang="en">
636
+ <head>
637
+ <meta charset="utf-8">
638
+ <meta name="viewport" content="width=device-width, initial-scale=1">
639
+ <title>T</title>
640
+ </head>
641
+ <body>
642
+ <main>
643
+ <div role="img"></div>
644
+ </main>
645
+ </body>
646
+ </html>
647
+ ```
648
+
649
+ **Result:** `RS-0001` [high/confirmed] Element with role="img" has no accessible name at `index.html:10`
650
+
651
+ **Passing input**
652
+
653
+ ```html
654
+ /* index.html */
655
+ <!doctype html>
656
+ <html lang="en">
657
+ <head>
658
+ <meta charset="utf-8">
659
+ <meta name="viewport" content="width=device-width, initial-scale=1">
660
+ <title>T</title>
661
+ </head>
662
+ <body>
663
+ <main>
664
+ <div role="img" aria-label="Sales chart"></div>
665
+ </main>
666
+ </body>
667
+ </html>
668
+ ```
669
+
670
+ **Result:** rule did not fire
671
+
672
+ ## RS-A11Y-013 (tailwind arbitrary hex pair): Text contrast below minimum (measured)
673
+
674
+ Category: accessibility. Default severity: high. Criterion: WCAG 1.4.3.
675
+
676
+ **Failing input**
677
+
678
+ ```tsx
679
+ /* Card.tsx */
680
+ export const Card = () => <p className="text-[#cccccc] bg-[#ffffff]">Price</p>;
681
+ ```
682
+
683
+ **Result:** `RS-0001` [high/review-required] Text contrast 1.61:1 is below 4.5:1 (#cccccc on #ffffff) at `Card.tsx:1`
684
+
685
+ **Passing input**
686
+
687
+ ```tsx
688
+ /* Card.tsx */
689
+ export const Card = () => <p className="text-[#1a1a1a] bg-[#ffffff]">Price</p>;
690
+ ```
691
+
692
+ **Result:** rule did not fire
693
+
694
+ ## RS-A11Y-013 (jsx style object): Text contrast below minimum (measured)
695
+
696
+ Category: accessibility. Default severity: high. Criterion: WCAG 1.4.3.
697
+
698
+ **Failing input**
699
+
700
+ ```tsx
701
+ /* Card.tsx */
702
+ export const Card = () => <p style={{ color: "#cccccc", backgroundColor: "#ffffff" }}>Price</p>;
703
+ ```
704
+
705
+ **Result:** `RS-0001` [high/review-required] Text contrast 1.61:1 is below 4.5:1 (#cccccc on #ffffff) at `Card.tsx:1`
706
+
707
+ **Passing input**
708
+
709
+ ```tsx
710
+ /* Card.tsx */
711
+ export const Card = () => <p style={{ color: "#1a1a1a", backgroundColor: "#ffffff" }}>Price</p>;
712
+ ```
713
+
714
+ **Result:** rule did not fire
715
+
716
+ ## RS-A11Y-013 (tailwind named colours): Text contrast below minimum (measured)
717
+
718
+ Category: accessibility. Default severity: high. Criterion: WCAG 1.4.3.
719
+
720
+ **Failing input**
721
+
722
+ ```tsx
723
+ /* Card.tsx */
724
+ export const Card = () => <p className="text-gray-400 bg-white">Price</p>;
725
+ ```
726
+
727
+ **Result:** `RS-0001` [high/review-required] Text contrast 2.54:1 is below 4.5:1 (#9ca3af on #ffffff) at `Card.tsx:1`
728
+
729
+ **Passing input**
730
+
731
+ ```tsx
732
+ /* Card.tsx */
733
+ export const Card = () => <p className="text-gray-900 bg-white">Price</p>;
734
+ ```
735
+
736
+ **Result:** rule did not fire
737
+
738
+ ## RS-A11Y-013 (css module file): Text contrast below minimum (measured)
739
+
740
+ Category: accessibility. Default severity: high. Criterion: WCAG 1.4.3.
741
+
742
+ **Failing input**
743
+
744
+ ```css
745
+ /* button.module.css */
746
+ .price { color: #cccccc; background: #ffffff; }
747
+ ```
748
+
749
+ **Result:** `RS-0001` [high/confirmed] Text contrast 1.61:1 is below 4.5:1 (#cccccc on #ffffff) at `button.module.css:1`
750
+
751
+ **Passing input**
752
+
753
+ ```css
754
+ /* button.module.css */
755
+ .price { color: #1a1a1a; background: #ffffff; }
756
+ ```
757
+
758
+ **Result:** rule did not fire
759
+
760
+ ## RS-A11Y-013 (styled-components template): Text contrast below minimum (measured)
761
+
762
+ Category: accessibility. Default severity: high. Criterion: WCAG 1.4.3.
763
+
764
+ **Failing input**
765
+
766
+ ```tsx
767
+ /* Button.tsx */
768
+ const B = styled.button`color: #cccccc; background: #ffffff;`;
769
+ ```
770
+
771
+ **Result:** `RS-0001` [high/confirmed] Text contrast 1.61:1 is below 4.5:1 (#cccccc on #ffffff) at `Button.tsx:2`
772
+
773
+ **Passing input**
774
+
775
+ ```tsx
776
+ /* Button.tsx */
777
+ const B = styled.button`color: #1a1a1a; background: #ffffff;`;
778
+ ```
779
+
780
+ **Result:** rule did not fire
781
+
782
+ ## RS-A11Y-016: Duplicate id
783
+
784
+ Category: accessibility. Default severity: high. Criterion: WCAG 4.1.2, 1.3.1.
785
+
786
+ **Failing input**
787
+
788
+ ```html
789
+ /* index.html */
790
+ <!doctype html>
791
+ <html lang="en">
792
+ <head>
793
+ <meta charset="utf-8">
794
+ <meta name="viewport" content="width=device-width, initial-scale=1">
795
+ <title>T</title>
796
+ </head>
797
+ <body>
798
+ <main>
799
+ <label for="a">One</label><input id="a"><input id="a">
800
+ </main>
801
+ </body>
802
+ </html>
803
+ ```
804
+
805
+ **Result:** `RS-0001` [high/confirmed] Duplicate id "a" at `index.html:10`
806
+
807
+ **Passing input**
808
+
809
+ ```html
810
+ /* index.html */
811
+ <!doctype html>
812
+ <html lang="en">
813
+ <head>
814
+ <meta charset="utf-8">
815
+ <meta name="viewport" content="width=device-width, initial-scale=1">
816
+ <title>T</title>
817
+ </head>
818
+ <body>
819
+ <main>
820
+ <label for="a">One</label><input id="a"><input id="b">
821
+ </main>
822
+ </body>
823
+ </html>
824
+ ```
825
+
826
+ **Result:** rule did not fire
827
+
828
+ ## RS-A11Y-017: Frame has no title
829
+
830
+ Category: accessibility. Default severity: high. Criterion: WCAG 4.1.2, 2.4.1.
831
+
832
+ **Failing input**
833
+
834
+ ```html
835
+ /* index.html */
836
+ <!doctype html>
837
+ <html lang="en">
838
+ <head>
839
+ <meta charset="utf-8">
840
+ <meta name="viewport" content="width=device-width, initial-scale=1">
841
+ <title>T</title>
842
+ </head>
843
+ <body>
844
+ <main>
845
+ <iframe src="pay.html"></iframe>
846
+ </main>
847
+ </body>
848
+ </html>
849
+ ```
850
+
851
+ **Result:** `RS-0001` [high/confirmed] Frame has no title at `index.html:10`
852
+
853
+ **Passing input**
854
+
855
+ ```html
856
+ /* index.html */
857
+ <!doctype html>
858
+ <html lang="en">
859
+ <head>
860
+ <meta charset="utf-8">
861
+ <meta name="viewport" content="width=device-width, initial-scale=1">
862
+ <title>T</title>
863
+ </head>
864
+ <body>
865
+ <main>
866
+ <iframe src="pay.html" title="Payment form"></iframe>
867
+ </main>
868
+ </body>
869
+ </html>
870
+ ```
871
+
872
+ **Result:** rule did not fire
873
+
874
+ ## RS-A11Y-018: Navigation with no skip link
875
+
876
+ Category: accessibility. Default severity: medium. Criterion: WCAG 2.4.1.
877
+
878
+ **Failing input**
879
+
880
+ ```html
881
+ /* index.html */
882
+ <!doctype html>
883
+ <html lang="en">
884
+ <head>
885
+ <meta charset="utf-8">
886
+ <meta name="viewport" content="width=device-width, initial-scale=1">
887
+ <title>T</title>
888
+ </head>
889
+ <body>
890
+ <main>
891
+ <nav><a href="/home">Home</a></nav>
892
+ </main>
893
+ </body>
894
+ </html>
895
+ ```
896
+
897
+ **Result:** `RS-0001` [medium/review-required] Navigation with no skip link at `index.html:10`
898
+
899
+ **Passing input**
900
+
901
+ ```html
902
+ /* index.html */
903
+ <!doctype html>
904
+ <html lang="en">
905
+ <head>
906
+ <meta charset="utf-8">
907
+ <meta name="viewport" content="width=device-width, initial-scale=1">
908
+ <title>T</title>
909
+ </head>
910
+ <body>
911
+ <main>
912
+ <a href="#main">Skip to content</a><nav><a href="/home">Home</a></nav>
913
+ </main>
914
+ </body>
915
+ </html>
916
+ ```
917
+
918
+ **Result:** rule did not fire
919
+
920
+ ## RS-A11Y-019: Email or telephone field has no autocomplete
921
+
922
+ Category: accessibility. Default severity: medium. Criterion: WCAG 1.3.5.
923
+
924
+ **Failing input**
925
+
926
+ ```html
927
+ /* index.html */
928
+ <!doctype html>
929
+ <html lang="en">
930
+ <head>
931
+ <meta charset="utf-8">
932
+ <meta name="viewport" content="width=device-width, initial-scale=1">
933
+ <title>T</title>
934
+ </head>
935
+ <body>
936
+ <main>
937
+ <label for="e">Email</label><input id="e" type="email">
938
+ </main>
939
+ </body>
940
+ </html>
941
+ ```
942
+
943
+ **Result:** `RS-0001` [medium/review-required] email field has no autocomplete attribute at `index.html:10`
944
+
945
+ **Passing input**
946
+
947
+ ```html
948
+ /* index.html */
949
+ <!doctype html>
950
+ <html lang="en">
951
+ <head>
952
+ <meta charset="utf-8">
953
+ <meta name="viewport" content="width=device-width, initial-scale=1">
954
+ <title>T</title>
955
+ </head>
956
+ <body>
957
+ <main>
958
+ <label for="e">Email</label><input id="e" type="email" autocomplete="email">
959
+ </main>
960
+ </body>
961
+ </html>
962
+ ```
963
+
964
+ **Result:** rule did not fire
965
+
966
+ ## RS-A11Y-020: Heading has no text
967
+
968
+ Category: accessibility. Default severity: medium. Criterion: WCAG 2.4.6, 1.3.1.
969
+
970
+ **Failing input**
971
+
972
+ ```html
973
+ /* index.html */
974
+ <!doctype html>
975
+ <html lang="en">
976
+ <head>
977
+ <meta charset="utf-8">
978
+ <meta name="viewport" content="width=device-width, initial-scale=1">
979
+ <title>T</title>
980
+ </head>
981
+ <body>
982
+ <main>
983
+ <h2></h2>
984
+ </main>
985
+ </body>
986
+ </html>
987
+ ```
988
+
989
+ **Result:** `RS-0001` [medium/review-required] Heading h2 has no text at `index.html:10`
990
+
991
+ **Passing input**
992
+
993
+ ```html
994
+ /* index.html */
995
+ <!doctype html>
996
+ <html lang="en">
997
+ <head>
998
+ <meta charset="utf-8">
999
+ <meta name="viewport" content="width=device-width, initial-scale=1">
1000
+ <title>T</title>
1001
+ </head>
1002
+ <body>
1003
+ <main>
1004
+ <h2>Featured</h2>
1005
+ </main>
1006
+ </body>
1007
+ </html>
1008
+ ```
1009
+
1010
+ **Result:** rule did not fire
1011
+
1012
+ ## RS-A11Y-021: Control border contrast below 3:1
1013
+
1014
+ Category: accessibility. Default severity: medium. Criterion: WCAG 1.4.11.
1015
+
1016
+ **Failing input**
1017
+
1018
+ ```css
1019
+ /* a.css */
1020
+ button { background: #ffffff; border: 1px solid #dddddd; color: #1a1a1a; }
1021
+ ```
1022
+
1023
+ **Result:** `RS-0001` [medium/review-required] Control border contrast 1.36:1 is below 3:1 at `a.css:1`
1024
+
1025
+ **Passing input**
1026
+
1027
+ ```css
1028
+ /* a.css */
1029
+ button { background: #ffffff; border: 1px solid #767676; color: #1a1a1a; }
1030
+ ```
1031
+
1032
+ **Result:** rule did not fire
1033
+
1034
+ ## RS-A11Y-022: Empty lang on a part of the page
1035
+
1036
+ Category: accessibility. Default severity: medium. Criterion: WCAG 3.1.2.
1037
+
1038
+ **Failing input**
1039
+
1040
+ ```html
1041
+ /* index.html */
1042
+ <!doctype html>
1043
+ <html lang="en">
1044
+ <head>
1045
+ <meta charset="utf-8">
1046
+ <meta name="viewport" content="width=device-width, initial-scale=1">
1047
+ <title>T</title>
1048
+ </head>
1049
+ <body>
1050
+ <main>
1051
+ <p lang="">Bonjour</p>
1052
+ </main>
1053
+ </body>
1054
+ </html>
1055
+ ```
1056
+
1057
+ **Result:** `RS-0001` [medium/confirmed] <p> has an empty lang attribute at `index.html:10`
1058
+
1059
+ **Passing input**
1060
+
1061
+ ```html
1062
+ /* index.html */
1063
+ <!doctype html>
1064
+ <html lang="en">
1065
+ <head>
1066
+ <meta charset="utf-8">
1067
+ <meta name="viewport" content="width=device-width, initial-scale=1">
1068
+ <title>T</title>
1069
+ </head>
1070
+ <body>
1071
+ <main>
1072
+ <p lang="fr">Bonjour</p>
1073
+ </main>
1074
+ </body>
1075
+ </html>
1076
+ ```
1077
+
1078
+ **Result:** rule did not fire
1079
+
626
1080
  ## RS-RESP-001: No viewport meta tag
627
1081
 
628
1082
  Category: responsive. Default severity: medium. Criterion: WCAG 1.4.10.
@@ -1198,6 +1652,8 @@ These inputs look suspicious but are correct. The rule must stay silent.
1198
1652
  - `RS-A11Y-004`: button with text. Result: silent (correct)
1199
1653
  - `RS-A11Y-001`: img named by title is not reported (ACT 23a2a8 passed example). Result: silent (correct)
1200
1654
  - `RS-A11Y-001`: img hidden from the accessibility tree. Result: silent (correct)
1655
+ - `RS-A11Y-001`: role=img hidden from the accessibility tree. Result: silent (correct)
1656
+ - `RS-A11Y-016`: id inside a code sample. Result: silent (correct)
1201
1657
  - `RS-A11Y-004`: hidden button is not rendered. Result: silent (correct)
1202
1658
  - `RS-A11Y-013`: text-shadow changes effective contrast, so the pair is not judged. Result: silent (correct)
1203
1659
  - `RS-A11Y-004`: name supplied at runtime by data-l10n-id. Result: silent (correct)
@@ -8,7 +8,7 @@ This page answers one question: **how do we know the audit is right?** Test fixt
8
8
 
9
9
  | Evidence | What was done | Headline result |
10
10
  |---|---|---|
11
- | Per-rule tests | A failing and a passing input for every one of the 26 rules, plus false-positive guards | 111 automated tests pass; all examples published in [Rule examples](15-rule-examples.md) |
11
+ | Per-rule tests | A failing and a passing input for every one of the 33 rules, plus false-positive guards | 140 automated tests pass; all examples published in [Rule examples](15-rule-examples.md) |
12
12
  | W3C ACT test cases | 154 test cases from the ACT Rules Community Group, mapped to 10 rules | Precision 71%, recall 65% after fixes (53% and 38% on the first run) |
13
13
  | axe-core comparison | The same 109 ACT cases run through axe-core 4.10.2 and RachnaSutra | axe-core is better: 92% precision and 83% recall, against 81% and 73% |
14
14
  | Real-world audit | 12 public repositories, 1,360 files, 767 findings; 3 rounds of manual spot checks | Round 1: 77% strict precision, 93% lenient; seven false-positive patterns found and fixed |
@@ -159,14 +159,14 @@ The 17 remaining findings were reviewed and deliberately not changed: ten focus-
159
159
  |---|---|---|
160
160
  | A blind re-test on new repositories | Current numbers were used to improve the rules | Planned |
161
161
  | Independent labelling | Removes author bias | Open; contributions welcome |
162
- | Runtime evidence (browser, axe-core, screenshots) | Contrast, focus and computed names need rendering | Planned, see roadmap |
162
+ | Runtime evidence (browser, axe-core, screenshots) | `audit --mode browser` renders `index.html`, saves a screenshot, and runs axe-core | Implemented when Playwright is installed. Screen-reader and keyboard paths stay manual. This does not change the static axe comparison above |
163
163
  | Live host smoke tests | Skills are only structurally verified | See [Host smoke tests](17-host-smoke-tests.md) |
164
164
  | Usage and community track record | Cannot be created in advance | Time |
165
165
 
166
166
  ## Reproduce
167
167
 
168
168
  ```bash
169
- npm install && npm test # 111 tests
169
+ npm install && npm test # 140 tests
170
170
  npm run examples # regenerate rule examples
171
171
  node benchmarks/act.mjs # ACT benchmark (needs network)
172
172
  # axe-core comparison (installs axe-core and jsdom in a throwaway folder):
@@ -10,7 +10,7 @@
10
10
  |---|---|
11
11
  | File read and search | available |
12
12
  | Shell and RachnaSutra CLI | available (`rachnasutra audit`, `doctor`) |
13
- | Browser, screenshots, vision | **not available**, so nothing below is rendered or visual |
13
+ | Browser, screenshots, vision | not used in this example. Version 0.5.0 can run `audit --mode browser` when Playwright is installed. This write-up did not |
14
14
  | Network | not used |
15
15
 
16
16
  Mode: **read-only**. Target: `fixtures/intentionally-broken-ui` (2 files). No file will be edited without approval.
@@ -21,7 +21,7 @@ Only the specialists the task needs: `rachnasutra-access` (accessibility evidenc
21
21
 
22
22
  ## 3. Evidence
23
23
 
24
- Command: `rachnasutra audit fixtures/intentionally-broken-ui --json`. Result: 21 findings (8 high, 7 medium, 5 low, 1 info); 13 confirmed, 8 review required.
24
+ Command: `rachnasutra audit fixtures/intentionally-broken-ui --json`. Result: 22 findings (8 high, 8 medium, 5 low, 1 info).
25
25
 
26
26
  Highest-severity findings, each verified against the source:
27
27