hurdle-gate 0.3.1__py3-none-any.whl

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.
hurdle/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """hurdle — static-analysis gate for source↔test file existence mapping."""
2
+
3
+ __version__ = "0.3.1"
hurdle/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from hurdle.cli import main
4
+
5
+ sys.exit(main())
hurdle/cli.py ADDED
@@ -0,0 +1,519 @@
1
+ #!/usr/bin/env python3
2
+ """hurdle — minimal test gap scanner (stdlib only).
3
+
4
+ hurdle scan PATH [--json FILE] [--strict] [--config FILE] [--diff BASE]
5
+ Maps source files to their conventional test counterparts and reports gaps.
6
+ Go: *_test.go in the same directory (package-level convention).
7
+ Python: test_{stem}.py / {stem}_test.py next to the file, tests/test_{stem}.py
8
+ relative to the file's directory or the scan root; variant names
9
+ tests/test_{stem}_*.py and tests/test_*_{stem}.py match via fnmatch (the
10
+ required '_' separators keep {stem} on word boundaries). "__init__.py" is a
11
+ package marker (excluded) unless strict_init=true; non-test .py files under a
12
+ configured test_dirs directory (default ["tests","test"]) are excluded as
13
+ test-support modules.
14
+ JS/TS: {stem}.test.{ext} / {stem}.spec.{ext} next to the file.
15
+ C/shell (.c .h .cc .cpp .sh): module-aggregated heuristic mode. The module is
16
+ the directory holding the source file; a module is ok (confidence=heuristic)
17
+ when a registered module_map keyword appears in some C test file path or
18
+ content (content read with errors='replace', files up to 1MB only), or the
19
+ module name appears in some C test file path. Files named test_*/..._test or
20
+ living under tests/, test/ or kunit/ are C test files, not sources.
21
+ Config (--config FILE; default: PATH/.hurdle.json when present):
22
+ exclude: trailing "/" matches a directory name anywhere in the path;
23
+ otherwise fnmatch glob matched against the relpath and the file
24
+ name. Matching sources get status=excluded (counted, not gaps).
25
+ allowlist: {"rel/path": "reason"} — exact relpath match; status=allowed
26
+ with the reason shown in the report (wins over exclude).
27
+ test_dirs: directory names marking test context (default ["tests","test"]);
28
+ non-test .py files under them are excluded as test-support.
29
+ strict_init: when true, __init__.py is judged as a normal source file
30
+ instead of a package marker.
31
+ module_map: {"module-relpath-or-name": ["keyword", ...]} for the C heuristic.
32
+ --diff BASE: only judge files added/modified/renamed between BASE and HEAD,
33
+ plus uncommitted working-tree changes vs BASE; test existence matching still
34
+ uses the full worktree. PATH must be a git work tree (exit 2 otherwise).
35
+ Unmappable extensions are reported separately as "unmapped", not gaps.
36
+ """
37
+
38
+ import argparse
39
+ import datetime
40
+ import fnmatch
41
+ import json
42
+ import os
43
+ import subprocess
44
+ import sys
45
+
46
+ JS_EXTS = {"ts", "tsx", "js", "jsx"}
47
+ C_EXTS = {"c", "h", "cc", "cpp", "sh"}
48
+ C_TEST_DIR_COMPONENTS = {"tests", "test", "kunit"}
49
+ MAX_CONTENT_BYTES = 1024 * 1024
50
+ DEFAULT_CONFIG_NAME = ".hurdle.json"
51
+
52
+
53
+ def die(msg):
54
+ print("hurdle: %s" % msg, file=sys.stderr)
55
+ sys.exit(2)
56
+
57
+
58
+ class Config:
59
+ """Parsed .hurdle.json content; all keys optional."""
60
+
61
+ def __init__(self, data):
62
+ data = data or {}
63
+ self.exclude = list(data.get("exclude") or [])
64
+ self.allowlist = dict(data.get("allowlist") or {})
65
+ self.module_map = dict(data.get("module_map") or {})
66
+ self.strict_init = bool(data.get("strict_init", False))
67
+ self.test_dirs = list(data.get("test_dirs") or ["tests", "test"])
68
+
69
+ def exclusion_hit(self, rel):
70
+ parts = rel.split("/")
71
+ base = parts[-1]
72
+ for pat in self.exclude:
73
+ if pat.endswith("/"):
74
+ if pat[:-1] in parts:
75
+ return True
76
+ elif fnmatch.fnmatch(rel, pat) or fnmatch.fnmatch(base, pat):
77
+ return True
78
+ return False
79
+
80
+ def allow_reason(self, rel):
81
+ return self.allowlist.get(rel)
82
+
83
+ def under_test_dir(self, rel):
84
+ return any(p in self.test_dirs for p in rel.split("/"))
85
+
86
+ def module_keywords(self, module_rel, module_name):
87
+ kws = self.module_map.get(module_rel)
88
+ if kws is None:
89
+ kws = self.module_map.get(module_name)
90
+ if kws is None:
91
+ return []
92
+ if isinstance(kws, str):
93
+ kws = [kws]
94
+ return list(kws)
95
+
96
+
97
+ def load_config(path):
98
+ try:
99
+ with open(path, "r", encoding="utf-8") as fh:
100
+ return Config(json.load(fh))
101
+ except (OSError, ValueError) as exc:
102
+ die("cannot load config %s: %s" % (path, exc))
103
+
104
+
105
+ def classify(name, rel=None):
106
+ """Return (lang, kind); kind is one of source/test/other."""
107
+ root, ext = os.path.splitext(name)
108
+ ext = ext.lstrip(".").lower()
109
+ if ext == "go":
110
+ return ("go", "test" if root.endswith("_test") else "source")
111
+ if ext == "py":
112
+ if name == "conftest.py" or root.startswith("test_") or root.endswith("_test"):
113
+ return ("py", "test")
114
+ if name == "__init__.py":
115
+ return ("py", "marker")
116
+ return ("py", "source")
117
+ if ext in JS_EXTS:
118
+ if root.endswith(".test") or root.endswith(".spec"):
119
+ return (ext, "test")
120
+ return (ext, "source")
121
+ if ext in C_EXTS:
122
+ parts = (rel or name).split("/")
123
+ if (
124
+ root.startswith("test_")
125
+ or root.endswith("_test")
126
+ or any(p in C_TEST_DIR_COMPONENTS for p in parts[:-1])
127
+ ):
128
+ return ("c", "test")
129
+ return ("c", "source")
130
+ return (ext, "other")
131
+
132
+
133
+ def walk(root):
134
+ """Recursively collect file paths under root, skipping symlinks and hidden entries."""
135
+ files = []
136
+ stack = [root]
137
+ while stack:
138
+ d = stack.pop()
139
+ try:
140
+ entries = list(os.scandir(d))
141
+ except OSError:
142
+ continue
143
+ for e in entries:
144
+ if e.name.startswith(".") or e.is_symlink():
145
+ continue
146
+ if e.is_dir(follow_symlinks=False):
147
+ stack.append(e.path)
148
+ elif e.is_file(follow_symlinks=False):
149
+ files.append(e.path)
150
+ return sorted(files)
151
+
152
+
153
+ def go_tests_in_dir(d):
154
+ try:
155
+ return sorted(
156
+ e.name
157
+ for e in os.scandir(d)
158
+ if e.name.endswith("_test.go") and e.is_file(follow_symlinks=False)
159
+ )
160
+ except OSError:
161
+ return []
162
+
163
+
164
+ def test_candidates(path, lang, scan_root):
165
+ d, name = os.path.split(path)
166
+ stem, ext = os.path.splitext(name)
167
+ if lang == "py":
168
+ return [
169
+ os.path.join(d, "test_" + stem + ".py"),
170
+ os.path.join(d, stem + "_test.py"),
171
+ os.path.join(d, "tests", "test_" + stem + ".py"),
172
+ os.path.join(scan_root, "tests", "test_" + stem + ".py"),
173
+ ]
174
+ if lang in JS_EXTS:
175
+ return [
176
+ os.path.join(d, stem + ".test" + ext),
177
+ os.path.join(d, stem + ".spec" + ext),
178
+ ]
179
+ return []
180
+
181
+
182
+ def py_variant_test(d, stem, scan_root, cfg, listing):
183
+ """Variant test lookup for Python sources (v0.2.0).
184
+
185
+ Matches tests/test_{stem}_*.py and tests/test_*_{stem}.py via fnmatch
186
+ inside the configured test dirs next to the file (d) and at the scan
187
+ root; the required '_' separators keep {stem} on word boundaries.
188
+ Returns the matched absolute path or None.
189
+ """
190
+ patterns = ("test_%s_*.py" % stem, "test_*_%s.py" % stem)
191
+ seen = set()
192
+ for base in (d, scan_root):
193
+ for td in cfg.test_dirs:
194
+ tdir = os.path.normpath(os.path.join(base, td))
195
+ if tdir in seen:
196
+ continue
197
+ seen.add(tdir)
198
+ for fname in listing(tdir):
199
+ if any(fnmatch.fnmatch(fname, p) for p in patterns):
200
+ return os.path.join(tdir, fname)
201
+ return None
202
+
203
+
204
+ def c_module_status(rel, c_tests, read_content, cfg):
205
+ """Heuristic verdict for one C/shell source file. Returns (status, matched_test)."""
206
+ d = os.path.dirname(rel)
207
+ module_rel = d if d else "."
208
+ module_name = os.path.basename(d) if d else os.path.splitext(os.path.basename(rel))[0]
209
+ for kw in cfg.module_keywords(module_rel, module_name):
210
+ for t in c_tests:
211
+ if kw in t:
212
+ return "ok", t
213
+ for t in c_tests:
214
+ content = read_content(t)
215
+ if content and kw in content:
216
+ return "ok", t
217
+ for t in c_tests:
218
+ if module_name and module_name in t:
219
+ return "ok", t
220
+ return "gap", None
221
+
222
+
223
+ def check_git_repo(path):
224
+ proc = subprocess.run(
225
+ ["git", "-C", path, "rev-parse", "--is-inside-work-tree"],
226
+ capture_output=True,
227
+ text=True,
228
+ )
229
+ if proc.returncode != 0 or proc.stdout.strip() != "true":
230
+ die("%s is not a git work tree" % path)
231
+
232
+
233
+ def changed_files(path, base):
234
+ """AMR files changed BASE...HEAD, plus uncommitted working-tree changes vs BASE."""
235
+ cmds = (
236
+ ["git", "-C", path, "diff", "--name-only", "--relative", "--diff-filter=AMR", base + "...HEAD"],
237
+ ["git", "-C", path, "diff", "--name-only", "--relative", "--diff-filter=AMR", base],
238
+ )
239
+ changed = set()
240
+ for cmd in cmds:
241
+ proc = subprocess.run(cmd, capture_output=True, text=True)
242
+ if proc.returncode != 0:
243
+ die("git diff failed (%s): %s" % (base, proc.stderr.strip()))
244
+ changed.update(line for line in proc.stdout.splitlines() if line)
245
+ return changed
246
+
247
+
248
+ def scan(path, cfg=None, diff_base=None):
249
+ root = os.path.abspath(path)
250
+ if cfg is None:
251
+ cfg = Config({})
252
+ results = []
253
+ go_cache = {}
254
+ c_tests = [] # C/shell test relpaths, collected in pass 1
255
+ c_contents = {} # C test relpath -> content str, or None if too big/unreadable
256
+
257
+ def read_c_test_content(rel):
258
+ if rel not in c_contents:
259
+ full = os.path.join(root, *rel.split("/"))
260
+ try:
261
+ if os.path.getsize(full) <= MAX_CONTENT_BYTES:
262
+ with open(full, "r", encoding="utf-8", errors="replace") as fh:
263
+ c_contents[rel] = fh.read()
264
+ else:
265
+ c_contents[rel] = None
266
+ except OSError:
267
+ c_contents[rel] = None
268
+ return c_contents[rel]
269
+
270
+ # Pass 1: collect the C/shell test universe so module judgment sees it all.
271
+ for f in walk(root):
272
+ rel = os.path.relpath(f, root).replace(os.sep, "/")
273
+ lang, kind = classify(os.path.basename(f), rel)
274
+ if kind == "test":
275
+ if lang == "c":
276
+ c_tests.append(rel)
277
+ continue
278
+
279
+ # Pass 2: judge every non-test file.
280
+ py_dir_cache = {}
281
+
282
+ def tests_dir_listing(dirpath):
283
+ if dirpath not in py_dir_cache:
284
+ try:
285
+ py_dir_cache[dirpath] = sorted(
286
+ e.name
287
+ for e in os.scandir(dirpath)
288
+ if e.is_file(follow_symlinks=False) and e.name.endswith(".py")
289
+ )
290
+ except OSError:
291
+ py_dir_cache[dirpath] = []
292
+ return py_dir_cache[dirpath]
293
+
294
+ for f in walk(root):
295
+ rel = os.path.relpath(f, root).replace(os.sep, "/")
296
+ lang, kind = classify(os.path.basename(f), rel)
297
+ if kind == "test":
298
+ continue
299
+ if kind == "marker" and cfg.strict_init:
300
+ kind = "source"
301
+ if kind == "source" and lang == "py" and cfg.under_test_dir(rel):
302
+ kind = "support"
303
+ entry = {"path": rel, "lang": lang}
304
+ if kind == "other":
305
+ entry.update(status="unmapped", matched_test=None, confidence="exact")
306
+ results.append(entry)
307
+ continue
308
+ reason = cfg.allow_reason(rel)
309
+ if reason is not None:
310
+ entry.update(
311
+ status="allowed", matched_test=None, confidence="exact", reason=reason
312
+ )
313
+ results.append(entry)
314
+ continue
315
+ if kind in ("marker", "support"):
316
+ entry.update(
317
+ status="excluded",
318
+ matched_test=None,
319
+ confidence="exact",
320
+ reason=(
321
+ "package marker (__init__.py)"
322
+ if kind == "marker"
323
+ else "test-support module under test dir"
324
+ ),
325
+ )
326
+ results.append(entry)
327
+ continue
328
+ if cfg.exclusion_hit(rel):
329
+ entry.update(status="excluded", matched_test=None, confidence="exact")
330
+ results.append(entry)
331
+ continue
332
+ if lang == "c":
333
+ status, matched = c_module_status(rel, c_tests, read_c_test_content, cfg)
334
+ entry.update(status=status, matched_test=matched, confidence="heuristic")
335
+ results.append(entry)
336
+ continue
337
+ d, name = os.path.split(f)
338
+ status, matched = "gap", None
339
+ if lang == "go":
340
+ if d not in go_cache:
341
+ go_cache[d] = go_tests_in_dir(d)
342
+ tests = go_cache[d]
343
+ if tests:
344
+ status = "ok"
345
+ matched = name[:-3] + "_test.go" if (name[:-3] + "_test.go") in tests else tests[0]
346
+ else:
347
+ for cand in test_candidates(f, lang, root):
348
+ if os.path.isfile(cand) and not os.path.islink(cand):
349
+ status = "ok"
350
+ matched = os.path.relpath(cand, root).replace(os.sep, "/")
351
+ break
352
+ if status == "gap" and lang == "py":
353
+ stem = os.path.splitext(name)[0]
354
+ hit = py_variant_test(d, stem, root, cfg, tests_dir_listing)
355
+ if hit:
356
+ status = "ok"
357
+ matched = os.path.relpath(hit, root).replace(os.sep, "/")
358
+ entry.update(status=status, matched_test=matched, confidence="exact")
359
+ results.append(entry)
360
+
361
+ if diff_base is not None:
362
+ changed = changed_files(root, diff_base)
363
+ results = [r for r in results if r["path"] in changed]
364
+ return root, results
365
+
366
+
367
+ def summarize(results):
368
+ by_lang = {}
369
+ ok = gap = unmapped = excluded = allowed = 0
370
+ for r in results:
371
+ st = r["status"]
372
+ if st == "unmapped":
373
+ unmapped += 1
374
+ continue
375
+ if st == "excluded":
376
+ excluded += 1
377
+ elif st == "allowed":
378
+ allowed += 1
379
+ elif st == "ok":
380
+ ok += 1
381
+ else:
382
+ gap += 1
383
+ cnt = by_lang.setdefault(
384
+ r["lang"], {"ok": 0, "gap": 0, "excluded": 0, "allowed": 0}
385
+ )
386
+ cnt[st] += 1
387
+ return {
388
+ "total": len(results),
389
+ "ok": ok,
390
+ "gap": gap,
391
+ "unmapped": unmapped,
392
+ "excluded": excluded,
393
+ "allowed": allowed,
394
+ "by_lang": by_lang,
395
+ }
396
+
397
+
398
+ def report(root, results, summary, mode="full", base=None, config_path=None):
399
+ print("hurdle scan: %s" % root)
400
+ meta = "mode=%s" % mode
401
+ if mode == "diff" and base:
402
+ meta += " (base=%s)" % base
403
+ if config_path:
404
+ meta += " config=%s" % config_path
405
+ print(meta)
406
+ print(
407
+ "total=%(total)d ok=%(ok)d gap=%(gap)d unmapped=%(unmapped)d"
408
+ " excluded=%(excluded)d allowed=%(allowed)d" % summary
409
+ )
410
+ for lang in sorted(summary["by_lang"]):
411
+ c = summary["by_lang"][lang]
412
+ line = " %s: ok=%d gap=%d" % (lang, c["ok"], c["gap"])
413
+ if c["excluded"]:
414
+ line += " excluded=%d" % c["excluded"]
415
+ if c["allowed"]:
416
+ line += " allowed=%d" % c["allowed"]
417
+ print(line)
418
+ allowed = [r for r in results if r["status"] == "allowed"]
419
+ if allowed:
420
+ print("allowed (allowlisted):")
421
+ for r in allowed[:20]:
422
+ print(" %s — %s" % (r["path"], r.get("reason", "")))
423
+ gaps = [r for r in results if r["status"] == "gap"]
424
+ if gaps:
425
+ dirs = {}
426
+ for r in gaps:
427
+ d = os.path.dirname(r["path"]) or "."
428
+ dirs[d] = dirs.get(d, 0) + 1
429
+ print("gap Top 10 directories:")
430
+ ranked = sorted(dirs.items(), key=lambda kv: (-kv[1], kv[0]))[:10]
431
+ for d, n in ranked:
432
+ print(" %4d %s" % (n, d))
433
+ print("gap files (up to 50 of %d):" % len(gaps))
434
+ for r in gaps[:50]:
435
+ print(" %s" % r["path"])
436
+
437
+
438
+ def main(argv=None):
439
+ parser = argparse.ArgumentParser(
440
+ prog="hurdle", description="minimal test gap scanner"
441
+ )
442
+ sub = parser.add_subparsers(dest="command", required=True)
443
+ scan_p = sub.add_parser("scan", help="scan PATH for untested source files")
444
+ scan_p.add_argument("path", help="directory tree to scan")
445
+ scan_p.add_argument("--json", dest="json_out", metavar="FILE", help="write JSON report")
446
+ scan_p.add_argument(
447
+ "--strict", action="store_true", help="exit 1 when at least one gap exists"
448
+ )
449
+ scan_p.add_argument(
450
+ "--config",
451
+ metavar="FILE",
452
+ help="config file (default: PATH/.hurdle.json when present)",
453
+ )
454
+ scan_p.add_argument(
455
+ "--diff",
456
+ metavar="BASE",
457
+ help="only judge files added/modified/renamed vs BASE (git; exit 2 if not a repo)",
458
+ )
459
+ uni_p = sub.add_parser(
460
+ "universe",
461
+ help="check universe coverage — every item covered, wildcarded or allowlisted",
462
+ )
463
+ uni_p.add_argument(
464
+ "name", help="universe name defined under 'universes' in .hurdle.json"
465
+ )
466
+ uni_p.add_argument(
467
+ "path", nargs="?", default=".", help="scan root (default: current directory)"
468
+ )
469
+ uni_p.add_argument("--json", dest="json_out", metavar="FILE", help="write JSON report")
470
+ uni_p.add_argument(
471
+ "--strict", action="store_true", help="exit 1 when at least one gap exists"
472
+ )
473
+ args = parser.parse_args(argv)
474
+
475
+ if args.command == "universe":
476
+ from hurdle import universe
477
+
478
+ return universe.run(
479
+ args.name, args.path, json_out=args.json_out, strict=args.strict
480
+ )
481
+
482
+ config_path = args.config
483
+ if config_path is None:
484
+ auto = os.path.join(os.path.abspath(args.path), DEFAULT_CONFIG_NAME)
485
+ config_path = auto if os.path.isfile(auto) else None
486
+ cfg = load_config(config_path) if config_path else Config({})
487
+ if args.diff:
488
+ check_git_repo(args.path)
489
+
490
+ root, results = scan(args.path, cfg, diff_base=args.diff)
491
+ summary = summarize(results)
492
+ report(
493
+ root,
494
+ results,
495
+ summary,
496
+ mode="diff" if args.diff else "full",
497
+ base=args.diff,
498
+ config_path=config_path,
499
+ )
500
+
501
+ if args.json_out:
502
+ payload = {
503
+ "path": root,
504
+ "generated_at": datetime.datetime.now(datetime.timezone.utc).isoformat(),
505
+ "mode": "diff" if args.diff else "full",
506
+ "base": args.diff,
507
+ "config": config_path,
508
+ "summary": summary,
509
+ "files": results,
510
+ }
511
+ with open(args.json_out, "w", encoding="utf-8") as fh:
512
+ json.dump(payload, fh, ensure_ascii=False, indent=2)
513
+ fh.write("\n")
514
+
515
+ return 1 if args.strict and summary["gap"] >= 1 else 0
516
+
517
+
518
+ if __name__ == "__main__":
519
+ sys.exit(main())
hurdle/universe.py ADDED
@@ -0,0 +1,319 @@
1
+ """hurdle universe — completeness gate over a defined item set (stdlib only).
2
+
3
+ hurdle universe NAME [PATH] [--json FILE] [--strict]
4
+
5
+ A "universe" is a set of items whose completeness is defined externally
6
+ (e.g. every command and event of a protocol). The check extracts a usage
7
+ set from string literals in the configured sources and computes
8
+ intersection coverage. Gate rule: every item must be covered, covered via
9
+ a domain wildcard, or allowlisted with a reason — a silent gap is the
10
+ failure mode this command exists to catch.
11
+
12
+ Usage set extraction (literal-intersection strategy):
13
+ 1. every file whose relpath matches an include pattern is read whole
14
+ (errors='replace', at most cli.MAX_CONTENT_BYTES, like scan);
15
+ 2. every quoted string literal of up to 120 characters whose text
16
+ matches literal_shape is collected (one regex, quote-paired single/
17
+ double variants);
18
+ 3. collected literals ∩ items = covered — universe membership itself
19
+ separates commands from events because their literal shapes are
20
+ identical;
21
+ 4. wildcard_patterns: substituting {domain} with each item's domain
22
+ (the part before the first '.') yields a regex; a content match
23
+ marks that domain's items status=wildcard;
24
+ 5. extra_usage: explicit declarations, the escape hatch for methods
25
+ composed dynamically (missed by literal extraction) — an exact name
26
+ counts as covered, a glob such as "Runtime.*" as wildcard.
27
+
28
+ Status precedence: covered > wildcard > allowed > gap (usage evidence
29
+ outranks an excuse; an excuse outranks silence). The universe is defined
30
+ under the "universes" key of .hurdle.json (auto-discovered at
31
+ PATH/.hurdle.json, the same rule as scan):
32
+
33
+ "universes": {
34
+ "cdp-commands": {
35
+ "items_file": "universes/cdp-commands.json",
36
+ "include": ["src/**/*.py"],
37
+ "literal_shape": "^[A-Z][A-Za-z0-9]*\\.[a-zA-Z][A-Za-z0-9]+$",
38
+ "wildcard_patterns": ["\\.subscribe\\(\\s*\"({domain})\\.\\*\""],
39
+ "extra_usage": ["Page.javascriptDialogOpening"],
40
+ "allowlist": {"Tracing.*": "out of scope"}
41
+ }
42
+ }
43
+
44
+ items_file holds a bare JSON array or {"items": [...], "meta": {...}}
45
+ (meta passes through to the report); its path is relative to the scan
46
+ root. include patterns are fnmatch globs matched against the relpath —
47
+ "**/" additionally matches zero directories, and the global exclude /
48
+ allowlist config is deliberately NOT applied to this scan. literal_shape,
49
+ wildcard_patterns, extra_usage and allowlist are optional (the shape
50
+ shown above is the default; allowlist values are the reasons, matched
51
+ with fnmatch against item names).
52
+
53
+ --strict exits 1 when at least one gap remains. Config, items-file or
54
+ regex errors exit 2 via die(), including an unknown universe name.
55
+ """
56
+
57
+ import fnmatch
58
+ import json
59
+ import os
60
+ import re
61
+
62
+ from .cli import DEFAULT_CONFIG_NAME, MAX_CONTENT_BYTES, die, walk
63
+
64
+ LITERAL_RE = re.compile(
65
+ r'"([^"\n]{1,120})"' + r"|" + r"'([^'\n]{1,120})'"
66
+ )
67
+ DEFAULT_LITERAL_SHAPE = r"^[A-Z][A-Za-z0-9]*\.[a-zA-Z][A-Za-z0-9]+$"
68
+
69
+
70
+ def _domain(item):
71
+ return item.split(".", 1)[0]
72
+
73
+
74
+ def _glob_match(rel, pattern):
75
+ """fnmatch on the relpath; '**/' additionally matches zero directories."""
76
+ if fnmatch.fnmatch(rel, pattern):
77
+ return True
78
+ return "**/" in pattern and fnmatch.fnmatch(rel, pattern.replace("**/", ""))
79
+
80
+
81
+ def _compile(pattern, what, name):
82
+ try:
83
+ return re.compile(pattern)
84
+ except re.error as exc:
85
+ die("universe '%s': invalid %s %r: %s" % (name, what, pattern, exc))
86
+
87
+
88
+ def _str_list(setting, key, name, required=False):
89
+ """Read key as a list of non-empty strings; a lone string is wrapped."""
90
+ val = setting.get(key)
91
+ if val is None:
92
+ if required:
93
+ die("universe '%s': %s is required" % (name, key))
94
+ return []
95
+ if isinstance(val, str):
96
+ return [val]
97
+ if not isinstance(val, list) or not all(
98
+ isinstance(v, str) and v for v in val
99
+ ):
100
+ die("universe '%s': %s must be a list of non-empty strings" % (name, key))
101
+ return list(val)
102
+
103
+
104
+ def _settings(raw_cfg, cfg_path, name):
105
+ universes = raw_cfg.get("universes") or {}
106
+ if not isinstance(universes, dict):
107
+ die("config %s: 'universes' must be an object" % cfg_path)
108
+ if name not in universes:
109
+ known = ", ".join(sorted(universes)) or "none defined"
110
+ die("universe '%s' not found in %s (known: %s)" % (name, cfg_path, known))
111
+ setting = universes[name]
112
+ if not isinstance(setting, dict):
113
+ die("universe '%s': definition must be an object" % name)
114
+ return setting
115
+
116
+
117
+ def _load_items(root, setting, name):
118
+ """Return (ordered unique items, meta) from the items_file."""
119
+ rel = setting.get("items_file")
120
+ if not isinstance(rel, str) or not rel:
121
+ die("universe '%s': items_file is required" % name)
122
+ full = os.path.join(root, rel)
123
+ try:
124
+ with open(full, "r", encoding="utf-8") as fh:
125
+ data = json.load(fh)
126
+ except (OSError, ValueError) as exc:
127
+ die("cannot load items_file %s: %s" % (rel, exc))
128
+ if isinstance(data, dict):
129
+ meta = data.get("meta")
130
+ items = data.get("items")
131
+ else:
132
+ meta = None
133
+ items = data
134
+ if not isinstance(items, list) or not items:
135
+ die(
136
+ "items_file %s: expected a non-empty JSON array or"
137
+ " {'items': [...], 'meta': {...}}" % rel
138
+ )
139
+ ordered = []
140
+ seen = set()
141
+ for item in items:
142
+ if not isinstance(item, str) or not item:
143
+ die("items_file %s: items must be non-empty strings (got %r)" % (rel, item))
144
+ if item not in seen:
145
+ seen.add(item)
146
+ ordered.append(item)
147
+ return ordered, meta
148
+
149
+
150
+ def _collect_literals(root, include, shape_re):
151
+ """Scan include-matched files; return (shape-valid literals, contents, file count)."""
152
+ literals = set()
153
+ contents = []
154
+ files = 0
155
+ for f in walk(root):
156
+ rel = os.path.relpath(f, root).replace(os.sep, "/")
157
+ if not any(_glob_match(rel, p) for p in include):
158
+ continue
159
+ files += 1
160
+ try:
161
+ if os.path.getsize(f) > MAX_CONTENT_BYTES:
162
+ continue
163
+ with open(f, "r", encoding="utf-8", errors="replace") as fh:
164
+ text = fh.read()
165
+ except OSError:
166
+ continue
167
+ contents.append(text)
168
+ for m in LITERAL_RE.finditer(text):
169
+ s = m.group(1) or m.group(2)
170
+ if shape_re.fullmatch(s):
171
+ literals.add(s)
172
+ return literals, contents, files
173
+
174
+
175
+ def _wildcard_domains(contents, patterns, domains, name):
176
+ """Domains whose wildcard pattern matches any scanned content."""
177
+ hits = set()
178
+ for pat in patterns:
179
+ for dom in sorted(domains):
180
+ cre = _compile(pat.replace("{domain}", dom), "wildcard_pattern", name)
181
+ if any(cre.search(text) for text in contents):
182
+ hits.add(dom)
183
+ return hits
184
+
185
+
186
+ def _evaluate(items, literals, wildcard_doms, extra_exact, extra_globs, allow_pairs):
187
+ rows = []
188
+ for item in items:
189
+ dom = _domain(item)
190
+ if item in literals or item in extra_exact:
191
+ status, reason = "covered", None
192
+ elif dom in wildcard_doms or any(
193
+ fnmatch.fnmatch(item, g) for g in extra_globs
194
+ ):
195
+ status, reason = "wildcard", None
196
+ else:
197
+ reason = None
198
+ for pat, why in allow_pairs:
199
+ if fnmatch.fnmatch(item, pat):
200
+ reason = why
201
+ break
202
+ status = "allowed" if reason is not None else "gap"
203
+ rows.append(
204
+ {"name": item, "domain": dom, "status": status, "allow_reason": reason}
205
+ )
206
+ return rows
207
+
208
+
209
+ def _rollup(rows):
210
+ summary = {"total": len(rows), "covered": 0, "wildcard": 0, "allowed": 0, "gap": 0}
211
+ by_domain = {}
212
+ for r in rows:
213
+ summary[r["status"]] += 1
214
+ c = by_domain.setdefault(
215
+ r["domain"],
216
+ {"total": 0, "covered": 0, "wildcard": 0, "allowed": 0, "gap": 0},
217
+ )
218
+ c["total"] += 1
219
+ c[r["status"]] += 1
220
+ return summary, by_domain
221
+
222
+
223
+ def _print_report(name, root, cfg_path, summary, by_domain, rows, files):
224
+ print("hurdle universe: %s" % name)
225
+ print("root=%s config=%s" % (root, cfg_path))
226
+ print("scanned files=%d" % files)
227
+ print(
228
+ "total=%(total)d covered=%(covered)d wildcard=%(wildcard)d"
229
+ " allowed=%(allowed)d gap=%(gap)d" % summary
230
+ )
231
+ ranked = sorted(by_domain.items(), key=lambda kv: (-kv[1]["gap"], kv[0]))[:15]
232
+ if ranked:
233
+ print("domain Top %d by gap:" % len(ranked))
234
+ print(
235
+ " %-24s %5s %4s %4s %6s %5s"
236
+ % ("domain", "total", "cov", "wc", "allow", "gap")
237
+ )
238
+ for dom, c in ranked:
239
+ print(
240
+ " %-24s %5d %4d %4d %6d %5d"
241
+ % (
242
+ dom,
243
+ c["total"],
244
+ c["covered"],
245
+ c["wildcard"],
246
+ c["allowed"],
247
+ c["gap"],
248
+ )
249
+ )
250
+ allowed = [r for r in rows if r["status"] == "allowed"]
251
+ if allowed:
252
+ print("allowed (allowlisted):")
253
+ for r in allowed[:20]:
254
+ print(" %s — %s" % (r["name"], r.get("allow_reason") or ""))
255
+ gaps = [r for r in rows if r["status"] == "gap"]
256
+ if gaps:
257
+ print("gap items (up to 50 of %d):" % len(gaps))
258
+ for r in gaps[:50]:
259
+ print(" %s" % r["name"])
260
+
261
+
262
+ def run(name, path=".", json_out=None, strict=False):
263
+ root = os.path.abspath(path)
264
+ cfg_path = os.path.join(root, DEFAULT_CONFIG_NAME)
265
+ if not os.path.isfile(cfg_path):
266
+ die(
267
+ "no %s in %s — universe definitions require config"
268
+ % (DEFAULT_CONFIG_NAME, root)
269
+ )
270
+ try:
271
+ with open(cfg_path, "r", encoding="utf-8") as fh:
272
+ raw = json.load(fh)
273
+ except (OSError, ValueError) as exc:
274
+ die("cannot load config %s: %s" % (cfg_path, exc))
275
+ if not isinstance(raw, dict):
276
+ die("config %s: expected a JSON object" % cfg_path)
277
+ setting = _settings(raw, cfg_path, name)
278
+
279
+ items, meta = _load_items(root, setting, name)
280
+ include = _str_list(setting, "include", name, required=True)
281
+ shape = setting.get("literal_shape") or DEFAULT_LITERAL_SHAPE
282
+ if not isinstance(shape, str):
283
+ die("universe '%s': literal_shape must be a string" % name)
284
+ shape_re = _compile(shape, "literal_shape", name)
285
+ patterns = _str_list(setting, "wildcard_patterns", name)
286
+ extra_usage = _str_list(setting, "extra_usage", name)
287
+ allow = setting.get("allowlist") or {}
288
+ if not isinstance(allow, dict) or not all(
289
+ isinstance(k, str) and isinstance(v, str) and k for k, v in allow.items()
290
+ ):
291
+ die(
292
+ "universe '%s': allowlist must map item-name globs to reason strings"
293
+ % name
294
+ )
295
+ allow_pairs = list(allow.items())
296
+
297
+ literals, contents, files = _collect_literals(root, include, shape_re)
298
+ domains = {_domain(i) for i in items}
299
+ wildcard_doms = _wildcard_domains(contents, patterns, domains, name)
300
+ extra_exact = {e for e in extra_usage if not any(c in e for c in "*?[")}
301
+ extra_globs = [e for e in extra_usage if any(c in e for c in "*?[")]
302
+
303
+ rows = _evaluate(items, literals, wildcard_doms, extra_exact, extra_globs, allow_pairs)
304
+ summary, by_domain = _rollup(rows)
305
+ _print_report(name, root, cfg_path, summary, by_domain, rows, files)
306
+
307
+ if json_out:
308
+ payload = {
309
+ "universe": name,
310
+ "meta": meta,
311
+ "summary": summary,
312
+ "by_domain": by_domain,
313
+ "items": rows,
314
+ }
315
+ with open(json_out, "w", encoding="utf-8") as fh:
316
+ json.dump(payload, fh, ensure_ascii=False, indent=2)
317
+ fh.write("\n")
318
+
319
+ return 1 if strict and summary["gap"] >= 1 else 0
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: hurdle-gate
3
+ Version: 0.3.1
4
+ Summary: Static-analysis gate for source↔test file existence mapping
5
+ License-Expression: Apache-2.0
6
+ Keywords: testing,test-coverage,static-analysis,ci,quality-gate
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Topic :: Software Development :: Quality Assurance
9
+ Classifier: Development Status :: 4 - Beta
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=7; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # hurdle
18
+
19
+ A source ↔ test **existence mapping** tool. A single-file executable that finds
20
+ source files added without tests (Python 3 standard library only, zero external
21
+ dependencies).
22
+
23
+ **What it does** — decides from filename/path conventions alone whether each
24
+ source file has a corresponding test, and reports the gaps (untested sources).
25
+ Text is the default output; `--json` produces a machine-readable report.
26
+
27
+ **What it does not do**
28
+ - Does not **run** tests — existence only; whether tests pass is out of scope.
29
+ - Does not measure **coverage** — this is a different (and far cheaper) signal
30
+ than line/branch coverage: "does this file have any test at all?"
31
+ - Does not judge code **quality** — a test file that exists but is thin will
32
+ not be caught.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ # Recommended: isolated install via pipx
38
+ pipx install .
39
+
40
+ # Development: venv + editable install (includes dev extras)
41
+ python3 -m venv .venv && source .venv/bin/activate
42
+ pip install -e .[dev]
43
+
44
+ # Environments where pip is unavailable (PEP 668 etc.): runs without installing
45
+ PYTHONPATH=src python3 -m hurdle scan .
46
+ ```
47
+
48
+ ## Quick start
49
+
50
+ ```bash
51
+ # 1) Full scan — gap report for the whole repository (use this to create a baseline)
52
+ hurdle scan ~/study/kopia --json kopia.json
53
+
54
+ # 2) diff mode — evaluate only sources new/changed vs. a base point (core of the local/CI gate)
55
+ hurdle scan . --diff origin/main
56
+
57
+ # 3) strict mode — fail (non-zero exit code) if any evaluated file has a gap
58
+ hurdle scan . --diff origin/main --strict --config .hurdle.json
59
+ ```
60
+
61
+ Reading the output: the report shows a per-file status (`matched` / `gap` /
62
+ `unmapped` — files with unknown extensions are counted only as `unmapped` and
63
+ excluded from language totals), each file's matching test and confidence
64
+ (`exact`/`heuristic`), and per-language totals. Exit codes under `--strict`:
65
+ no gaps = 0, gaps present = failure, runtime error (e.g. `--diff` outside a
66
+ git repository) = 2. CI decides pass/fail from the strict-mode exit code.
67
+
68
+ ## Verdict rules (per language)
69
+
70
+ | Language | Test-existence verdict | confidence |
71
+ |---|---|---|
72
+ | **go** | Package-level: an exact `{stem}_test.go` match wins first; otherwise covered if any `*_test.go` exists in the same package (directory) | exact |
73
+ | **py** | Probes 4 pytest-convention candidate paths — beside the file / in a `tests/` directory × `test_{stem}.py` / `{stem}_test.py` combinations — plus variant names `tests/test_{stem}_*.py` and `tests/test_*_{stem}.py` (v0.2.0). `__init__.py` counts as a package marker and non-test files under `test_dirs` (default `tests`, `test`) count as test-support — both excluded rather than gapped (config: `strict_init`, `test_dirs`) | exact |
74
+ | **ts/js** | Naming conventions: the `*.test.ts(x)` / `*.spec.ts(x)` families | exact |
75
+ | **c / shell** | File-to-file mapping is impossible in trees like lustre (centralized `lustre/tests/` + `kunit/`), so coverage is aggregated per module/directory (heuristic). Listing module→test keywords in `module_map` improves accuracy | heuristic |
76
+
77
+ ## Configuration (.hurdle.json)
78
+
79
+ Passed via `--config`. See `.hurdle.example.json` in this repository for a
80
+ minimal example and `baselines/*.hurdle.json` for real-world ones.
81
+
82
+ ```jsonc
83
+ {
84
+ "exclude": ["vendor/", "**/*_pb.go"], // kept out of the scan
85
+ "allowlist": { "cmd/legacy/main.go": "thin wrapper; covered in pkg/" },
86
+ "module_map": { "lustre/osd-zfs": ["osd", "conf-sanity"] }
87
+ }
88
+ ```
89
+
90
+ | Key | Format | Description |
91
+ |---|---|---|
92
+ | `exclude` | array of strings | Directories are excluded wholesale with a trailing `/` in the name (`vendor/`). Everything else is an fnmatch pattern matched against full paths/filenames (`**/*_pb.go`) |
93
+ | `allowlist` | relpath → reason string | Do not count this file as a gap (escape hatch). Checked **before exclude**, so a file with an explicit reason survives even broad exclude patterns. The reason stays on record in commit history |
94
+ | `module_map` | module relpath → keyword array | Feeds the C/shell heuristic. List the test-suite keywords that cover a module (e.g. `["sanity", "conf-sanity"]`) and module coverage is looked up in the centralized tests/ directory |
95
+
96
+ ## Baseline → gate workflow
97
+
98
+ The core design is a **ratchet**: existing gaps are frozen, and only new gaps
99
+ are blocked.
100
+
101
+ 1. **Capture a baseline** — run a full scan, commit the resulting JSON gap
102
+ report (covering all existing code) to the repository. This becomes a
103
+ de-facto allowlist. The actual results of doing this for the kopia/lustre/
104
+ longhorn-manager/velero repositories are in [BASELINES.md](BASELINES.md)
105
+ and `baselines/*.json`.
106
+ 2. **Classify with config** — filter generated code (`*_pb.go` etc.), vendor,
107
+ and test-support code (`internal/testutil` etc.) via `exclude`/`allowlist`
108
+ so that only files with genuinely no corresponding test remain in the
109
+ baseline.
110
+ 3. **diff + strict gate** — in CI, `--diff origin/<base> --strict` judges only
111
+ the files changed now. Legacy gaps never show up in the diff and are
112
+ ignored; only new/modified files are forced to carry tests. The gap count
113
+ decreases monotonically.
114
+
115
+ ## CI integration
116
+
117
+ Copy `ci/test-exist-gate.yml` to `.github/workflows/test-exist-gate.yml` in the
118
+ target repository and follow the 4 steps in the comment block at the top of
119
+ the file (swap the URL, commit the config, mark the check as required). The
120
+ flow: `fetch-depth: 0` checkout → install hurdle → run
121
+ `scan . --diff origin/base --strict --config .hurdle.json --json` → upload the
122
+ report artifact even on failure (`if: always()`).
123
+
124
+ ## pre-commit local hook
125
+
126
+ Copy `ci/pre-commit-hook.sh` to `.git/hooks/pre-commit`, or use this minimal
127
+ 3-line form:
128
+
129
+ ```bash
130
+ #!/bin/sh
131
+ [ -n "$(git diff --name-only --diff-filter=ACMR HEAD)" ] || exit 0
132
+ exec hurdle scan . --diff HEAD --strict
133
+ ```
134
+
135
+ ## Limitations (honestly)
136
+
137
+ - **It only checks file existence.** It never sees whether tests run, pass, or
138
+ assert anything meaningful. It is a minimal gate against "source added with
139
+ no test" — not a coverage replacement.
140
+ - **Heuristic module verdicts can over- and under-count.** The module-aggregated
141
+ C/shell verdict depends on `module_map` keywords: keywords that are too
142
+ broad over-report coverage; a missing per-module suite under-reports it.
143
+ Treat the report's confidence markers as the trust boundary.
144
+ - **The only escape hatch is the allowlist.** When a rule misjudges a file,
145
+ allowlisting it with a reason is the sole exception path — hiding it with
146
+ exclude removes it from the scan entirely and breaks gap tracking.
147
+
148
+ ## License
149
+
150
+ Apache-2.0 — see the [LICENSE](LICENSE) file for the full text.
151
+
152
+ ## Universe coverage (`hurdle universe`)
153
+
154
+ Beyond per-file test existence, hurdle can enforce coverage of a
155
+ **defined universe** — a complete set of items every one of which must be
156
+ either used, wildcard-covered, or explicitly allowlisted. The motivating
157
+ case: CDP protocol commands/events (`protocol.json` defines the complete
158
+ universe, so "missing something" is well-defined).
159
+
160
+ ```jsonc
161
+ // .hurdle.json
162
+ "universes": {
163
+ "cdp-commands": {
164
+ "items_file": "universes/cdp-commands.json", // bare array or {"items":[], "meta":{}}
165
+ "include": ["src/**/*.py"],
166
+ "literal_shape": "^[A-Z][A-Za-z0-9]*\\.[a-zA-Z][A-Za-z0-9]+$",
167
+ "wildcard_patterns": ["\\.subscribe\\(\\s*\"({domain})\\.\\*\""],
168
+ "extra_usage": ["Page.javascriptDialogOpening"],
169
+ "allowlist": {"Tracing.*": "out of scope — low-level tracing"}
170
+ }
171
+ }
172
+ ```
173
+
174
+ ```bash
175
+ hurdle universe cdp-commands . --strict --json report.json
176
+ ```
177
+
178
+ - Usage extraction collects shape-matched string literals (module
179
+ constants are picked up at their definition site) and intersects them
180
+ with the universe — universe membership itself disambiguates commands
181
+ vs events that share the `Domain.name` shape.
182
+ - Statuses: `covered` / `wildcard` (a `Domain.*` subscription) /
183
+ `allowed` (fnmatch on item names, reason recorded) / `gap`.
184
+ - `--strict` exits 1 on any gap that is not allowlisted — newly added
185
+ universe items cannot appear silently.
@@ -0,0 +1,10 @@
1
+ hurdle/__init__.py,sha256=i5u-ZMlsWeUMLmVdE6IWWnuhQfntLDtLRuzX-y3SW_8,103
2
+ hurdle/__main__.py,sha256=MjfbwyISQsdxEbdSL5Wgy-NfqO4NFj-yPFPkYCArzMI,58
3
+ hurdle/cli.py,sha256=GBXNTrgIakAaoRNQXdR45hR6Bf8zrhpnYi4asOMEvBw,18703
4
+ hurdle/universe.py,sha256=qKp4DMqijkW3kmuEQwsPs8Xhu3VZPpZCJQQxtkW9990,11898
5
+ hurdle_gate-0.3.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
6
+ hurdle_gate-0.3.1.dist-info/METADATA,sha256=vigo-dozLuWv3dHeE7KKtIntwMltP-ipGzC-K78ul9c,8600
7
+ hurdle_gate-0.3.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
8
+ hurdle_gate-0.3.1.dist-info/entry_points.txt,sha256=1oTz-KQby1bASFUDQPLUGl2R4Wz4bzwXiCt1k_kicx8,43
9
+ hurdle_gate-0.3.1.dist-info/top_level.txt,sha256=W__hcnaY6CM3gHRC8NyzOeEFu8xkQROLjifBSqq8Dms,7
10
+ hurdle_gate-0.3.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ hurdle = hurdle.cli:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ hurdle