Skip to content

Star unified quality gate #340

Open
2 of 8 issues completed
Open

Description

@David-Noble-at-work

Migrated from NobleFactor/noblefactor-engprod#62 (star now lives in this repository; GitHub blocks private→public transfers). Original discussion remains there.

Coverage

Phase Plan Item Status Evidence
1 Generate .pre-commit-config.yaml from star.yaml Done internal/config/sync.go — syncPrecommitConfig(), tests in sync_test.go
2 star lint starlark (buildifier + complexity) Not done No LintStarlark extension, no buildifier integration
3 star lint all Done com.noblefactor.star.LintAll — discovers siblings, runs all, collects failures
4 Copyright header checks (star lint copyright --fix) Done com.noblefactor.star.LintCopyright — license detection, check, fix, config-driven
5 Frontmatter validation Done Built into lint.markdown() — reports frontmatter_issues, checks frontmatter_passed
6 YAML/JSON schema validation Not done No LintYaml extension exists
7 Native git hooks (replace pre-commit framework) Done com.noblefactor.star.SetupHooks + HookPreCommit + HookPrePush
8 Migration complete Partial Hooks and lint-all exist; CI migration not verified

Continues work from #25 (closed with phases incomplete).

Summary

Make star the single source of truth for pre-commit hooks and quality gates across all NobleFactor repositories. Running star setup config generates .pre-commit-config.yaml (and other tool configs) from star.yaml, ensuring consistent quality gates everywhere.

What's Implemented

Phase 1: Generate .pre-commit-config.yaml — Done

internal/config/sync.go has syncPrecommitConfig() that generates .pre-commit-config.yaml from the precommit.hooks section of star.yaml. Includes:

  • precommitConfig, precommitRepo, precommitHook structs
  • Generated file header: # GENERATED BY star lint sync - DO NOT EDIT
  • Clean and EnsureGitignore support
  • Full test coverage in sync_test.go (generation, default language, clean, gitignore)

Note: The Starlark config.sync() result exposes golangci_lint and markdown_lint but does not surface precommit_config — the pre-commit generation happens in the Go layer during sync.

Phase 3: star lint all — Done

com.noblefactor.star.LintAll/commands/lint-all.star:

  • Uses commands.siblings() to discover all sibling lint commands
  • Runs each, collects pass/fail results
  • Respects config (skips copyright if cfg.lint.copyright.enabled is false)
  • Propagates --fix flag
  • Prints summary and fails if any linter failed

Phase 4: Copyright header checks — Done

com.noblefactor.star.LintCopyright/commands/lint-copyright.star (373 lines):

  • License auto-detection from LICENSE file (MIT, Apache-2.0, BSD, GPL, MPL, ISC, Unlicense)
  • Comment style detection for 40+ file extensions
  • SPDX + copyright line checking with regex
  • Fix mode: adds missing headers, replaces wrong license/holder, handles shebangs
  • Config-driven: cfg.lint.copyright.enabled, .license, .holder, .exclude
  • File collection via file.glob() respecting .gitignore + explicit exclude patterns

Phase 5: Frontmatter validation — Done

Built into lint.markdown() in the Go layer (internal/starlark/receiver_lint.go). The markdown linter:

  • Reports result.frontmatter_issues (list of file + message)
  • Reports result.frontmatter_passed (bool)
  • Both lint-markdown.star and the hook extensions check frontmatter results

Phase 7: Native git hooks — Done

Three extensions working together:

  • com.noblefactor.star.SetupHooks — installs native git hooks via setup.install_hook(name="pre-commit")
  • com.noblefactor.star.HookPreCommit — runs go, shell, markdown linters on pre-commit
  • com.noblefactor.star.HookPrePush — runs go, shell, markdown linters on pre-push

The Go layer (internal/starlark/receiver_setup.go) provides:

  • setup.install_hook / setup.uninstall_hook / setup.check_hook
  • setup.precommit_install / setup.precommit_check (for pre-commit framework compat)

Supporting infrastructure — Done

  • com.noblefactor.star.LintGo — star lint go (golangci-lint)
  • com.noblefactor.star.LintShell — star lint shell (shellcheck, shfmt)
  • com.noblefactor.star.LintMarkdown — star lint markdown (markdownlint-cli2 + frontmatter)
  • com.noblefactor.star.LintTools — star lint tools (check tool availability)
  • com.noblefactor.star.ConfigSync — star setup config (sync .golangci.yaml, .markdownlint-cli2.yaml)

Remaining Work

Phase 2: star lint starlark — Not started

Lint .star files for formatting and complexity.

Tools needed:

  • Buildifier — Standard Starlark formatter/linter (~100 checks)
  • Custom complexity — Function length, nesting depth, conditionals

Configuration (star.yaml):

lint:
  starlark:
    enabled: true
    buildifier:
      warnings: all  # or specific: [+-warn1, +-warn2]
    complexity:
      max_function_lines: 50
      max_nesting_depth: 4
      max_conditionals: 10

Commands:

star lint starlark            # Check formatting and complexity
star lint starlark --fix      # Auto-format with buildifier

Implementation:

  1. Create com.noblefactor.star.LintStarlark extension
  2. Add starlark_lint builtin receiver with check(paths), format(paths), complexity(paths, config)
  3. Add buildifier to lint.ensure_tools() in receiver_lint.go
  4. Starlark script: glob **/*.star, run buildifier checks, compute complexity metrics

Why custom complexity: Starlark is a Python dialect but lacks import, class, try/except. Python tools (ruff, pylint) produce false positives. Buildifier handles formatting; we add simple complexity metrics.

Phase 6: YAML/JSON schema validation — Not started

Validate config files against JSON schemas.

Configuration (star.yaml):

lint:
  yaml:
    enabled: true
    schemas:
      - pattern: "star.yaml"
        schema: "https://noblefactor.com/schemas/star-v1.json"
      - pattern: "**/packages-manifest.yaml"
        schema: "https://noblefactor.com/schemas/packages-manifest-v1.json"
      - pattern: ".github/workflows/*.yaml"
        schema: "https://json.schemastore.org/github-workflow.json"
    exclude:
      - "**/testdata/**"

Commands:

star lint yaml                # Validate YAML/JSON against schemas

Implementation:

  1. Create com.noblefactor.star.LintYaml extension
  2. Add yaml_lint builtin receiver with validate(path, schema), fetch_schema(url) (fetch and cache remote schemas)
  3. Starlark script: read schema mappings from config, glob matching files, validate against schemas

Phase 8: Migration complete — Partial

Remaining:

  • Verify all repos use generated .pre-commit-config.yaml (not manually maintained)
  • Update CI (.github/workflows/ci.yaml) to use star lint all instead of individual lint commands
  • Update documentation

Files to Create/Modify

File Action Phase
star/extensions/com.noblefactor.star.LintStarlark/ Create extension 2
internal/starlark/receiver_starlark_lint.go Create — buildifier + complexity builtins 2
internal/starlark/receiver_lint.go Modify — add buildifier to tools check 2
star/extensions/com.noblefactor.star.LintYaml/ Create extension 6
internal/starlark/receiver_yaml_lint.go Create — JSON schema validation builtins 6
.github/workflows/ci.yaml Modify — use star lint all 8

Configuration Schema

Full star.yaml quality gate schema (implemented sections marked):

lint:
  go:           # ✅ Implemented
    enabled: true
    config:
      linters:
        enable: [gofmt, govet, errcheck, staticcheck]
  shell:        # ✅ Implemented
    enabled: true
    shellcheck:
      severity: warning
    shfmt:
      indent: 4
  markdown:     # ✅ Implemented (includes frontmatter)
    enabled: true
    config:
      MD013: false
      MD033: false
  starlark:     # ❌ Not implemented
    enabled: true
    buildifier:
      warnings: all
    complexity:
      max_function_lines: 50
      max_nesting_depth: 4
      max_conditionals: 10
  copyright:    # ✅ Implemented
    enabled: true
    license: MIT
    holder: Noble Factor
    exclude:
      - "**/testdata/**"
      - "**/vendor/**"
  yaml:         # ❌ Not implemented
    enabled: true
    schemas:
      - pattern: "star.yaml"
        schema: "https://noblefactor.com/schemas/star-v1.json"

precommit:      # ✅ Implemented (generation)
  hooks:
    - id: star-lint-all
      name: Star quality gate
      entry: star lint all
      language: system

hooks:          # ✅ Implemented (native)
  pre-commit:
    - lint all
  pre-push:
    - test go

Dependencies

Related

Open Questions

  • Should star lint yaml validate star.yaml against its own schema (self-referential)?
  • What's the minimum set of linters for a repo? (Go-only repo doesn't need shellcheck)
  • Should there be a star lint --list to show available linters and their status?

Sub-issues

Sub-issues

2 of 8 Issues completed
Loading 8 sub-issues

Activity

  1. David-Noble-at-work commented on Sep 5, 2026

    @David-Noble-at-work
    ContributorAuthor

    Phase 2, star lint starlark, is #721. Its charter (docs/plans/lint-starlark.md) makes the case that buildifier alone would have caught none of the registry's 28 broken .star files — every one was syntactically valid — and that the useful check is resolution against the generated provider surface, which starindex already parses. So Phase 2 is larger than "buildifier + complexity" and #721 is where that is worked out. Placed 2026-09-05 as a task under this feature; its plan should move to docs/plans/feature/721-lint-starlark.md when a branch opens.

    For what it is worth: noblefactor-ops#140's four new .star files are gated locally with buildifier -mode=check -lint=warn in the PR script, because nothing in either repository's CI reads Starlark yet. That is the gap this row closes.

  2. David-Noble-at-work commented on Sep 5, 2026

    @David-Noble-at-work
    ContributorAuthor

    Correction to the comment above, on where Phase 2 lives: ruled 2026-09-05, the Starlark linter is a built-in in Go beside the code model, not an extension. star lint starlark stays as the row's name; #721 is its implementation. Interim: buildifier as a gate now.

  3. 11 remaining items

  4. David-Noble-at-work commented on Nov 7, 2026

    @David-Noble-at-work
    ContributorAuthor

    Restructured on 2026-11-06 by the owner's word, in the Area review of NobleFactor/noblefactor-engprod#452.

    This feature is now Engineering: devlore-cli's own quality gate run through star, under Epic #452, Code quality, coverage, and the lint gates. Its star work, which ships in the star binary and is Product, moved to the command features of Epic #1065, Star:

    Issue Moved to
    Bug #343, checkLineWidth Feature #1087, the goast provider
    Bug #994 and Bug #998, go-style Feature #1075, star lint go-style
    Bug #997, Bug #1000 and Task #1197, copyright Feature #1073, star lint copyright
    Bug #1007, markdown on Windows Feature #1076, star lint markdown
    Task #1194, YAML and JSON against their schemas Feature #837, the lint provider

    It keeps Bug #964 (CI runs none of star lint's four checks), Bug #1006 (make complexity and GOBIN), Task #672 (the pre-commit hook runs star lint shell) and Task NobleFactor/noblefactor-engprod#231 (Test-Frontmatter.sh is deleted). Its closing still waits on its compliance audit and code review, with the owner's sign-off.

  5. David-Noble-at-work commented on Nov 9, 2026

    @David-Noble-at-work
    ContributorAuthor

    star github triage sweep added this issue to Triage: devlore, for the rule it breaks:

    • no-evidence: no Evidence of completion section
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions