Skip to content

Roadmap & TODO

This page tracks the current status of starlark-go-x, what’s been accomplished, and what still needs to be done before upstream contribution.

Implemented Features Complete

Section titled “Implemented Features ”
FeatureStatusBranchDescription
OnExec✅ Donecoverage-hooksLine coverage instrumentation
OnBranch✅ Donebranch-coverageBranch coverage (if/else, and/or)
OnFunctionEnter✅ Donefunction-coverageFunction entry tracking
OnFunctionExit✅ Donefunction-coverageFunction exit + return value
OnIteration✅ Doneloop-coverageFor-loop iteration tracking
PositionAt✅ Donecoverage-hooksMap PC to source position
Type Annotations✅ Donetype-hintsParse Python-style type hints

All features are merged into the trunk branch.

1. Performance Validation Required

Section titled “1. Performance Validation ”
  1. Baseline Benchmark

    Run standard starlark-go benchmarks against upstream (unmodified) version.

    Terminal window
    cd google/starlark-go
    go test -bench=. ./starlark/... > baseline.txt
  2. A/B Comparison - Hooks Disabled

    Run same benchmarks on starlark-go-x with all hooks set to nil.

    Terminal window
    cd starlark-go-x/trunk
    go test -bench=. ./starlark/... > hooks-disabled.txt
    benchstat baseline.txt hooks-disabled.txt
  3. A/B Comparison - Hooks Enabled

    Run benchmarks with hooks enabled (but doing minimal work).

    Terminal window
    # Modify benchmark to set OnExec = func(fn, pc) {}
    go test -bench=. ./starlark/... > hooks-enabled.txt
    benchstat hooks-disabled.txt hooks-enabled.txt
  4. Document Results

    • If hooks disabled shows >1% regression: investigate and fix
    • If hooks enabled shows expected overhead: document it
    • Create benchmark comparison table for upstream proposal
ScenarioExpected Overhead
Hooks nil (disabled)~0% (nil pointer check only)
OnExec enabled5-15% per instruction
OnBranch enabled<1% (only on branches)
OnFunctionEnter/Exit<1% (only on calls)
OnIteration enabled<1% (only on loops)

2. Code Style Cleanup Required

Section titled “2. Code Style Cleanup ”

Our code has verbose comments marked with TODO(upstream). Before proposing:

  1. Remove verbose comments

    // Current (verbose):
    // OnExec is called before each bytecode instruction is executed, if non-nil.
    // This hook enables coverage instrumentation, debugging, and tracing.
    // The callback receives the executing function and program counter;
    // use fn.PositionAt(pc) to resolve the source position.
    // For performance, avoid calling PositionAt on every instruction—deduplicate by line.
    // TODO(upstream): trim verbose comments to match codebase style before proposing.
    OnExec func(fn *Function, pc uint32)
    // Target (concise, matches upstream style):
    // OnExec, if non-nil, is called before each bytecode instruction.
    OnExec func(fn *Function, pc uint32)
  2. Review upstream comment style

    Study existing Thread fields in google/starlark-go for tone and length.

  3. Create clean branch

    Fork from trunk, clean up comments, prepare for PR.

Current test status:

TestStatusFile
TestOnExec✅ Passeval_test.go
TestOnExecCoverage✅ Passeval_test.go
TestOnBranch✅ Passeval_test.go
TestOnBranchShortCircuit✅ Passeval_test.go
TestOnFunctionEnterExit✅ Passeval_test.go
TestOnFunctionExitResult✅ Passeval_test.go
TestOnIteration✅ Passeval_test.go
TestOnIterationEmptyLoop✅ Passeval_test.go

Additional tests needed:

  • Test hooks with recursive functions
  • Test hooks with nested functions (closures)
  • Test hooks with comprehensions
  • Test hooks with exceptions/errors
  • Test thread-safety with concurrent execution
  • Benchmark tests (see above)

4. Documentation for Upstream Required

Section titled “4. Documentation for Upstream ”

Prepare materials for the upstream proposal:

  • Design document explaining use cases (coverage, profiling, debugging)
  • API documentation in godoc format
  • Example usage in documentation
  • Performance analysis results

Future Enhancements Nice to Have

Section titled “Future Enhancements ”
HookUse CasePriority
OnLoadTrack module loadingLow
OnErrorTrack error locationsMedium
OnBuiltinCallTrack built-in function callsLow

Not currently planned, but could be added:

FeatureDescriptionComplexity
MC/DC CoverageModified Condition/Decision CoverageHigh
Path CoverageTrack all execution pathsVery High
Data Flow CoverageTrack variable def/useHigh

These are rarely needed outside safety-critical systems and would require significant AST-level changes.

  • Sky’s go.mod uses starlark-go-x via replace directive
  • skytest --coverage uses OnExec for line coverage
  • skycov reports line coverage
  • Update Sky to use OnBranch for branch coverage
  • Update Sky to use OnFunctionEnter for function coverage
  • Update skycov reporters (Cobertura branch-rate, LCOV BRDA)
  • Add branch/function coverage to skytest output
PhaseTaskEffort
1Performance benchmarking2-4 hours
2Additional tests2-3 hours
3Code cleanup1-2 hours
4Upstream proposal draft2-3 hours
5Sky integration (branch/function)3-4 hours

To work on starlark-go-x:

Terminal window
# Clone with worktrees
git clone --bare https://github.com/albertocavalcante/starlark-go-x.git .bare
echo "gitdir: ./.bare" > .git
# Create worktrees
git worktree add main main
git worktree add trunk trunk
# Work on new feature
git branch my-feature trunk
git worktree add my-feature my-feature
cd my-feature
# ... make changes ...
go test ./...
git commit -m "feat: my feature"
# Merge to trunk (linear history)
cd ../trunk
git merge --ff-only my-feature
git push origin trunk