From 9319da61139ea4045f2cd403397a16d72c2ffee3 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Wed, 04 Feb 2026 12:03:51 +0000 Subject: [PATCH] lexicons: update pull lexicon Signed-off-by: oppiliappan --- api/tangled/cbor_gen.go | 397 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------- api/tangled/knotsubscribeRepos.go | 4 ++-- api/tangled/repopull.go | 31 ++++++++++++++++++------------- cmd/cborgen/cborgen.go | 1 + lexicons/pulls/pull.json | 60 +++++++++++++++++++++++++++++++++++++----------------------- 5 file(s) changed, 327 insertion(s)(+), 166 deletion(s)(-) diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -8581,11 +8581,11 @@ fieldCount-- } - if t.Mentions == nil { + if t.DependentOn == nil { fieldCount-- } - if t.Patch == nil { + if t.Mentions == nil { fieldCount-- } @@ -8652,38 +8652,6 @@ return err } - // t.Patch (string) (string) - if t.Patch != nil { - - if len("patch") > 1000000 { - return xerrors.Errorf("Value in field \"patch\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patch"))); err != nil { - return err - } - if _, err := cw.WriteString(string("patch")); err != nil { - return err - } - - if t.Patch == nil { - if _, err := cw.Write(cbg.CborNull); err != nil { - return err - } - } else { - if len(*t.Patch) > 1000000 { - return xerrors.Errorf("Value in field t.Patch was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Patch))); err != nil { - return err - } - if _, err := cw.WriteString(string(*t.Patch)); err != nil { - return err - } - } - } - // t.Title (string) (string) if len("title") > 1000000 { return xerrors.Errorf("Value in field \"title\" was too long") @@ -8705,6 +8673,32 @@ } if _, err := cw.WriteString(string(t.Title)); err != nil { return err + } + + // t.Rounds ([]*tangled.RepoPull_Round) (slice) + if len("rounds") > 1000000 { + return xerrors.Errorf("Value in field \"rounds\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("rounds"))); err != nil { + return err + } + if _, err := cw.WriteString(string("rounds")); err != nil { + return err + } + + if len(t.Rounds) > 8192 { + return xerrors.Errorf("Slice value in field t.Rounds was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Rounds))); err != nil { + return err + } + for _, v := range t.Rounds { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + } // t.Source (tangled.RepoPull_Source) (struct) @@ -8801,22 +8795,6 @@ return err } - // t.PatchBlob (util.LexBlob) (struct) - if len("patchBlob") > 1000000 { - return xerrors.Errorf("Value in field \"patchBlob\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patchBlob"))); err != nil { - return err - } - if _, err := cw.WriteString(string("patchBlob")); err != nil { - return err - } - - if err := t.PatchBlob.MarshalCBOR(cw); err != nil { - return err - } - // t.References ([]string) (slice) if t.References != nil { @@ -8852,6 +8830,38 @@ } } + + // t.DependentOn (string) (string) + if t.DependentOn != nil { + + if len("dependentOn") > 1000000 { + return xerrors.Errorf("Value in field \"dependentOn\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("dependentOn"))); err != nil { + return err + } + if _, err := cw.WriteString(string("dependentOn")); err != nil { + return err + } + + if t.DependentOn == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.DependentOn) > 1000000 { + return xerrors.Errorf("Value in field t.DependentOn was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.DependentOn))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.DependentOn)); err != nil { + return err + } + } + } return nil } @@ -8880,7 +8890,7 @@ n := extra - nameBuf := make([]byte, 10) + nameBuf := make([]byte, 11) for i := uint64(0); i < n; i++ { nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) if err != nil { @@ -8928,27 +8938,6 @@ t.LexiconTypeID = string(sval) } - // t.Patch (string) (string) - case "patch": - - { - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Patch = (*string)(&sval) - } - } // t.Title (string) (string) case "title": @@ -8959,6 +8948,55 @@ } t.Title = string(sval) + } + // t.Rounds ([]*tangled.RepoPull_Round) (slice) + case "rounds": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Rounds: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Rounds = make([]*RepoPull_Round, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.Rounds[i] = new(RepoPull_Round) + if err := t.Rounds[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Rounds[i] pointer: %w", err) + } + } + + } + + } } // t.Source (tangled.RepoPull_Source) (struct) case "source": @@ -9051,26 +9089,6 @@ t.CreatedAt = string(sval) } - // t.PatchBlob (util.LexBlob) (struct) - case "patchBlob": - - { - - b, err := cr.ReadByte() - if err != nil { - return err - } - if b != cbg.CborNull[0] { - if err := cr.UnreadByte(); err != nil { - return err - } - t.PatchBlob = new(util.LexBlob) - if err := t.PatchBlob.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.PatchBlob pointer: %w", err) - } - } - - } // t.References ([]string) (slice) case "references": @@ -9109,6 +9127,27 @@ t.References[i] = string(sval) } + } + } + // t.DependentOn (string) (string) + case "dependentOn": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.DependentOn = (*string)(&sval) } } @@ -9488,7 +9527,7 @@ } cw := cbg.NewCborWriter(w) - fieldCount := 4 + fieldCount := 3 if t.Repo == nil { fieldCount-- @@ -9499,29 +9538,6 @@ } if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { - return err - } - - // t.Sha (string) (string) - if len("sha") > 1000000 { - return xerrors.Errorf("Value in field \"sha\" was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sha"))); err != nil { - return err - } - if _, err := cw.WriteString(string("sha")); err != nil { - return err - } - - if len(t.Sha) > 1000000 { - return xerrors.Errorf("Value in field t.Sha was too long") - } - - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Sha))); err != nil { - return err - } - if _, err := cw.WriteString(string(t.Sha)); err != nil { return err } @@ -9655,18 +9671,7 @@ } switch string(nameBuf[:nameLen]) { - // t.Sha (string) (string) - case "sha": - - { - sval, err := cbg.ReadStringWithMax(cr, 1000000) - if err != nil { - return err - } - - t.Sha = string(sval) - } - // t.Repo (string) (string) + // t.Repo (string) (string) case "repo": { @@ -9718,6 +9723,142 @@ t.RepoDid = (*string)(&sval) } + } + + default: + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { + return err + } + } + } + + return nil +} +func (t *RepoPull_Round) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + + if _, err := cw.Write([]byte{162}); err != nil { + return err + } + + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("createdAt")); err != nil { + return err + } + + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + return err + } + + // t.PatchBlob (util.LexBlob) (struct) + if len("patchBlob") > 1000000 { + return xerrors.Errorf("Value in field \"patchBlob\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("patchBlob"))); err != nil { + return err + } + if _, err := cw.WriteString(string("patchBlob")); err != nil { + return err + } + + if err := t.PatchBlob.MarshalCBOR(cw); err != nil { + return err + } + return nil +} + +func (t *RepoPull_Round) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoPull_Round{} + + cr := cbg.NewCborReader(r) + + maj, extra, err := cr.ReadHeader() + if err != nil { + return err + } + defer func() { + if err == io.EOF { + err = io.ErrUnexpectedEOF + } + }() + + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") + } + + if extra > cbg.MaxLength { + return fmt.Errorf("RepoPull_Round: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 9) + for i := uint64(0); i < n; i++ { + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) + if err != nil { + return err + } + + if !ok { + // Field doesn't exist on this type, so ignore it + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { + return err + } + continue + } + + switch string(nameBuf[:nameLen]) { + // t.CreatedAt (string) (string) + case "createdAt": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.CreatedAt = string(sval) + } + // t.PatchBlob (util.LexBlob) (struct) + case "patchBlob": + + { + + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + t.PatchBlob = new(util.LexBlob) + if err := t.PatchBlob.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.PatchBlob pointer: %w", err) + } + } + } default: diff --git a/api/tangled/knotsubscribeRepos.go b/api/tangled/knotsubscribeRepos.go --- a/api/tangled/knotsubscribeRepos.go +++ b/api/tangled/knotsubscribeRepos.go @@ -18,8 +18,8 @@ // KnotSubscribeRepos_GitSync2 is a "gitSync2" in the sh.tangled.knot.subscribeRepos schema. type KnotSubscribeRepos_GitSync2 struct { - // did: Repository AT-URI identifier - Did *string `json:"did,omitempty" cborgen:"did,omitempty"` + // repo: Repository AT-URI identifier + Repo string `json:"repo" cborgen:"repo"` // seq: The stream sequence number of this message. Seq int64 `json:"seq" cborgen:"seq"` } diff --git a/api/tangled/repopull.go b/api/tangled/repopull.go --- a/api/tangled/repopull.go +++ b/api/tangled/repopull.go @@ -17,18 +17,24 @@ } // // RECORDTYPE: RepoPull type RepoPull struct { - LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull" cborgen:"$type,const=sh.tangled.repo.pull"` - Body *string `json:"body,omitempty" cborgen:"body,omitempty"` - CreatedAt string `json:"createdAt" cborgen:"createdAt"` - Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` - // patch: (deprecated) use patchBlob instead - Patch *string `json:"patch,omitempty" cborgen:"patch,omitempty"` - // patchBlob: patch content - PatchBlob *util.LexBlob `json:"patchBlob" cborgen:"patchBlob"` - References []string `json:"references,omitempty" cborgen:"references,omitempty"` - Source *RepoPull_Source `json:"source,omitempty" cborgen:"source,omitempty"` - Target *RepoPull_Target `json:"target" cborgen:"target"` - Title string `json:"title" cborgen:"title"` + LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull" cborgen:"$type,const=sh.tangled.repo.pull"` + Body *string `json:"body,omitempty" cborgen:"body,omitempty"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + DependentOn *string `json:"dependentOn,omitempty" cborgen:"dependentOn,omitempty"` + Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` + References []string `json:"references,omitempty" cborgen:"references,omitempty"` + Rounds []*RepoPull_Round `json:"rounds" cborgen:"rounds"` + Source *RepoPull_Source `json:"source,omitempty" cborgen:"source,omitempty"` + Target *RepoPull_Target `json:"target" cborgen:"target"` + Title string `json:"title" cborgen:"title"` +} + +// RepoPull_Round is a "round" in the sh.tangled.repo.pull schema. +// +// revisions of this pull request, newer rounds are appended to this array. appviews may reject records do not treat this field as append-only. the blob format is gzipped text-based git-format-patches. +type RepoPull_Round struct { + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + PatchBlob *util.LexBlob `json:"patchBlob" cborgen:"patchBlob"` } // RepoPull_Source is a "source" in the sh.tangled.repo.pull schema. @@ -36,7 +42,6 @@ Branch string `json:"branch" cborgen:"branch"` Repo *string `json:"repo,omitempty" cborgen:"repo,omitempty"` RepoDid *string `json:"repoDid,omitempty" cborgen:"repoDid,omitempty"` - Sha string `json:"sha" cborgen:"sha"` } // RepoPull_Target is a "target" in the sh.tangled.repo.pull schema. diff --git a/cmd/cborgen/cborgen.go b/cmd/cborgen/cborgen.go --- a/cmd/cborgen/cborgen.go +++ b/cmd/cborgen/cborgen.go @@ -50,6 +50,7 @@ tangled.RepoPull{}, tangled.RepoPullComment{}, tangled.RepoPull_Source{}, + tangled.RepoPull_Round{}, tangled.RepoPullStatus{}, tangled.RepoPull_Target{}, tangled.Spindle{}, diff --git a/lexicons/pulls/pull.json b/lexicons/pulls/pull.json --- a/lexicons/pulls/pull.json +++ b/lexicons/pulls/pull.json @@ -12,34 +12,30 @@ "required": [ "target", "title", - "patchBlob", - "createdAt" + "createdAt", + "rounds" ], "properties": { - "target": { - "type": "ref", - "ref": "#target" - }, "title": { "type": "string" }, "body": { "type": "string" }, - "patch": { - "type": "string", - "description": "(deprecated) use patchBlob instead" - }, - "patchBlob": { - "type": "blob", - "accept": [ - "text/x-patch" - ], - "description": "patch content" + "rounds": { + "type": "array", + "items": { + "type": "ref", + "ref": "#round" + } }, "source": { "type": "ref", "ref": "#source" + }, + "target": { + "type": "ref", + "ref": "#target" }, "createdAt": { "type": "string", @@ -58,6 +54,10 @@ "type": "string", "format": "at-uri" } + }, + "dependentOn": { + "type": "string", + "format": "at-uri" } } } @@ -84,17 +84,11 @@ "source": { "type": "object", "required": [ - "branch", - "sha" + "branch" ], "properties": { "branch": { "type": "string" - }, - "sha": { - "type": "string", - "minLength": 40, - "maxLength": 40 }, "repo": { "type": "string", @@ -103,6 +97,26 @@ "repoDid": { "type": "string", "format": "did" + } + } + }, + "round": { + "type": "object", + "required": [ + "patchBlob", + "createdAt" + ], + "description": "revisions of this pull request, newer rounds are appended to this array. appviews may reject records do not treat this field as append-only. the blob format is gzipped text-based git-format-patches.", + "properties": { + "createdAt": { + "type": "string", + "format": "datetime" + }, + "patchBlob": { + "type": "blob", + "accept": [ + "application/gzip" + ] } } } -- tangled.sh