* perf(httpclient): remember the server's external-dependency policy across processes Every bd ready over an HTTP workspace fetched GET /v0/beads/context before its listing. listReadyWork itself needs no handshake; the fetch came from the external-dependency decorator asking ServerEnforcesExternalDependencyPolicy whether the server already applies the policy. In a one-shot CLI that is one extra round trip per process (about 54 ms at a 52 ms RTT) to relearn a bit that only changes when the server is restarted with a different composition. The store opened from a workspace now keeps that answer in the user cache directory (beads/http-policy/), keyed by the server URL and the project the workspace pinned at bd connect, for BEADS_HTTP_POLICY_CACHE_TTL (5 minutes by default; off disables it). A fresh entry answers the probe without dialing; a handshake this process already holds wins and refreshes the entry. A workspace with no project pin, and a store an embedder opens through OpenWith, are not cached. Writing the entry is best effort. The staleness this allows is bounded by the TTL: a server restarted without the policy within the window is still trusted to enforce it until the entry ages out. Carrying the policy on every response would close that window but needs a server change and does nothing for servers already deployed. Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(httpclient): claims and closes ask the server for the policy, never the cache Review follow-up to the policy cache. The claim and close guards (direct claim, claim-next, batch close, the lifecycle close and claim, and the legacy ClaimReadyIssue and CloseIssueChecked) handshake anyway, and a stale cached "the server enforces it" would stand down their client-side refusal of externally blocked work. Those entry points now mark their context with storage.WithLivePolicyProbe, and httpclient.Store answers such a probe from the server, refreshing the cache entry. Reads keep the cached answer. Tests: externaldeps TestClaimsAndClosesAskForALivePolicyProbe and TestRemoteClaimsAndClosesAskForALivePolicyProbe pin which entry points probe live (every claim and close) and which do not (ready listings), over a local and a remote store; httpclient TestALiveProbeSkipsThePolicyCache pins the store side; TestPolicyCacheRefusesEntriesItCannotTrust now also covers an entry written for another server URL. Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
374 lines
12 KiB
Python
374 lines
12 KiB
Python
load("@rules_go//go:def.bzl", "go_library", "go_test")
|
|
load("@rules_shell//shell:sh_test.bzl", "sh_test")
|
|
|
|
go_library(
|
|
name = "httpclient",
|
|
srcs = [
|
|
"accessors.go",
|
|
"backend_credential.go",
|
|
"batchapplier.go",
|
|
"batchcloser.go",
|
|
"batchcreator.go",
|
|
"batchgetter.go",
|
|
"blocked_querier.go",
|
|
"blocked_recomputer.go",
|
|
"blockedlister.go",
|
|
"bridge.go",
|
|
"ca.go",
|
|
"ca_permissions_other.go",
|
|
"ca_permissions_unix.go",
|
|
"claimer.go",
|
|
"commenter.go",
|
|
"conn_share.go",
|
|
"counter.go",
|
|
"credential.go",
|
|
"deleter.go",
|
|
"dependencyeditor.go",
|
|
"detail_reads.go",
|
|
"dial.go",
|
|
"dispatch.go",
|
|
"errors.go",
|
|
"heartbeater.go",
|
|
"insecure_credential_guard.go",
|
|
"journal.go",
|
|
"leasereclaimer.go",
|
|
"lifecycle.go",
|
|
"list_walk.go",
|
|
"memories.go",
|
|
"metadata.go",
|
|
"metadatacas.go",
|
|
"molecule.go",
|
|
"offrole.go",
|
|
"open_with.go",
|
|
"order.go",
|
|
"policy_cache.go",
|
|
"readyclaimer.go",
|
|
"refusal.go",
|
|
"register.go",
|
|
"relations.go",
|
|
"releaser.go",
|
|
"resolve.go",
|
|
"role_querier.go",
|
|
"role_reader.go",
|
|
"role_readycounter.go",
|
|
"roles_aux.go",
|
|
"roles_graph.go",
|
|
"servercontext.go",
|
|
"store.go",
|
|
"sweeper.go",
|
|
"target.go",
|
|
"target_seam.go",
|
|
"unlimited_read.go",
|
|
"unsupported.go",
|
|
"unsupported_gen.go",
|
|
"vocabulary.go",
|
|
"watch.go",
|
|
"writewire.go",
|
|
],
|
|
importpath = "github.com/steveyegge/beads/internal/httpclient",
|
|
visibility = ["//:__subpackages__"],
|
|
deps = [
|
|
"//internal/atomicfile",
|
|
"//internal/config",
|
|
"//internal/configfile",
|
|
"//internal/creds",
|
|
"//internal/httpapi/apigen",
|
|
"//internal/httpclient/encode",
|
|
"//internal/httpclient/wire",
|
|
"//internal/storage",
|
|
"//internal/storage/backends",
|
|
"//internal/storage/issueops",
|
|
"//internal/storage/sqlbuild",
|
|
"//internal/types",
|
|
"//internal/utils",
|
|
"//issueops",
|
|
"//journalops",
|
|
"//memoryops",
|
|
"@org_golang_x_net//http/httpproxy",
|
|
"@org_golang_x_net//idna",
|
|
],
|
|
)
|
|
|
|
go_test(
|
|
name = "httpclient_test",
|
|
# Unsharded, this package took 137-228s on rbe-west under --config=ci
|
|
# (BEADS_TEST_SKIP=dolt, no BEADS_TEST_EMBEDDED_DOLT; 2026-10-09), the test lane's
|
|
# longest single action. Two shards (rules_go deals tests out round-robin) put
|
|
# ~68s of measured test time on each; the three heaviest tests (31s, 20s, 13s)
|
|
# land on different shards. size=large/timeout=long follows the same convention
|
|
# as //internal/storage/embeddeddolt's go_test.
|
|
size = "large",
|
|
timeout = "long",
|
|
srcs = [
|
|
"backend_credential_test.go",
|
|
"batchapplier_test.go",
|
|
"blocked_querier_test.go",
|
|
"blockedlister_test.go",
|
|
"brief_test.go",
|
|
"bulk_roles_test.go",
|
|
"ca_permissions_unix_test.go",
|
|
"ca_test.go",
|
|
"ca_wrong_ca_test.go",
|
|
"completeness_test.go",
|
|
"composition_test.go",
|
|
"conn_share_test.go",
|
|
"counts_test.go",
|
|
"create_priority_test.go",
|
|
"credential_source_test.go",
|
|
"credential_test.go",
|
|
"dial_header_timeout_test.go",
|
|
"dial_test.go",
|
|
"dispatch_test.go",
|
|
"divergence_citation_gate_test.go",
|
|
"divergence_test.go",
|
|
"expected_revision_contract_test.go",
|
|
"gate_fields_test.go",
|
|
"getissue_miss_test.go",
|
|
"heartbeater_test.go",
|
|
"helpers_test.go",
|
|
"insecure_credential_guard_test.go",
|
|
"lifecycle_create_test.go",
|
|
"lifecycle_update_test.go",
|
|
"list_filters_test.go",
|
|
"list_scope_test.go",
|
|
"list_search_test.go",
|
|
"list_sort_test.go",
|
|
"memo_key_test.go",
|
|
"memo_retry_test.go",
|
|
"metadatacas_test.go",
|
|
"molecule_test.go",
|
|
"open_with_test.go",
|
|
"policy_cache_test.go",
|
|
"race_detector_off_test.go",
|
|
"race_detector_on_test.go",
|
|
"required_served_tier_test.go",
|
|
"roles_graph_cycles_test.go",
|
|
"roles_test.go",
|
|
"served_batch_apply_large_test.go",
|
|
"served_batch_apply_test.go",
|
|
"served_batch_close_test.go",
|
|
"served_batch_getter_test.go",
|
|
"served_blocked_external_test.go",
|
|
"served_blocked_lister_test.go",
|
|
"served_bridge_test.go",
|
|
"served_bulk_test.go",
|
|
"served_claim_lifecycle_test.go",
|
|
"served_commenter_test.go",
|
|
"served_config_test.go",
|
|
"served_config_write_test.go",
|
|
"served_counter_test.go",
|
|
"served_detail_reads_test.go",
|
|
"served_dualrun_test.go",
|
|
"served_dualwrite_history_test.go",
|
|
"served_external_dependency_policy_test.go",
|
|
"served_graph_aux_test.go",
|
|
"served_graph_counter_test.go",
|
|
"served_harness_test.go",
|
|
"served_heartbeater_test.go",
|
|
"served_hooks_test.go",
|
|
"served_issue_operations_test.go",
|
|
"served_journal_test.go",
|
|
"served_large_apply_timeout_test.go",
|
|
"served_lease_reclaimer_test.go",
|
|
"served_lifecycle_create_test.go",
|
|
"served_list_test.go",
|
|
"served_memories_deps_test.go",
|
|
"served_metadata_cas_test.go",
|
|
"served_molecule_test.go",
|
|
"served_participation_generation_test.go",
|
|
"served_project_swap_test.go",
|
|
"served_querier_test.go",
|
|
"served_reader_test.go",
|
|
"served_ready_claimer_test.go",
|
|
"served_readycounter_test.go",
|
|
"served_relations_test.go",
|
|
"served_releaser_test.go",
|
|
"served_test.go",
|
|
"served_unlimited_read_test.go",
|
|
"served_wrong_server_test.go",
|
|
"store_dependent_test.go",
|
|
"store_test.go",
|
|
"target_test.go",
|
|
"unlimited_read_test.go",
|
|
"update_persistence_test.go",
|
|
"watch_test.go",
|
|
"wave2b_roles_test.go",
|
|
"wave2c_claimnext_test.go",
|
|
"wave2c_config_test.go",
|
|
"wave2c_journal_test.go",
|
|
"write_ledger_test.go",
|
|
"write_roles_test.go",
|
|
],
|
|
# keep
|
|
#
|
|
# TestInterfaceCompleteness (completeness_test.go) reads its own package's
|
|
# generated shell, unsupported_gen.go, by a plain relative os.ReadFile to
|
|
# regex-match the methods storage.DoltStorage's refusing shell covers. That
|
|
# file is already a `srcs` member of :httpclient above, which Bazel compiles
|
|
# away rather than leaving as a readable file in the test's sandbox; `data`
|
|
# is what actually puts a copy there, exactly as
|
|
# //internal/httpclient/encode's own go_test does for the same reason.
|
|
# Gazelle does not manage `data` on this rule, so this survives
|
|
# `make bazel-sync` (the directive just says so).
|
|
data = glob(["*.go"]),
|
|
embed = [":httpclient"],
|
|
shard_count = 2,
|
|
deps = [
|
|
"//:beads",
|
|
"//backend/conformance",
|
|
"//internal/eventsjournal",
|
|
"//internal/hooks",
|
|
"//internal/httpapi",
|
|
"//internal/httpapi/apigen",
|
|
"//internal/httpapi/spec",
|
|
"//internal/httpclient/encode",
|
|
"//internal/httpclient/wire",
|
|
"//internal/storage",
|
|
"//internal/storage/backends",
|
|
"//internal/storage/batchfixtures",
|
|
"//internal/storage/domain",
|
|
"//internal/storage/embeddeddolt",
|
|
"//internal/storage/externaldeps",
|
|
"//internal/storage/issueops",
|
|
"//internal/storage/sqlbuild",
|
|
"//internal/types",
|
|
"//internal/workapi",
|
|
"//issueops",
|
|
"//journalops",
|
|
"//memoryops",
|
|
"@in_gopkg_yaml_v3//:yaml_v3",
|
|
],
|
|
)
|
|
|
|
# scripts/conformance.sh's Tier 3, the served HTTP corpus: the whole package
|
|
# with BEADS_TEST_EMBEDDED_DOLT=1, so the served_*_test.go cases stand a real
|
|
# `bd serve` handler over embedded Dolt instead of skipping as they do in
|
|
# httpclient_test above, and BEADS_HTTP_TEST_REQUIRED=1, so a missing engine
|
|
# fails each served case rather than skipping it. It is the script's run on
|
|
# the lane's race build (raceEnabled shrinks its one large apply).
|
|
#
|
|
# Shard count: on the lane's executors (rbe-west, 2026-10-09, the whole
|
|
# embedded lane running) the package is ~750 top-level tests and ~1,100
|
|
# test-seconds, all serial, the heaviest about 52s. Each served case copies
|
|
# one per-process template workspace instead of initializing its own embedded
|
|
# Dolt schema (served_harness_test.go's servedTemplateWorkspace), and
|
|
# TestServedBatchGetterContract seeds its 1000 issues in one write: before
|
|
# both, the package was ~3,700 test-seconds over 24 shards, the heaviest shard
|
|
# 390s. rules_go's round-robin alone (16 shards) left shards at 40-119s,
|
|
# wherever its split dropped the long tests, so the tests measured at >= 3s
|
|
# (the maximum over three whole-lane runs) are pinned
|
|
# (tools/bazel/go_test_pinned_shard.sh, served_pinned_shards.txt from
|
|
# tools/bazel/pin_shards.py --shards 17 --min-seconds 3) onto 17 shards, and
|
|
# the binary's round-robin deals the other ~650 (~340s of measured test
|
|
# time; those shards ran ~1.4x their tests' summed times) over the remaining
|
|
# 9.
|
|
# Regenerate the manifest from runs of the lane:
|
|
# bazel test //... --config=embedded
|
|
# python3 tools/bazel/pin_shards.py --shards 17 --min-seconds 3 \
|
|
# --write internal/httpclient/served_pinned_shards.txt \
|
|
# bazel-testlogs/internal/httpclient/httpclient_served_test
|
|
#
|
|
# Tags:
|
|
# embedded: the embedded-Dolt tier; excluded from --config=prcore/ci,
|
|
# selected by --config=embedded.
|
|
sh_test(
|
|
name = "httpclient_served_test",
|
|
size = "large",
|
|
# Deviation from the script's -timeout=40m: Bazel ends the action at
|
|
# 1200s (eternal under --config=embedded), and rules_go's wrapper ignores
|
|
# that SIGTERM, so a hang would end as a bare TIMEOUT. 19m lets Go's own
|
|
# timeout fire first and dump every goroutine to test.log.
|
|
timeout = "eternal",
|
|
srcs = ["//tools/bazel:go_test_pinned_shard.sh"],
|
|
args = [
|
|
"$(rootpath :served_pinned_shards.txt)",
|
|
"$(rootpath :httpclient_test)",
|
|
"-test.v",
|
|
"-test.count=1",
|
|
"-test.timeout=19m",
|
|
],
|
|
data = [
|
|
"served_pinned_shards.txt",
|
|
":httpclient_test",
|
|
],
|
|
env = {
|
|
"BEADS_HTTP_TEST_REQUIRED": "1",
|
|
"BEADS_TEST_EMBEDDED_DOLT": "1",
|
|
},
|
|
shard_count = 26,
|
|
tags = ["embedded"],
|
|
)
|
|
|
|
# --- begin go_srcs (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
|
|
|
|
filegroup(
|
|
name = "go_srcs",
|
|
srcs = glob(
|
|
["**/*.go"],
|
|
allow_empty = True,
|
|
),
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
# --- end go_srcs ---
|
|
|
|
# --- begin repo_files (managed by tools/bazel/go_srcs.py; run `make bazel-sync`) ---
|
|
|
|
filegroup(
|
|
name = "repo_doc_files",
|
|
srcs = glob(
|
|
[
|
|
"**/*.md",
|
|
"**/*.mdx",
|
|
],
|
|
allow_empty = True,
|
|
exclude = ["**/node_modules/**"],
|
|
),
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "repo_go_srcs",
|
|
srcs = glob(
|
|
["**/*.go"],
|
|
allow_empty = True,
|
|
exclude = [
|
|
"**/*_test.go",
|
|
"**/node_modules/**",
|
|
],
|
|
),
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "repo_go_test_srcs",
|
|
srcs = glob(
|
|
["**/*_test.go"],
|
|
allow_empty = True,
|
|
exclude = ["**/node_modules/**"],
|
|
),
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
filegroup(
|
|
name = "repo_other_files",
|
|
srcs = glob(
|
|
["**"],
|
|
exclude = [
|
|
"**/*.db",
|
|
"**/*.exe",
|
|
"**/*.go",
|
|
"**/*.md",
|
|
"**/*.mdx",
|
|
"**/*.out",
|
|
"**/*.prof",
|
|
"**/*.pyc",
|
|
"**/*.test",
|
|
"**/__pycache__/**",
|
|
"**/node_modules/**",
|
|
],
|
|
),
|
|
visibility = ["//:__subpackages__"],
|
|
)
|
|
|
|
# --- end repo_files ---
|