Skip to content

Contributing Vault Coding skills - #44

Open
arnabkaycee wants to merge 2 commits into
mainfrom
arnabkaycee/vault-code-skills
Open

Contributing Vault Coding skills#44
arnabkaycee wants to merge 2 commits into
mainfrom
arnabkaycee/vault-code-skills

Conversation

@arnabkaycee

@arnabkaycee arnabkaycee commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds 7 agent skills for contributing code to the HashiCorp Vault codebase. These skills provide structured, actionable guidance for common development tasks ranging from terminology lookups to security-critical implementation patterns.

Skills Added

Skill Description
vault-acronym-helper Defines and normalizes Vault-specific terminology (e.g. auth method vs auth backend, root key vs master key) with a full acronym reference
vault-architecture Covers repository structure (api/, sdk/, vault/), CE/EE code separation via build tags, API design patterns, plugin architecture, and storage key conventions
vault-debugging Systematic debugging workflow for build failures, race conditions, nil pointer panics, and context deadline errors; includes Delve debugger usage and timing guidance for long-running builds
vault-performance Profiling with pprof, writing and comparing benchmarks, and common optimization patterns (allocation reduction, sync.Pool, batching, parallel processing)
vault-security Security-first implementation rules: no secrets in logs, constant-time comparisons via crypto/subtle, input validation at all API boundaries, sanitized error messages, and responsible disclosure guidance
vault-test-authoring Test design decisions (unit vs core tests), the DoTest pattern for reusable cluster-agnostic tests, API-only (blackbox) testing, and external_tests/ package organization
vault-testing Commands for running CE/EE tests, race detection, integration/acceptance tests, build tag syntax, table-driven test patterns, and a pre-PR checklist

Reference Documents

The test-authoring skill includes 3 reference files:

  • CLUSTER_SETUP.md — cluster configuration options
  • DOTEST_EXAMPLES.md — complete DoTest pattern examples
  • REPLICATION_TESTING.md — Enterprise replication test setup
    The acronym-helper skill includes a full acronyms.md reference.

@arnabkaycee
arnabkaycee requested a review from a team as a code owner February 26, 2026 06:35
@github-actions

Copy link
Copy Markdown

Tessl Skill Review Results

Skill Status Review Score
vault/development/skills/architecture PASSED 90%
vault/development/skills/debugging PASSED 96%
vault/development/skills/performance PASSED 96%
vault/development/skills/security PASSED 85%
vault/development/skills/test-authoring PASSED 93%
vault/development/skills/testing PASSED 96%
vault/understanding/skills/acronym-helper PASSED 95%

Checks: frontmatter validity, required fields, body structure, examples, line count.
Review Score is informational — not used for pass/fail gating.

Comment thread vault/development/skills/architecture/SKILL.md
Comment on lines +212 to +213
- EE adds significant capabilities
- Single codebase needed

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sure if I understand what these two mean. Can you ellaborate?

sdk/ # Plugin SDK
```

Everything in `vault/` is internal - never import directly.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only applies to external projects though.


```
vault/ # Core server (INTERNAL)
├── logical/ # Backend interfaces

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no vault/logical directory.

└── credential/ # Auth methods

command/ # CLI commands
http/ # HTTP API handlers

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be confusing because most of the HTTP API handlers that don't live here. This is more like the lower-level parts of our HTTP API and surrounding tooling, together with some of the less conventional HTTP handlers that don't use the SDK so much.

Comment thread vault/development/skills/architecture/SKILL.md
Comment thread vault/development/skills/architecture/SKILL.md
| Stop a node | `cluster.StopCore(t, nodeIndex)` | Call `WaitForActiveNode(t, cluster)` to verify another node activated | Assert stopped node's client returns errors (unhealthy/sealed), not just that a new active exists |
| Seal all nodes | `testhelpers.SealCores(t, cluster)` | Before DR promotion: assert `health.Sealed == true` on all old-primary nodes | No assertion that writes to the old primary during sealed state return appropriate errors |
| Unseal all nodes | `testhelpers.EnsureCoresUnsealed(t, cluster)` | Assert `health.Sealed == false` and `health.Initialized == true` on each node | No re-check of replication state post-unseal |
| Inject replication failure mode | `vault.SetReplicationFailureMode(core, vault.ReplicationFailureModeReindexNeeded)` | Assert `sys/replication/status` surfaces a warning; then assert promote/demote succeeds or fails as intended | Tests check the result of `promote` but do not verify the failure mode appears in status warnings before the operation |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very niche.


---

### Simulate Node/Primary Failure

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these don't belong in the replication testing section IMO.

secondaryClient.WithRequestCallbacks(api.RequireState(state)).Logical().Read(path)
```

To verify 412 actually fired (invalidation was async):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some confusion here I think. These callbacks (and client-controlled consistency aka CCC in general) doesn't actually take into account async invalidation, they only check to ensure that the upstream WAL has been received and applied to storage locally. This is actually a big limitation and so if the code being tested uses async invalidation, you need to poll instead of relying solely on CCC.


### Pattern 3: Force Synchronous Invalidation (Deterministic Tests)

Set `AsyncInvalidationChannelSize = 0` to force FSM to block until invalidation completes:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm the only one who's ever done this, and it's very much a last resort. We should avoid it whenever possible because it precludes using t.Parallel.

|----------------|---------|----------|
| `NewTestCluster` | `vault.NewTestCluster` | Default choice for core tests |
| `NewTestDockerCluster` | Docker containers | Cross-binary testing |
| `NewTestExecDevCluster` | Subprocesses | External process testing |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove this.

@ncabatoff

Copy link
Copy Markdown

I would drastically scale back the replication testing notes. We can distinguish between two kinds of replication testing: tests written by devs modifying how replication works, and tests written by devs who want to verify that their code behaves properly in replication scenarios. We should cater more to the latter, for whom most of what you wrote about replication is overkill.

"time"

"github.com/hashicorp/vault/sdk/helper/testcluster"
"github.com/stretchr/testify/require"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to add a skill to make sure we avoid using t.Fatalf instead use testify/require?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants