Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions docs/normative/trace-context/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ identity components.
|-----------|--------|--------|------|
| Installation | 128-bit ID provisioned with the signing key pair | same | same |
| Forge instance | web base URL (`https://github.com`, or a GHES host) | web base URL (`https://gitlab.com`, or a self-hosted host) | site base URL |
| Container | repository `id` | project `id` | project `id` |
| Container | repository `id`; for a PR, the base repository, never the fork | project `id`; for an MR, the target project, never the fork | project `id` |
| Entity kind | `work_item` (issue), `change_proposal` (PR) | `work_item` (issue), `change_proposal` (MR) | `work_item` (issue; Jira has no change proposal) |
| Entity | `work_item`: issue REST `id`; `change_proposal`: pull-request REST `id` = GraphQL `fullDatabaseId` (`BigInt`), never the issue-space ID | issue or MR database `id` (not the IID) | issue `id` |

Expand All @@ -44,6 +44,10 @@ percent-escapes with characters that still need escaping, such as
the same configured deployment URL on every launch, rather than an entity or
API URL.

Normalization fixes spelling only; it never resolves one name to another. An
IP literal and its hostname, two DNS aliases of one host, and
`https://[::ffff:192.0.2.1]` and `https://192.0.2.1` are different instances.

Strip leading zeros from the port, keeping an all-zero port as `:0` rather
than treating it as the default, and reject ports above `65535`. Then remove
an empty port and the scheme's default port (`443` for HTTPS, `80` for
Expand All @@ -54,7 +58,8 @@ names, and reject Unicode host spellings instead of converting them. For
example, `https://GitHub.com:443/` becomes `https://github.com`, and
`https://XN--BCHER-KVA.example` becomes `https://xn--bcher-kva.example`.
Bracketed IPv6 hosts follow the same port rules and take their RFC 5952
form: `https://[2001:DB8:0:0:0:0:0:1]` becomes `https://[2001:db8::1]`.
section 4 form, with IPv4-mapped addresses in mixed notation:
`https://[2001:DB8:0:0:0:0:0:1]` becomes `https://[2001:db8::1]`.
Zone identifiers reject (`https://[FE80::1%25EN0]`; use a routable
address), so a normalized instance always re-normalizes to itself.
Trailing DNS root dots are stripped: `https://github.com.` and
Expand All @@ -78,8 +83,8 @@ traces regardless of key state.

- Renames (issue titles, repository names, Jira project keys) never
change identity: the container and entity components are database IDs.
- Repository transfers on GitHub and GitLab preserve the database ID, so
identity survives a transfer.
- A container transfer that keeps the container's database ID keeps
identity; one that changes the database ID is a new binding.
- An entity moved between containers (a GitHub issue transfer, a Jira
project move) has a **new binding** — a different container or entity
ID — and therefore a new identity. A previously published envelope
Expand All @@ -91,8 +96,10 @@ traces regardless of key state.

### Fallback derivation (v1)

When no admissible stored context exists, the entity's context is derived
deterministically:
When the identity is resolved and no admissible stored context exists, the
entity's context is derived deterministically. An unresolved identity gets no
derived context; dispatch is postponed instead (see [Admission](#admission)).
The derivation is:

- Input: the forge instance, container, kind, and entity — never the
installation.
Expand Down Expand Up @@ -148,7 +155,7 @@ the magic through the nonce — there are no unsigned fields.
| · | 16 | Trace ID | nonzero |
| · | 8 | Parent/anchor Span ID | nonzero |
| · | 1 | Provenance kind | `0x00` none, `0x01` source link, `0x02` scenario |
| · | 0/24/32 | Provenance fields | none; source link = 16B source TraceID + 8B source SpanID; scenario = 16B scenario TraceID + 16B invocation ID |
| · | 0/24/32 | Provenance fields | none; source link = 16B source TraceID + 8B source SpanID; scenario = 16B scenario TraceID + 16B invocation ID; every ID nonzero |
| · | 16 | Nonce | nonzero (checked); signers draw it from `crypto/rand`, unique per creation intent (not checked at admission) |
| end−64 | 64 | Ed25519 signature | over bytes `[0, end−64)` |

Expand Down Expand Up @@ -228,7 +235,7 @@ envelope.
Any differing extra candidate, whether junk or a second envelope,
deliberately forces fallback even when one candidate alone would admit;
identical duplicates do not. An actor who can edit the body can deny
continuity by appending junk or deleting the carrier, but can never alter
continuity by appending junk or deleting the carrier, but can never forge
or inject a context: only an envelope the installation signed for this
entity admits. Admission has no freshness check, so an older valid
envelope for the same entity still admits. Rejection is deliberately
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/trace-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ database ID; its result alone cannot resolve trace identity.

- [`identity_test.go`](https://github.com/fullsend-ai/fullsend/blob/main/internal/telemetry/tracecontext/identity_test.go)
contains independent fallback vectors, deployment-prefix separation checks,
cross-process convergence, root-dot, port, and IPv6 spelling and zone
canonicalization, mixed-escape path rejection, a
cross-process convergence, root-dot, port, and IPv6 spelling
canonicalization and zone rejection, mixed-escape path rejection, a
normalization fuzz target asserting the canonical form re-normalizes to
itself, and SDK exporter lifecycle assertions.
- [`envelope_test.go`](https://github.com/fullsend-ai/fullsend/blob/main/internal/telemetry/tracecontext/envelope_test.go)
Expand Down
8 changes: 6 additions & 2 deletions internal/forge/jira/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,12 @@ type searchRequest struct {
NextPageToken string `json:"nextPageToken,omitempty"`
}

// searchFields lists the issue fields the poller actually consumes.
// Requesting them explicitly (rather than "*all") bounds search payloads:
// searchFields lists the issue fields SearchIssues requests. Of these,
// the poller reads only "created", "labels", and "reporter". "project"
// carries the immutable project database ID, the Jira container identity
// for trace binding (ADR 0154), so search results hold the same identity
// as issue reads; GetIssue fetches it through its own request.
// Requesting fields explicitly (rather than "*all") bounds search payloads:
// with "*all", 50 issues per page each carrying full ADF descriptions,
// embedded first comment pages, attachments, and every custom field can
// plausibly exceed the client's 10MB decode cap — and since a failed
Expand Down
8 changes: 4 additions & 4 deletions internal/telemetry/tracecontext/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ func DecodeCarrier(s string) ([]byte, error) {
type Outcome int

const (
// OutcomeFallback means no carrier was admissible; the caller uses
// the deterministic entity-derived fallback, except for
// OutcomeFallback means no decoded candidate was admissible; the
// caller uses the deterministic entity-derived fallback, except for
// ReasonUnresolved, where it must postpone dispatch. It is the zero
// value.
OutcomeFallback Outcome = iota
Expand Down Expand Up @@ -473,8 +473,8 @@ func reasonForParse(err error) string {
// returns permission.
//
// An unresolved expected identity reports ReasonUnresolved before any
// carrier is inspected: the caller must postpone dispatch (FR-002) and
// must not read the candidate's own diagnostics as the cause.
// decoded candidate is inspected: the caller must postpone dispatch
// (FR-002) and must not read the candidate's own diagnostics as the cause.
func Admit(expected Identity, keys map[[8]byte]ed25519.PublicKey, candidates ...[]byte) Result {
if !expected.Resolved() {
return fallback(ReasonUnresolved)
Expand Down
3 changes: 2 additions & 1 deletion internal/telemetry/tracecontext/envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ func TestAdmit_DuplicateCarriers(t *testing.T) {

// TestAdmit_AppendedJunkForcesFallback documents the accepted
// denial-of-continuity trade-off: an editor can suppress continuity by
// appending an unauthenticated carrier, but cannot inject or select one.
// appending an unauthenticated carrier, but can never forge or inject a
// context.
func TestAdmit_AppendedJunkForcesFallback(t *testing.T) {
t.Parallel()
raw, keys := signedGolden(t, DomainBound, ProvenanceNone)
Expand Down
12 changes: 7 additions & 5 deletions internal/telemetry/tracecontext/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ func nonzeroFallback(fb Fallback) Fallback {
// and https are accepted. Ports lose leading zeros (an all-zero port stays
// :0) and must fit 16 bits; empty and default ports are then removed.
// Trailing DNS root dots are stripped, hosts must be ASCII (punycode for
// IDNs), and IPv6 hosts take their RFC 5952 form without a zone
// identifier. Path segments and escape spelling are preserved so distinct
// deployments cannot alias; a path mixing percent-escapes with characters
// that still need escaping rejects. All identity and envelope construction
// IDNs), and IPv6 hosts take their RFC 5952 section 4 form, with
// IPv4-mapped addresses in mixed notation, and no zone identifier. Path
// segments and escape spelling are preserved so distinct deployments
// cannot alias; a path mixing percent-escapes with characters that still
// need escaping rejects. All identity and envelope construction
// must use the normalized form so independent launches converge.
func NormalizeInstance(raw string) (string, error) {
if !utf8.ValidString(raw) {
Expand Down Expand Up @@ -182,7 +183,8 @@ func NormalizeInstance(raw string) (string, error) {
if host == "" {
return "", errors.New("tracecontext: instance URL needs a host")
}
// One IPv6 address has one spelling: use its RFC 5952 form.
// One IPv6 address has one spelling: use its RFC 5952 section 4 form,
// with IPv4-mapped addresses in mixed notation.
if addr, err := netip.ParseAddr(u.Hostname()); err == nil && addr.Is6() {
host = "[" + addr.String() + "]"
}
Expand Down
Loading