Skip to content

Commit e6f5dff

Browse files
committed
huihuihui
1 parent 75f9284 commit e6f5dff

34 files changed

Lines changed: 1700 additions & 115 deletions

‎AGENT_NOTES.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ before broad inventory commands like unfiltered `symbols`.
9797
| Get focused pre-edit context | `gosherpa context symbol <target> --use-snapshot --max-* --json` when a fresh snapshot exists; otherwise `gosherpa context symbol|file|package|diff ... --max-* ... --json` |
9898
| Find references | `gosherpa refs <target> --json` |
9999
| Find direct callers or callees | `gosherpa callers <target> --json` and `gosherpa callees <target> --json` |
100-
| Explore call reachability | `gosherpa entrypoints <target> --json`, `gosherpa path <from> <to> --json`, or `gosherpa paths <from> <to> --json` |
100+
| Explore call reachability | `gosherpa entrypoints <target> --json`, `gosherpa path <from> <to> --json`, or `gosherpa paths <from> <to> --json`; `context symbol`, `context diff`, `impact symbol`, `impact diff`, `pr`, and `agent context` may include `entrypointSummary` |
101101
| Inspect package relationships | `gosherpa packages --json`, `gosherpa deps <package> --json`, or `gosherpa deps --all --json` |
102102
| Inspect interface relationships | `gosherpa interface <interface> --json`; add `--use-snapshot` when a fresh snapshot exists. Use `gosherpa implementers <interface> --json` or `gosherpa interfaces <type> --json` for focused lists |
103103
| Analyze changed files | `gosherpa agent context --base HEAD --use-snapshot --max-files 20 --max-symbols 40 --max-tests 20 --max-bytes 12000 --json`; use focused `context diff`, `impact diff`, and `pr` commands for drill-down |
@@ -240,8 +240,13 @@ Current analysis is intentionally conservative:
240240
falls back to AST/per-package analysis when needed.
241241
- Caller, callee, path, entrypoint, and interface impact analysis may miss
242242
dynamic dispatch, reflection, reassigned or escaping function values,
243-
goroutine starts, function literals, build-tag edge cases, aliases, and some
244-
generic cases.
243+
custom routers, build-tag edge cases, aliases, and some generic cases.
244+
- Entrypoint records and `entrypointSummary` keep certainty explicit:
245+
`direct` means repository-local static calls reach the target; `possible`
246+
means a public/runtime heuristic or bounded possible wiring such as
247+
goroutines, function literals, or stdlib `net/http` registration. This
248+
evidence is separate from direct caller arrays and does not currently change
249+
target-risk scoring.
245250
- Test files are excluded from several analyses by default; use command flags
246251
such as `--tests` where available.
247252
- Diff impact is hunk-based and does not infer every semantic consequence of

‎PRIORITY_IMPLEMENTATION_PLAN.md‎

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -912,20 +912,20 @@ Goal: represent program entrypoints and runtime wiring as reusable evidence.
912912

913913
Tasks:
914914

915-
- [ ] Centralize entrypoint records for:
915+
- [x] Centralize entrypoint records for:
916916
- `main.main`
917917
- tests with `--tests`
918918
- exported functions
919919
- no-local-caller functions
920920
- stdlib `net/http` handlers already supported
921921
- visible goroutine origins already supported
922-
- [ ] Include kind, reason, source range, reachable target when known,
922+
- [x] Include kind, reason, source range, reachable target when known,
923923
certainty, and limitations.
924-
- [ ] Keep framework-specific routers out of scope unless a bounded pattern is
924+
- [x] Keep framework-specific routers out of scope unless a bounded pattern is
925925
explicitly accepted.
926-
- [ ] Add fixtures for command packages, HTTP handlers, tests, workers, and
926+
- [x] Add fixtures for command packages, HTTP handlers, tests, workers, and
927927
unsupported custom routing.
928-
- [ ] Define and implement the bounded entrypoint summary used by context,
928+
- [x] Define and implement the bounded entrypoint summary used by context,
929929
impact, PR, and the agent workflow: counts by kind, top reachable
930930
examples, certainty labels, source locations, and limitations.
931931

@@ -952,22 +952,35 @@ go test ./internal/sherpa ./internal/agentworkflow ./internal/agentcontext ./int
952952
go run ./cmd/gosherpa entrypoints ./internal/sherpa.PlanTests --json
953953
```
954954

955+
Verification note, 2026-07-18:
956+
957+
- Selected `<base-ref>`: `HEAD`, resolved with
958+
`git rev-parse --verify HEAD` to
959+
`75f92848901056843985b02589c3e7be142672ac`.
960+
- Added centralized entrypoint evidence records with reason, certainty,
961+
reachable target, source ranges, and limitations.
962+
- Added focused worker/goroutine, stdlib HTTP, test-entrypoint, command-package,
963+
and non-function/custom-wiring limitation coverage in the existing call and
964+
golden fixtures.
965+
- Ran
966+
`go test ./internal/sherpa ./internal/agentcontext ./internal/impact ./internal/agentworkflow ./cmd/gosherpa`.
967+
955968
### Slice 3.4: Entrypoints In Context, Impact, PR, And Agent Workflow
956969

957970
Goal: show how inspected or changed code is reached.
958971

959972
Tasks:
960973

961-
- [ ] Add bounded entrypoint summaries to `context symbol`, `impact symbol`,
974+
- [x] Add bounded entrypoint summaries to `context symbol`, `impact symbol`,
962975
`context diff`, `impact diff`, `pr`, and the agent workflow where
963976
relevant.
964-
- [ ] Keep entrypoint evidence separate from direct caller evidence.
965-
- [ ] Include possible runtime paths only when certainty labels and limitations
977+
- [x] Keep entrypoint evidence separate from direct caller evidence.
978+
- [x] Include possible runtime paths only when certainty labels and limitations
966979
are clear.
967-
- [ ] Update target risk scoring only if entrypoint evidence materially changes
980+
- [x] Update target risk scoring only if entrypoint evidence materially changes
968981
blast-radius judgment; document the rule.
969-
- [ ] Add human output that is concise enough not to crowd out tests and risk.
970-
- [ ] Update golden JSON fixtures and schema docs.
982+
- [x] Add human output that is concise enough not to crowd out tests and risk.
983+
- [x] Update golden JSON fixtures and schema docs.
971984

972985
Primary files:
973986

@@ -993,20 +1006,35 @@ go run ./cmd/gosherpa context symbol ./internal/sherpa.PlanTests --use-snapshot
9931006
go run ./cmd/gosherpa agent context --base <base-ref> --use-snapshot --json
9941007
```
9951008

1009+
Verification note, 2026-07-18:
1010+
1011+
- Selected `<base-ref>`: `HEAD`, resolved with
1012+
`git rev-parse --verify HEAD` to
1013+
`75f92848901056843985b02589c3e7be142672ac`.
1014+
- Added `entrypointSummary` to `context symbol`, `context diff`,
1015+
`impact symbol`, `impact diff`, `pr`, and `agent context`; direct callers
1016+
and entrypoint evidence remain separate.
1017+
- Target-risk scoring was intentionally unchanged because entrypoint evidence
1018+
improves reachability planning but does not by itself prove broader blast
1019+
radius than affected packages, references, interfaces, tests, warnings, or
1020+
snapshot fallback.
1021+
- Ran
1022+
`go test ./internal/sherpa ./internal/agentcontext ./internal/impact ./internal/agentworkflow ./cmd/gosherpa`.
1023+
9961024
### Slice 3.5: Test And Entrypoint Documentation Pass
9971025

9981026
Goal: keep users and agents calibrated.
9991027

10001028
Tasks:
10011029

1002-
- [ ] Update `docs/CLI_REFERENCE.md`, `docs/STATUS.md`,
1030+
- [x] Update `docs/CLI_REFERENCE.md`, `docs/STATUS.md`,
10031031
`docs/product/JSON_SCHEMA_V1.md`, `docs/product/CONTEXT_SCHEMA_V1.md`,
10041032
`AGENT_NOTES.md`, and `llms.txt`.
1005-
- [ ] Document the difference between direct tests, related tests, contract
1033+
- [x] Document the difference between direct tests, related tests, contract
10061034
tests, caller-package tests, integration-like tests, and fallbacks.
1007-
- [ ] Document entrypoint certainty and unsupported runtime wiring.
1008-
- [ ] Ensure examples use `<base-ref>` unless recording a verified local ref.
1009-
- [ ] Run schema and golden tests.
1035+
- [x] Document entrypoint certainty and unsupported runtime wiring.
1036+
- [x] Ensure examples use `<base-ref>` unless recording a verified local ref.
1037+
- [x] Run schema and golden tests.
10101038

10111039
Primary files:
10121040

@@ -1027,6 +1055,17 @@ go test ./cmd/gosherpa
10271055
go test ./...
10281056
```
10291057

1058+
Verification note, 2026-07-18:
1059+
1060+
- Selected `<base-ref>`: `HEAD`, resolved with
1061+
`git rev-parse --verify HEAD` to
1062+
`75f92848901056843985b02589c3e7be142672ac`.
1063+
- Updated CLI, status, JSON schema, context schema, agent notes, and llms
1064+
guidance for entrypoint certainty, bounded `entrypointSummary`, unsupported
1065+
custom routers/runtime wiring, and unchanged target-risk scoring.
1066+
- Ran `GOCACHE=/private/tmp/gosherpa-gocache go test ./cmd/gosherpa`.
1067+
- Ran `GOCACHE=/private/tmp/gosherpa-gocache go test ./...`.
1068+
10301069
Phase 3 is done when:
10311070

10321071
- Test recommendations are stronger, grouped, and evidence-backed.
@@ -1039,15 +1078,15 @@ Goal: prove the three tracks work together as one product workflow.
10391078

10401079
Tasks:
10411080

1042-
- [ ] Select and record `<base-ref>`.
1043-
- [ ] Run `git rev-parse --verify <base-ref>` and record the resolved commit.
1044-
- [ ] Refresh or create a snapshot:
1081+
- [x] Select and record `<base-ref>`.
1082+
- [x] Run `git rev-parse --verify <base-ref>` and record the resolved commit.
1083+
- [x] Refresh or create a snapshot:
10451084

10461085
```bash
10471086
go run ./cmd/gosherpa snapshot --json
10481087
```
10491088

1050-
- [ ] Run:
1089+
- [x] Run:
10511090

10521091
```bash
10531092
git rev-parse --verify <base-ref>
@@ -1062,7 +1101,7 @@ Tasks:
10621101
go run ./cmd/gosherpa entrypoints ./internal/sherpa.PlanTests --json
10631102
```
10641103

1065-
- [ ] Verify the outputs answer:
1104+
- [x] Verify the outputs answer:
10661105
- what changed or what is inspected
10671106
- where relevant code lives
10681107
- who calls it and what it calls
@@ -1073,10 +1112,10 @@ Tasks:
10731112
- how wide the change appears
10741113
- what uncertainty remains
10751114
- which command or test should run next
1076-
- [ ] Update `docs/STATUS.md` with completed readiness improvements.
1077-
- [ ] Update `docs/product/MUST_USE_READINESS.md` if readiness estimate or
1115+
- [x] Update `docs/STATUS.md` with completed readiness improvements.
1116+
- [x] Update `docs/product/MUST_USE_READINESS.md` if readiness estimate or
10781117
priority order changes.
1079-
- [ ] Update `README.md`, `AGENT_NOTES.md`, and `llms.txt` if workflows or
1118+
- [x] Update `README.md`, `AGENT_NOTES.md`, and `llms.txt` if workflows or
10801119
agent guidance materially change.
10811120

10821121
Exit criteria:
@@ -1086,6 +1125,35 @@ Exit criteria:
10861125
- Test and entrypoint evidence improves next-action planning.
10871126
- Human output and JSON output remain stable enough for daily use.
10881127

1128+
Verification note, 2026-07-18:
1129+
1130+
- Selected `<base-ref>`: `HEAD`, resolved with
1131+
`git rev-parse --verify HEAD` to
1132+
`75f92848901056843985b02589c3e7be142672ac`.
1133+
- Refreshed `.gosherpa/snapshot.json` with
1134+
`GOCACHE=/private/tmp/gosherpa-gocache go run ./cmd/gosherpa snapshot --json`;
1135+
the snapshot command reported status `valid`, created at
1136+
`2026-07-18T11:16:58Z`, with 136 files, 12 packages, 2833 symbols, and
1137+
36985 relationship records.
1138+
- Ran `GOCACHE=/private/tmp/gosherpa-gocache go test ./...`.
1139+
- Ran the final workflow smoke set:
1140+
`doctor --json`, `agent context --base HEAD --use-snapshot --json`,
1141+
`context diff --base HEAD --use-snapshot --json`,
1142+
`impact diff --base HEAD --use-snapshot --json`,
1143+
`tests affected --base HEAD --use-snapshot --json`,
1144+
`pr --base HEAD --use-snapshot --json`,
1145+
`context symbol ./internal/sherpa.PlanTests --use-snapshot --json`, and
1146+
`entrypoints ./internal/sherpa.PlanTests --json`.
1147+
- Verified the diff workflows used
1148+
`snapshot+git-diff+typechecked+ast` where applicable; `agent context`
1149+
reported a valid, fresh, reused snapshot. The standalone and embedded
1150+
entrypoint outputs include certainty, reason, reachable target, source
1151+
locations, and explicit limitations. Large agent/context outputs preserve
1152+
byte-budget truncation metadata for entrypoint counts and examples.
1153+
- `doctor --json` completed with the expected nested-module warning for the
1154+
CLI testdata modules. `docs/product/MUST_USE_READINESS.md` did not need a
1155+
readiness estimate or priority-order change in this pass.
1156+
10891157
## Out Of Scope Until This Plan Is Done
10901158

10911159
- MCP or long-running server mode

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ output, human-readable tables by default, and JSON when you want automation.
3838
| Which interfaces and implementers are involved? | `gosherpa interface <interface>`, `gosherpa implementers <interface>` |
3939
| Which tests are related? | `gosherpa tests <target>`, `gosherpa tests affected --base <ref>` |
4040
| What might this change affect? | `gosherpa context diff --base <ref>`, `gosherpa impact diff --base <ref>` |
41-
| What should an agent read before editing? | `gosherpa context symbol|file|package|diff ... --json` |
41+
| What should an agent read before editing? | `gosherpa agent context --base <ref> --use-snapshot --json` |
4242

4343
## Quickstart
4444

@@ -67,6 +67,7 @@ go build -o gosherpa ./cmd/gosherpa
6767
./gosherpa snapshot
6868
./gosherpa analyze --use-snapshot
6969
./gosherpa context symbol ParseFile --use-snapshot --json
70+
./gosherpa agent context --base HEAD --use-snapshot --json
7071
./gosherpa impact diff --base HEAD --use-snapshot
7172
./gosherpa pr --base HEAD --use-snapshot --json
7273
```
@@ -155,7 +156,7 @@ reused by:
155156
- `analyze`, `symbols`, `symbol`, `search`, and `packages --tests`
156157
- `refs`, `callers`, `callees`, `implementers`, `interface`, and `interfaces`
157158
- `context symbol` and `impact symbol`
158-
- `context diff`, `impact diff`, `tests affected`, and `pr` for current
159+
- `agent context`, `context diff`, `impact diff`, `tests affected`, and `pr` for current
159160
changed-symbol inventory and selected relationship subanalysis
160161

161162
If a snapshot is missing, stale, invalid, or does not contain the relationship
@@ -168,6 +169,7 @@ Agents should prefer bounded, task-specific context over broad inventory dumps:
168169

169170
```bash
170171
gosherpa doctor --json
172+
gosherpa agent context --base HEAD --use-snapshot --max-files 20 --max-symbols 40 --max-tests 20 --max-bytes 12000 --json
171173
gosherpa context diff --base HEAD --use-snapshot --max-files 20 --max-symbols 40 --max-tests 20 --max-bytes 12000 --json
172174
gosherpa context symbol ./internal/sherpa.ParseFile --use-snapshot --max-references 20 --max-tests 10 --max-bytes 12000 --json
173175
gosherpa tests affected --base HEAD --use-snapshot --json

‎cmd/gosherpa/cli_json.go‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ type impactDiffJSONData struct {
102102
AffectedInterfaces []string `json:"affectedInterfaces"`
103103
AffectedImplementations []string `json:"affectedImplementations"`
104104
InterfaceAnalysisMode string `json:"interfaceAnalysisMode,omitempty"`
105+
EntryPointSummary *sherpa.EntryPointSummary `json:"entrypointSummary,omitempty"`
105106
AffectedTests []impactengine.RelatedTest `json:"affectedTests"`
106107
TestAnalysisMode string `json:"testAnalysisMode,omitempty"`
107108
TestCommands []string `json:"testCommands"`
@@ -394,6 +395,10 @@ func impactDiffJSONResult(report impactengine.ImpactReport) impactengine.ImpactR
394395
report.AffectedInterfaces = nonNilSlice(report.AffectedInterfaces)
395396
report.AffectedImplementations = nonNilSlice(report.AffectedImplementations)
396397
report.InterfaceAnalysisMode = strings.TrimSpace(report.InterfaceAnalysisMode)
398+
if report.EntryPointSummary != nil {
399+
summary := sherpa.NormalizeEntryPointSummary(*report.EntryPointSummary)
400+
report.EntryPointSummary = &summary
401+
}
397402
report.AffectedTests = nonNilSlice(report.AffectedTests)
398403
report.TestAnalysisMode = strings.TrimSpace(report.TestAnalysisMode)
399404
report.TestCommands = nonNilSlice(report.TestCommands)
@@ -421,6 +426,7 @@ func impactDiffJSONDataFromReport(report impactengine.ImpactReport, analysisMode
421426
AffectedInterfaces: report.AffectedInterfaces,
422427
AffectedImplementations: report.AffectedImplementations,
423428
InterfaceAnalysisMode: report.InterfaceAnalysisMode,
429+
EntryPointSummary: report.EntryPointSummary,
424430
AffectedTests: report.AffectedTests,
425431
TestAnalysisMode: report.TestAnalysisMode,
426432
TestCommands: report.TestCommands,
@@ -740,7 +746,7 @@ func callPathsJSONDataFromResult(result sherpa.CallPathsResult) callPathsJSONDat
740746
}
741747

742748
func entrypointsJSONResult(result sherpa.EntryPointsResult) sherpa.EntryPointsResult {
743-
result.EntryPoints = nonNilSlice(result.EntryPoints)
749+
result.EntryPoints = sherpa.NormalizeEntryPoints(result.EntryPoints)
744750
result.Warnings = nonNilSlice(result.Warnings)
745751

746752
return result
@@ -764,6 +770,10 @@ func contextSymbolJSONResult(report agentcontext.Report) agentcontext.Report {
764770
report.AffectedInterfaces = nonNilSlice(report.AffectedInterfaces)
765771
report.AffectedImplementations = nonNilSlice(report.AffectedImplementations)
766772
report.InterfaceAnalysisMode = strings.TrimSpace(report.InterfaceAnalysisMode)
773+
if report.EntryPointSummary != nil {
774+
summary := sherpa.NormalizeEntryPointSummary(*report.EntryPointSummary)
775+
report.EntryPointSummary = &summary
776+
}
767777
report.RelatedTests = nonNilSlice(report.RelatedTests)
768778
report.TestAnalysisMode = strings.TrimSpace(report.TestAnalysisMode)
769779
report.TestCommands = nonNilSlice(report.TestCommands)
@@ -834,6 +844,10 @@ func contextDiffJSONResult(report agentcontext.DiffReport) agentcontext.DiffRepo
834844
report.AffectedInterfaces = nonNilSlice(report.AffectedInterfaces)
835845
report.AffectedImplementations = nonNilSlice(report.AffectedImplementations)
836846
report.InterfaceAnalysisMode = strings.TrimSpace(report.InterfaceAnalysisMode)
847+
if report.EntryPointSummary != nil {
848+
summary := sherpa.NormalizeEntryPointSummary(*report.EntryPointSummary)
849+
report.EntryPointSummary = &summary
850+
}
837851
report.AffectedTests = nonNilSlice(report.AffectedTests)
838852
report.TestAnalysisMode = strings.TrimSpace(report.TestAnalysisMode)
839853
report.TestCommands = nonNilSlice(report.TestCommands)
@@ -1061,7 +1075,7 @@ func entrypointLimitations(analysisMode string) []string {
10611075
limitations := callLimitations(analysisMode)
10621076
limitations = append(limitations,
10631077
"Entry point classification is heuristic: main functions, test functions, selected stdlib net/http handlers, exported functions, and functions with no local callers.",
1064-
"Framework-specific routers, custom runtime wiring, and CLI command handlers are not inferred yet.",
1078+
"Framework-specific routers, custom routers, custom runtime wiring, and CLI command handlers are not inferred yet.",
10651079
)
10661080

10671081
return limitations

0 commit comments

Comments
 (0)