Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the core Protocol Buffer schemas and gRPC service definitions for Collect One, including documentation, form definitions, record instances, audit logs, and shared types. The review feedback points out documentation mismatches in the README regarding message names and file locations. Additionally, it suggests marking several numeric fields as optional (such as max_pixels, accuracy thresholds, and GPS intervals) to distinguish between unset values and explicit zero defaults in proto3.
| // Dataset. | ||
| string entity_saveto = 11; | ||
|
|
||
| // Maximum long-edge pixel dimension for image attachments. Images exceeding |
There was a problem hiding this comment.
Since max_pixels is a numeric field, in proto3 it defaults to 0 when unset. However, 0 is an invalid pixel dimension for image downsampling, and typically represents 'no limit'. Marking this field as optional allows the client and server to explicitly distinguish between 'unset (no limit)' and an explicitly set value.
| // Maximum long-edge pixel dimension for image attachments. Images exceeding | |
| optional int32 max_pixels = 12; |
There was a problem hiding this comment.
✦ Good question; checking with the author and will follow up here.
| double accuracy_threshold_meters = 1; | ||
|
|
||
| // Horizontal accuracy threshold in meters above which the UI displays an | ||
| // uncertainty warning (e.g., red dialog in ODK Collect). | ||
| // Corresponds to XForms `<input unacceptableAccuracyThreshold="...">` and | ||
| // XLSForm `warning-accuracy` / `body::unacceptableAccuracyThreshold`. | ||
| double warning_threshold_meters = 2; |
There was a problem hiding this comment.
In proto3, numeric fields default to 0.0 when unset. For accuracy_threshold_meters and warning_threshold_meters, a value of 0.0 represents an extremely strict (or impossible) threshold. Marking these fields as optional allows the client to easily distinguish between 'unset (use client/system defaults)' and an explicitly configured threshold.
| double accuracy_threshold_meters = 1; | |
| // Horizontal accuracy threshold in meters above which the UI displays an | |
| // uncertainty warning (e.g., red dialog in ODK Collect). | |
| // Corresponds to XForms `<input unacceptableAccuracyThreshold="...">` and | |
| // XLSForm `warning-accuracy` / `body::unacceptableAccuracyThreshold`. | |
| double warning_threshold_meters = 2; | |
| optional double accuracy_threshold_meters = 1; | |
| // Horizontal accuracy threshold in meters above which the UI displays an | |
| // uncertainty warning (e.g., red dialog in ODK Collect). | |
| // Corresponds to XForms `<input unacceptableAccuracyThreshold="...">` and | |
| // XLSForm `warning-accuracy` / `body::unacceptableAccuracyThreshold`. | |
| optional double warning_threshold_meters = 2; |
There was a problem hiding this comment.
✦ Good question; checking with the author and will follow up here.
| int32 location_min_interval_seconds = 2; | ||
|
|
||
| // Maximum acceptable age in seconds for cached GPS readings before requesting | ||
| // a fresh location fix from the hardware sensor. | ||
| int32 location_max_age_seconds = 3; |
There was a problem hiding this comment.
In proto3, numeric fields default to 0 when unset. For location_min_interval_seconds and location_max_age_seconds, a value of 0 would mean continuous background GPS tracking and instant cache expiration, which is extremely battery-intensive. Marking these fields as optional allows the client to distinguish between 'unset (use sensible client defaults)' and an explicitly configured value.
| int32 location_min_interval_seconds = 2; | |
| // Maximum acceptable age in seconds for cached GPS readings before requesting | |
| // a fresh location fix from the hardware sensor. | |
| int32 location_max_age_seconds = 3; | |
| optional int32 location_min_interval_seconds = 2; | |
| // Maximum acceptable age in seconds for cached GPS readings before requesting | |
| // a fresh location fix from the hardware sensor. | |
| optional int32 location_max_age_seconds = 3; |
There was a problem hiding this comment.
✦ Good question; checking with the author and will follow up here.
…and product docs (#2699, #2701, #2702) - shared/protos/README.md: ControlDef/GroupDef/RepeatDef names; TranslationCatalog is in form_def.proto (#2701) - survey_def.proto, organization.proto: FormConceptLinks comment placement; drop stale budget cap wording (#2702) - docs/product/prd.md, concept-brief.md: Map layer wording, five lifecycle states, general access sliders, Purpose Packs (#2699)
85ddc77 to
feb3c6e
Compare
Collect One review series: P01 Protos: forms (6/90)
Tracking issue: #2629 · Stacked on: #2698 · Reviewer: @rfontanarosa
FYI: @gino-m @shobhitagarwal1612
Context
Collect One is the Kotlin Multiplatform successor to Ground: a single shared codebase for the web
console, the mobile app (Android, iOS, browser), and a Spanner-backed user-data service. Forms use
ProtoForms, a lossless proto3 encoding of ODK XForms. Product and architecture background:
docs/product/prd.md,docs/technical/client/architecture.md(the docs slices have not merged yet, sothese are paths in the
wip/baobabtree, not links).This PR is one slice of the
wip/baobabtree. It only adds the files listed below. It is stacked on #2698(W01 Build system, CI workflows, and tooling): review only this diff; it merges after #2698.
This slice is the ProtoForms schema itself: the
openforis.collectone.v1.formspackage, plus the READMEfor the whole
shared/protos/directory. It contains no Kotlin and no Gradle module.What's in this PR
shared/protos/README.md: overview of all proto packages (forms, survey, data, library, sync), the"data tables are current state, forms are events" mental model, and the mutation conventions of the gRPC
services (client-generated UUIDs, sparse
deletemask and sparseupsert, soft deletes). Only theforms/part describes files in this PR.shared/protos/forms/types.proto:DataTypeenum (16 values, scalars to geo types, binary, message,select one/multiple),
GeoPoint,GeoTrace,GeoShape, and theTypedValueoneof used for literals.shared/protos/forms/form_def.proto: the form definition.FormDefholds aModelDefand aViewDef.PrimaryInstance/RecordSchema/FieldDefinition,SecondaryInstance,FieldBinding(relevant, calculate, constraint, required, read-only, preload,
entity_saveto),ForeignAttribute,TranslationCatalog/LanguageTranslation/LocalizedString/MediaRef,ActionDefwithEventTypeandActionType,EntityDeclaration/EntityPropertyMapping/EntitySyncMetadata,SubmissionConfig.ViewComponent(oneof ofControlDef,GroupDef,RepeatDef),ControlType,LabelDef/OutputFragment,ChoiceItem,ItemsetDef,RangeConfig,GeoConfig,IntentConfig.shared/protos/forms/record_instance.proto: a submission.RecordInstance(form id and version,RecordMetadata, rootRecordNode, optionalAuditLog), withFieldValueas a oneof of scalar, list,nested node, and repeat list.
shared/protos/forms/audit_log.proto:AuditConfig,AuditEvent,AuditLogfor client audit logging.Where it fits
This is the bottom layer: these messages are the wire and storage format for form definitions and
submissions, shared by the mobile app, the web console, and the server. The package depends only on
google.protobuf(Timestamp,Any) andgoogle.type(Date,TimeOfDay). Per the README, Kotlinclasses are generated from these files by Square Wire in the
shared/corebuild, which arrives with K01.Not in this PR
shared/protos/survey/*(SurveyDef, ACLs, organizations,SurveyService) → P02 Protos: survey, ACL, organizationshared/protos/data/*,library/*,sync/*,earthengine/*,userdata/*→ P03 Protos: data, library, sync, Earth Engine, user datashared/core/build.gradle.kts(the module that compiles these protos) and the textproto codec → K01 Core 1/7: core.forms.serialization.textproto, core.forms.media (MediaCapture, FormStateModels)FormDef→ K02 Core 2/7: serialization, xpath.ast (FormDefXmlDeserializer, FormDefXmlSerializer)ProtoFieldCoverageTest, which thecustom_extensionscomments refer to → K06 Core 6/7: mutation, sampling (DefaultSamplingEngine, SurveyMutations)docs/technical/model/forms/*, the long-form description of this model → D03 Docs: technical 2/2: forms, surveySuggested reading order
shared/protos/README.md: the "Core Mental Model" and "Packages" sections; the gRPC sections describe P02 and P03.shared/protos/forms/types.protoshared/protos/forms/record_instance.protoshared/protos/forms/audit_log.protoshared/protos/forms/form_def.proto:FormDefat the bottom first, thenModelDef, thenViewDefand its components.Focus areas
Secondary Instances, Bindings and Bind Attributes, Body Elements, Events and Actions, Entities,
Submission, Metadata, Data Types, Audit Attributes). Check that the fields are enough to round-trip a
form;
ForeignAttributeexists to keep<bind>attributes from namespaces the model does not cover.idandsort_orderon repeated items.FieldDefinition,SecondaryInstance,FieldBinding,ActionDef,ChoiceItem,ViewComponent,RecordNodeand others carry a stableid"for sparsemutation addressing" and often a
sort_order. These support thedelete/upsertmerge described inthe README, where keyed repeated items are matched by ID and ordered by
sort_order. Note the documenteddefaults (for example
iddefaults tofield_pathonFieldBinding).RecordInstancestores answers asmap<string, FieldValue>instead of agenerated message per form, so every runtime reads submissions with ordinary generated accessors.
google.protobuf.Any custom_extensionsonFormDef,ModelDef,FieldBinding,ControlDef: thecomments say the client codecs (ProtoJSON, textproto) drop these for now. Is keeping the fields right?
SecondaryInstancereserves field 3 and the nameinline_data; inline rows are nowrepeated RecordNode rows = 6.RecordMetadatakeepssubscriber_id,sim_serial,phone_numberfrom theXForms metadata set, with notes that modern mobile OSs restrict them.
SubmissionConfig.base64_rsa_public_keyis kept for round-trip only; the comment saysCollect One does not encrypt submissions and relies on transport security.
ControlNode,GroupNode,RepeatNode; the proto definesControlDef,GroupDef,RepeatDef.TranslationCatalogundertypes.proto; it is defined inform_def.proto.survey/,data/,library/,sync/,../core/and../../docs/technical/model/resolve only once P02, P03, K01 and D03 land.
Safe to skim
DataType,ControlType,PreloadType,EventType,ActionType) and the simpleconfig messages (
RangeConfig,GeoConfig,MediaRef).Size
Testing
bash scripts/buf-format.sh --check: PASS.buf build(proto compilation): PASS.bash scripts/ktfmt.sh --checkandbash scripts/license-check.sh --check: PASS. No Gradle module is in this slice, so nojvmTestordetekttasks ran.CI:
Check(ktfmt, buf format check throughscripts/buf-format.sh --check, license headers), as far as themodules in this PR's tree exist. This slice adds no Gradle module, so the protos are first compiled when
shared/corelands in K01.No deviations from the frozen tree. No currency amounts appear in these files.