Skip to content

Polysemy Spar: Laws for DefaultSsoCode, Now, IdP and ScimExternalIdStore#1940

Merged
fisx merged 43 commits intodevelopfrom
in-mem-specs
Dec 16, 2021
Merged

Polysemy Spar: Laws for DefaultSsoCode, Now, IdP and ScimExternalIdStore#1940
fisx merged 43 commits intodevelopfrom
in-mem-specs

Conversation

@isovector
Copy link
Contributor

@isovector isovector commented Nov 23, 2021

This PR adds polysemy-check laws for Now, DefaultSsoCode, IdP and ScimExternalIdStore. Now is just a check that the function is monotonic, and the other three are the usual lens laws (+ delete).

The remaining "store" effects in spar have weird TTL semantics that I haven't yet worked out what the laws should be. I'll follow up with those when I figure the semantics out.

Checklist

  • The PR Title explains the impact of the change.
  • The PR description provides context as to why the change should occur and what the code contributes to that effect. This could also be a link to a JIRA ticket or a Github issue, if there is one.
  • A file with the changelog entry in one or more suitable sub-sections. The sub-sections are marked by directories inside changelog.d.

@isovector isovector requested review from fisx and pcapriotti November 23, 2021 20:39
@fisx
Copy link
Contributor

fisx commented Nov 24, 2021

The remaining "store" effects in spar have weird TTL semantics that I haven't yet worked out what the laws should be. I'll follow up with those when I figure the semantics out.

you should interview your client on those. :) you can talk to either me or @smatting to learn more.

Base automatically changed from in-mem-interpreters to develop November 24, 2021 22:56
@isovector
Copy link
Contributor Author

isovector commented Nov 25, 2021

CI seems to be genuinely broken. I'll brave setting up the integration tests locally tomorrow! 😱

@smatting
Copy link
Contributor

@isovector FYI, the README.md has a section on how to run them locally.

@isovector
Copy link
Contributor Author

Turns out CI was flakey. Everything is fixed now. @pcapriotti, @fisx , PTAL.

Copy link
Contributor

@fisx fisx left a comment

Choose a reason for hiding this comment

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

Would be nice to run this against the cassandra implementation as well. I would like to have the specs in services/src/Spar/Sem/*/Spec.hs, and have a very small integration test suite that just sticks it all together. But this can be done in the a different PR.

But there are some tests in here that I don't understand. Maybe it's time to pair again?

-- before and after its generators, and check their results for equality. We
-- can't use 'Now' as this effect, because 'E.get' won't return equivalent
-- results! And we can't keep it empty, because that triggers a crash in
-- @polysemy-check@. Thus @Input ()@, which isn't beautiful, but works fine.
Copy link
Contributor

Choose a reason for hiding this comment

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

if it's an oversight, is there a ticket in polysemy-check for allowing empty effect lists? do you have an idea how to fix it?

Comment on lines 126 to 127
E.deleteConfig s
pure Nothing
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this test may be pointless if you haven't been careful about the Arbitrary instance. Does it return the same UUID twice in a few calls with non-negligible probability?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right --- it almost certainly doesn't. What would you say are the odds of the generators respecting the size parameter?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no idea. :) experiment? I'm not sure that's the right approach, though. We want the keys to come from a small set so that collisions are common, but not anything else. If we didn't use quickcheck but registry, we could "easily" replace the underlying UUID and Issuer generators, but with quickcheck I'm not sure what to do.

(Note to self: the Issuer generator may have not enough entropy, instead of too much. With some of the generators I've been quite lazy.)

getReplacedBy replaced_id,
do
E.setReplacedBy replaced replacing
(Just replacing_id <$) <$> E.getConfig replaced_id
Copy link
Contributor

Choose a reason for hiding this comment

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

... and I'm not sure this is making too much sense. What are you trying to test here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shows that getReplacedBy actually gives you back what you replaced it by, right?

Copy link
Contributor

@fisx fisx Dec 3, 2021

Choose a reason for hiding this comment

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

Yes, but why the getConfig? Why just pure $ Just replacing_id? (Sorry, my first question wasn't very helpful. It was late...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, yeah. Because this is a Maybe (Maybe IdPId) where the outer maybe depends on whether the thing exists in the first place.

@isovector
Copy link
Contributor Author

@fisx good catch --- coverage checking pointed out that we were hitting lots of pathological cases. I think I've the worrisome ones.

@isovector
Copy link
Contributor Author

@fisx I'd like to get this merged.

if s ^. SAML.idpId == s' ^. SAML.idpId
then discard
else pure ()
when (s ^. SAML.idpId == s' ^. SAML.idpId) discard
Copy link
Contributor

Choose a reason for hiding this comment

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

didn't we say this has negligible probability?

@@ -0,0 +1 @@
Added laws for DefaultSsoCode, Now, IdP and ScimExternalIdStore
Copy link
Contributor

Choose a reason for hiding this comment

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

this may be a bit confusing for the casual reader of the release notes. i'll fix it on develop after merging.

@fisx fisx merged commit 4e1b8fb into develop Dec 16, 2021
@fisx fisx deleted the in-mem-specs branch December 16, 2021 20:11
@akshaymankar akshaymankar mentioned this pull request Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants