Skip to content

[Collect One 7/90] Protos: survey, ACL, organization (P02) - #2702

Open
gino-m wants to merge 2 commits into
review/c1/w01-build-scaffoldingfrom
review/c1/p02-protos-survey
Open

gino-m wants to merge 2 commits into
review/c1/w01-build-scaffoldingfrom
review/c1/p02-protos-survey

Conversation

@gino-m

@gino-m gino-m commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Collect One review series: P02 Protos: survey, ACL, organization (7/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 (these arrive with the docs slices, which have
not merged yet, so they are referenced by path).

This PR is one slice of the wip/baobab tree. It only adds the files listed below.
Stacked on #2698: review only this diff; it merges after #2698.

This slice is schema only: six proto3 files in package openforis.collectone.v1.survey. Nothing compiles them
yet. The Wire code generation that reads shared/protos/survey/*.proto lives in shared/core/build.gradle.kts,
which arrives with K01.

What's in this PR

  • shared/protos/survey/survey_def.proto (1,079 lines): SurveyDef, the root container of a survey (forms,
    entity datasets, map config, translations, purpose and program IDs, versions, trash time, quota limits);
    SurveyOverview and SurveyThumbnailFeature for the survey list; SurveyOutcome; FormLaunchConfig and
    FormAvailability; FormConceptLinks; FormTemplateOrigin; EntityDatasetDef with DataTableRow,
    EntityPropertyDefinition, SamplingDesign, SubPlotDesign and ImportProvenance; MapConfig,
    SurveyArea, SurveyAreaSource, LayerDef, FormGeometrySource, GeometryStyle; the deprecated
    OfflineTilePackageDef; enums SurveyState, EntityType, OfflineTileType.
  • shared/protos/survey/acl.proto: Role (viewer, data collector, survey organizer), AclEntry with invitation
    status and invite token, CachedProfile, SharingPolicy, PeerDataVisibility, SurveyAcl, and the quota
    types QuotaTier and QuotaLimits.
  • shared/protos/survey/organization.proto: Organization, OrganizationType, OrganizationMember,
    OrganizationRole, MembershipStatus, and custom imagery (ImagerySource with XyzTileSource or
    EarthEngineTileSource).
  • shared/protos/survey/survey_service.proto: SurveyService with ListSurveyOverviews, GetSurvey,
    GetSurveyAcl, MutateSurvey, AcceptSurveyInvite, BatchGetSurveyOverviews and SearchPublicSurveys,
    plus SurveyMutation and the request and response messages.
  • shared/protos/survey/organization_service.proto: OrganizationService with GetOrganization,
    SearchOrganizations, ListOrganizations, MutateOrganization and JoinOrganization, plus
    OrganizationMutation.
  • shared/protos/survey/geo_data_service.proto: GeoDataService with GetOverlayTileUrl, GetPlotStatistics,
    GetPlotTimeSeries and GetSceneTileUrl, and their types (PlotRef, DateWindow, TimeSeriesSource,
    DoubleSeries, SceneStretch).

Where it fits

These are the wire and storage contracts for survey configuration, access, and organizations, shared by the
clients and the server. They import forms protos (P01) and data/geometry.proto, data/audit_record.proto,
library/concept.proto and earthengine/expression.proto (P03), so the imports resolve only once P01 and P03
are also in the tree.

Not in this PR

  • shared/protos/README.md and the forms protos (FormDef, DataType, LabelDef, TranslationCatalog)
    → P01 Protos: forms
  • Geometry, Position, AuditInfo, ConceptRef, the Earth Engine Expression, and GetAppliedMutations
    (in data/data_service.proto) → P03 Protos: data, library, sync, Earth Engine, user data
  • Wire code generation for these protos (shared/core/build.gradle.kts) → K01 Core 1/7:
    core.forms.serialization.textproto, core.forms.media (MediaCapture, FormStateModels)
  • SurveyMutations, OrganizationMutations, DefaultSamplingEngine, ProtoFieldCoverageTest → K06 Core 6/7:
    mutation, sampling (DefaultSamplingEngine, SurveyMutations)
  • OrganizationServiceImpl, GeoDataServiceImpl → S03 Server 3/4: service, geo (DataMutationApplier,
    ImageryAnalytics)
  • SurveyServiceImpl → S04 Server 4/4: service, app (SurveyServiceImpl, Main)
  • ProtoSurveyMapper → A08 App data 3/5: mapper, repository (ProtoSurveyMapper, ProtoRecordMapper)
  • The docs the comments cite: docs/technical/backend/impact-aggregation.md → D02 Docs: technical 1/2: client,
    backend; docs/technical/sync-engine.md and docs/technical/model/... → D03 Docs: technical 2/2: forms,
    survey

Suggested reading order

  1. acl.proto: roles, sharing policy, and quotas; every other file uses them.
  2. survey_def.proto: SurveyDef first, then EntityDatasetDef and SamplingDesign, then MapConfig and
    SurveyArea, then SurveyOverview.
  3. survey_service.proto: the RPC comments, then SurveyMutation and MutateSurveyRequest.
  4. organization.proto, then organization_service.proto.
  5. geo_data_service.proto.

Focus areas

  • Mutation model: SurveyMutation and OrganizationMutation carry sparse delete and upsert instances of
    the resource itself. delete is applied first as a structural mask, then upsert is merged recursively.
    Trash and restore use upsert.trash_time and delete.trash_time. Is that clear enough to implement from?
  • Three version fields on SurveyDef: version (string, saved revision), saved_revision_number, and
    record_version (one counter shared by the saved revision, the working copy and the ACL).
    MutateSurveyRequest.base_version is a string compared with version, while
    MutateOrganizationRequest.base_version is an int64 compared with Organization.version.
  • List RPCs: query mode and delta mode selected by sync_token, at-least-once delivery, and tombstones
    (SurveyState.DELETED on overviews, is_deleted on organizations).
  • Access rules: SharingPolicy with SurveyAcl.default_role (never SURVEY_ORGANIZER), organization managers
    getting SURVEY_ORGANIZER on every survey of their organization, and invite tokens stored on AclEntry and
    OrganizationMember.
  • SamplingDesign: methods, allocation, seed and engine_version for reproducible plots, and input_hash
    for detecting a stale design.
  • Reserved fields: many removed fields are reserved by number and name with a comment on what replaced them
    (for example the forms.GeoPoint and forms.GeoShape geometry fields replaced by data.Geometry).
  • Things that look like leftovers, worth a comment if you agree: the QuotaLimits comments on
    Organization.quota_limits, SurveyDef.quota_limits and SurveyOverview.quota_limits still mention a
    budget cap, but that field is reserved in QuotaLimits; the comment "Dictionary concepts linked to the
    questions of one form." sits above FormTemplateOrigin instead of FormConceptLinks;
    OfflineTilePackageDef is marked deprecated in its comment; and SurveyDef.custom_extensions (Any) is
    documented as not supported by the client codecs.

Safe to skim

  • License headers and the plain request and response wrappers (Get...Request, Get...Response, search and
    list pages).
  • Enum value lists such as OrganizationType, SurveyOutcome.Outcome, SceneStretch and OfflineTileType.
  • The per-tier numbers in the QuotaLimits field comments.

Size

Source Tests Data Files
2306 0 0 6

Testing

bash scripts/buf-format.sh --check: PASS. buf build (proto compilation): PASS. bash scripts/ktfmt.sh --check and bash scripts/license-check.sh --check: PASS. No Gradle module is in this slice, so no jvmTest or detekt tasks ran.
CI: Check (ktfmt, buf, license headers), as far as the modules in this PR's tree exist. This slice adds no
Gradle module, so the checks that apply to it are the buf format check (scripts/buf-format.sh --check) and
the license header check. The protos are first compiled when K01 adds the Wire code generation.

@gino-m gino-m added the collect-one Tickets related to Collect One label Nov 27, 2026
@gino-m
gino-m requested a review from rfontanarosa November 27, 2026 19:21
@gino-m gino-m self-assigned this Nov 27, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive set of Protocol Buffer definitions for the Collect One survey and organization management platform, covering access control lists, geospatial data services, multi-tenant organizations, and core survey definitions along with their respective gRPC services. The schemas are well-designed, but several minor improvements should be made: a misplaced comment in survey_def.proto needs to be relocated, outdated references to a removed budget cap in quota limit comments should be cleaned up, the population_year field in geo_data_service.proto should be marked optional to handle missing data correctly, and deprecated offline tile package definitions should be formally marked with deprecation options.

Comment thread shared/protos/survey/survey_def.proto Resolved
Comment thread shared/protos/survey/survey_def.proto Resolved
Comment thread shared/protos/survey/organization.proto Resolved
Comment on lines +118 to +119
// Year of the population estimate.
int32 population_year = 6;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since the population estimate itself is optional (optional double population), the population_year field should also be marked as optional to avoid defaulting to 0 when population data is unavailable.

Suggested change
// Year of the population estimate.
int32 population_year = 6;
// Year of the population estimate. Unset when population data is unavailable.
optional int32 population_year = 6;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✦ Good question; checking with the author and will follow up here.

Comment thread shared/protos/survey/survey_def.proto Resolved
Comment thread shared/protos/survey/survey_def.proto Resolved
gino-m added a commit that referenced this pull request Nov 27, 2026
…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)
SurveyDef, ACLs, organizations, and the Survey and Organization services.

Sliced from wip/baobab @ db237d5. Tracking: #2629.
@gino-m
gino-m force-pushed the review/c1/p02-protos-survey branch from 2a4674b to ba60a4f Compare November 28, 2026 01:33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

collect-one Tickets related to Collect One

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant